[Nix-dev] statically linking gcc in Nix fails
Armijn Hemel
armijn at uulug.nl
Fri Oct 22 17:33:18 CEST 2004
hi,
> > I'm trying to compile gcc statically in Nix. I adapted the default.nix
> > and builder.sh from the default gcc-3.4.2 in nixpkgs, but I get the
> > following error:
> >
> > impure path `/usr/lib/crti.o' used in link
>
> When do you get this error? The compiler locates crti.o using the search
> path set through the -B option. For instance,
> pkgs/build-support/gcc-wrapper/builder.sh adds `-B$glibc/lib' to the
> compiler flags. Is that being passed?
Like this?
gcc -c -DHAVE_CONFIG_H
-B/nix/store/25953718bb7723f1d38d00a42d7afa2d-glibc-2.3.3/lib -isystem
/nix/store/25953718bb7723f1d38d00a42d7afa2d-glibc-2.3.3/include
-I. -I./../include -W -Wall -Wtraditional -pedantic regex.c -o
pic/regex.o; \
else true; fi
That is. But afterwards it starts building libgcc and it uses the just
built compiler, without the needed flags. How
/tmp/nix-10093-0/gcc-3.4.2/gcc/xgcc -B/tmp/nix-10093-0/gcc-3.4.2/gcc/
-B/nix/store/790cc4117e26b4522819a7836af6f903-gcc-static-3.4.2/i686-pc-linux-gnu/bin/
-B/nix/store/790cc4117e26b4522819a7836af6f903-gcc-static-3.4.2/i686-pc-linux-gnu/lib/ -isystem
/nix/store/790cc4117e26b4522819a7836af6f903-gcc-static-3.4.2/i686-pc-linux-gnu/include -isystem
/nix/store/790cc4117e26b4522819a7836af6f903-gcc-static-3.4.2/i686-pc-linux-gnu/sys-include
-O2 [...]
and glibc doesn't seem to be passed. I copied the builder.sh and
default.nix pretty much verbatim from gcc-3.4, only changed the
preConfigure (added export LDFLAGS="-static" and only build a compiler
for the C language), changed the patch so it would also use my LDFLAGS,
ripped out profiled-compiler build.
It appears that my "-static" flag is the culprit. Only -static is passed
to the linker, not the Nix stuff. Sigh, patch debugging :)
armijn
--
---------------------------------------------------------------------------
armijn at uulug.nl | http://www.uulug.nl/ | UULug: Utrecht Linux Users Group
---------------------------------------------------------------------------
More information about the nix-dev
mailing list