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
...
1) Building with clang is addressed by navigating a minor #if in some
of the code.
2) I noticed that even when things were building correctly, passing
`${out}` as a variable assignment to `make` was actually not working:
there were compiler warnings about missing include directories whose
bogus paths involved the literal string `out`. I ended up fixing this
by performing the assignment to the make variable `PREFIX` in the
`Makefile` itself.
This makes memoization of Nixpkgs evaluation less effective, since
some Nixpkgs invocations may have 'config = {}' while others may have
'config = { xorg = {}; }'.
Instead set 'config = {}'.