[Nix-dev] Problem boostrapping binutils in stdenv

Lluís Batlle i Rossell viriketo at gmail.com
Tue Dec 14 11:15:06 CET 2010


The newer binutils link everything -lz.

I added the explicit dependency of binutils on zlib recently (r24790). Otherwise it was
taken from bootstrap-tools. This created a dependency on bootstrap-tools though we did
not want (iirc).

I fixed a bug yesterday that made binutils link with the proper zlib, but due to
rpath, it ilnked at runtime with the wrong zlib (r25107).

This made appear another problem; the rpath is put into the same order as the
"-l" flags. Here are the flags to ld when linking gcc (glibc built, gcc still from
bootstrap-tools):

	--strip-debug
	-lgcc
	--as-needed
	-lgcc_s
	--no-as-needed
	-lc
	-lgcc
	--as-needed
	-lgcc_s
	--no-as-needed

So, libgcc_s is from bootstrap-tools, and libc is from the glibc path. Due to
the order of -L flags, it links with the good libc at 'ld' time, but due to the
order of "-l" (determining the later rpath order) it links at runtime with the
bad 'libc' (that of bootstrap-tools, because -lgcc comes before -lc).

So, as a solution we never had, I think we should respect the order of the -L
and not of the -l, when adding the rpath.

Why all this worked before? Because we did not build binutils before glibc
before, because then binutils did not need zlib, then they
needed zlib but some bootstrap-tools had a zlib matching that of nixpkgs (not
the case of mips, where all failed), ...

What do you think?



More information about the nix-dev mailing list