6bfa42218d
gcc provides wrappers for binutils' ar, nm and ranlib executables, which must be used instead when using link-time optimisation. See also: http://manpages.ubuntu.com/manpages/zesty/man1/aarch64-linux-gnu-gcc-ar-5.1.html The upstream version of avr-gcc-ar searches in paths passed to the configure script for the avr-ar binary that it wraps, falling back to searching PATH instead. Thus currently avr-gcc-ar works on Nix, but only if avrbinutils is already in the environment. This change bakes the path to avr-ar into avr-gcc-ar, since its path is known at compile time. It also no longer searches PATH, meaning the user's local environment won't override this path. Note that avr-gcc-nm and avr-gcc-ranlib are compiled from the same source file as avr-gcc-ar, just with different compiler flags. Testing on master (without avrbinutils in the environment): $ nix-build -A avrgcc $ result/bin/avr-gcc-ar --version result/bin/avr-gcc-ar: Cannot find binary 'avr-ar' Testing on branch with this fix: $ nix-build -A avrgcc $ result/bin/avr-gcc-ar --version GNU ar (GNU Binutils) 2.26.20160125 ...
60 lines
1.4 KiB
Nix
60 lines
1.4 KiB
Nix
{ stdenv, fetchurl, gmp, mpfr, libmpc, zlib, avrbinutils, texinfo }:
|
|
|
|
let
|
|
version = "5.4.0";
|
|
in
|
|
stdenv.mkDerivation {
|
|
|
|
name = "avr-gcc-${version}";
|
|
src = fetchurl {
|
|
url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.bz2";
|
|
sha256 = "0fihlcy5hnksdxk0sn6bvgnyq8gfrgs8m794b1jxwd1dxinzg3b0";
|
|
};
|
|
|
|
patches = [
|
|
./avrbinutils-path.patch
|
|
];
|
|
|
|
# avrbinutils-path.patch introduces a reference to @avrbinutils@, substitute
|
|
# it now.
|
|
postPatch = ''
|
|
substituteInPlace gcc/gcc-ar.c --subst-var-by avrbinutils ${avrbinutils}
|
|
'';
|
|
|
|
buildInputs = [ gmp mpfr libmpc zlib avrbinutils ];
|
|
|
|
nativeBuildInputs = [ texinfo ];
|
|
|
|
hardeningDisable = [ "format" ];
|
|
|
|
stripDebugList= [ "bin" "libexec" ];
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
configurePhase = ''
|
|
mkdir gcc-build
|
|
cd gcc-build
|
|
../configure \
|
|
--prefix=$out \
|
|
--host=$CHOST \
|
|
--build=$CHOST \
|
|
--target=avr \
|
|
--with-as=${avrbinutils}/bin/avr-as \
|
|
--with-gnu-as \
|
|
--with-gnu-ld \
|
|
--with-ld=${avrbinutils}/bin/avr-ld \
|
|
--with-system-zlib \
|
|
--disable-install-libiberty \
|
|
--disable-nls \
|
|
--disable-libssp \
|
|
--with-dwarf2 \
|
|
--enable-languages=c,c++'';
|
|
|
|
meta = with stdenv.lib; {
|
|
description = "GNU Compiler Collection, version ${version} for AVR microcontrollers";
|
|
homepage = http://gcc.gnu.org;
|
|
license = licenses.gpl3Plus;
|
|
platforms = platforms.unix;
|
|
maintainers = with maintainers; [ mguentner ];
|
|
};
|
|
}
|