diff --git a/pkgs/baseenv/baseenv-build.sh b/pkgs/baseenv/baseenv-build.sh index 0b4c0d0fedc5..b0c7073f0ba3 100755 --- a/pkgs/baseenv/baseenv-build.sh +++ b/pkgs/baseenv/baseenv-build.sh @@ -9,20 +9,17 @@ sed \ -e s^@OUT\@^$out^g \ < $setup > $out/setup || exit 1 -gcc='$NIX_CC' - sed \ - -e s^@GCC\@^$gcc^g \ + -e 's^@GCC\@^$NIX_CC^g' \ < $gccwrapper > $out/bin/gcc || exit 1 chmod +x $out/bin/gcc || exit 1 - -ln -s gcc $out/bin/cc - -gcc='$NIX_CXX' +ln -s gcc $out/bin/cc || exit 1 sed \ - -e s^@GCC\@^$gcc^g \ + -e 's^@GCC\@^$NIX_CXX^g' \ < $gccwrapper > $out/bin/g++ || exit 1 chmod +x $out/bin/g++ || exit 1 +ln -s g++ $out/bin/c++ || exit 1 -ln -s g++ $out/bin/c++ +cp $ldwrapper $out/bin/ld || exit 1 +chmod +x $out/bin/ld || exit 1 diff --git a/pkgs/baseenv/baseenv.fix b/pkgs/baseenv/baseenv.fix index 5efa61d08a0a..62c8c502e34c 100644 --- a/pkgs/baseenv/baseenv.fix +++ b/pkgs/baseenv/baseenv.fix @@ -1,8 +1,9 @@ Package( - [ ("name", "stdenv-native") + [ ("name", "baseenv") , ("build", Relative("baseenv/baseenv-build.sh")) , ("setup", Relative("baseenv/setup.sh")) , ("gccwrapper", Relative("baseenv/gcc-wrapper.sh")) + , ("ldwrapper", Relative("baseenv/ld-wrapper.sh")) ] ) diff --git a/pkgs/baseenv/gcc-wrapper.sh b/pkgs/baseenv/gcc-wrapper.sh index 9ce4167bce4a..f743c96ec2f0 100644 --- a/pkgs/baseenv/gcc-wrapper.sh +++ b/pkgs/baseenv/gcc-wrapper.sh @@ -6,26 +6,33 @@ justcompile=0 for i in $@; do if test "$i" == "-c"; then justcompile=1 - fi - if test "$i" == "-S"; then + elif test "$i" == "-S"; then justcompile=1 - fi - if test "$i" == "-E"; then + elif test "$i" == "-E"; then + justcompile=1 + elif test "$i" == "-E"; then + justcompile=1 + elif test "$i" == "-M"; then + justcompile=1 + elif test "$i" == "-MM"; then justcompile=1 fi done IFS=" " -extra=($NIX_CFLAGS) +extra=($NIX_CFLAGS_COMPILE) if test "$justcompile" != "1"; then - extra=(${extra[@]} $NIX_LDFLAGS) + extra=(${extra[@]} $NIX_CFLAGS_LINK) + for i in $NIX_LDFLAGS; do + extra=(${extra[@]} "-Wl,$i") + done if test "$NIX_STRIP_DEBUG" == "1"; then - extra=(${extra[@]} -Wl,-s) + extra=(${extra[@]} -g0 -Wl,-s) fi fi if test "$NIX_DEBUG" == "1"; then - echo "extra gcc flags:" >&2 + echo "extra flags to @GCC@:" >&2 for i in ${extra[@]}; do echo " $i" >&2 done diff --git a/pkgs/baseenv/setup.sh b/pkgs/baseenv/setup.sh index 4cdd3518247b..60f71bfddf60 100644 --- a/pkgs/baseenv/setup.sh +++ b/pkgs/baseenv/setup.sh @@ -11,7 +11,8 @@ addtoenv() fi if test -d $1/lib; then - export NIX_LDFLAGS="-L $1/lib -Wl,-rpath,$1/lib $NIX_LDFLAGS" + export NIX_CFLAGS_LINK="-L$1/lib $NIX_CFLAGS_LINK" + export NIX_LDFLAGS="-rpath $1/lib $NIX_LDFLAGS" fi if test -d $1/lib/pkgconfig; then @@ -33,7 +34,7 @@ for i in $oldenvpkgs; do done # Add the output as an rpath. -export NIX_LDFLAGS="-Wl,-rpath,$out/lib $NIX_LDFLAGS" +export NIX_LDFLAGS="-rpath $out/lib $NIX_LDFLAGS" # Strip debug information by default. export NIX_STRIP_DEBUG=1 diff --git a/pkgs/gcc/gcc-build.sh b/pkgs/gcc/gcc-build.sh index a6b8d87eadc3..480caf694bc5 100755 --- a/pkgs/gcc/gcc-build.sh +++ b/pkgs/gcc/gcc-build.sh @@ -20,7 +20,10 @@ cd build || exit 1 ../gcc-*/configure --prefix=$out --enable-languages=c,c++ || exit 1 # Patch some of the makefiles to force linking against our own glibc. -extraflags="$NIX_CFLAGS $NIX_LDFLAGS -Wl,-s -isystem $linux/include" +extraflags="-Wl,-s -isystem $linux/include $NIX_CFLAGS_COMPILE $NIX_CFLAGS_LINK" +for i in $NIX_LDFLAGS; do + extraflags="$extraflags -Wl,$i" +done mf=Makefile sed \ diff --git a/pkgs/stdenv-linux/setup-nativetools.sh b/pkgs/stdenv-linux/setup-nativetools.sh index c1b4bc610263..f675389306d3 100644 --- a/pkgs/stdenv-linux/setup-nativetools.sh +++ b/pkgs/stdenv-linux/setup-nativetools.sh @@ -3,7 +3,9 @@ export SHELL=/bin/sh . @BASEENV@/setup -export NIX_CFLAGS="-isystem @GLIBC@/include $NIX_CFLAGS" -export NIX_LDFLAGS="-L@GLIBC@/lib -Wl,-dynamic-linker,@GLIBC@/lib/ld-linux.so.2,-rpath,@GLIBC@/lib $NIX_LDFLAGS" +export NIX_CFLAGS_COMPILE="-isystem @GLIBC@/include $NIX_CFLAGS_COMPILE" +export NIX_CFLAGS_LINK="-L@GLIBC@/lib $NIX_CFLAGS_LINK" +export NIX_LDFLAGS="-dynamic-linker @GLIBC@/lib/ld-linux.so.2 -rpath @GLIBC@/lib $NIX_LDFLAGS" export NIX_CC=/usr/bin/gcc export NIX_CXX=/usr/bin/g++ +export NIX_LD=/usr/bin/ld diff --git a/pkgs/stdenv-linux/setup.sh b/pkgs/stdenv-linux/setup.sh index aa195830c533..5c7fce62feca 100644 --- a/pkgs/stdenv-linux/setup.sh +++ b/pkgs/stdenv-linux/setup.sh @@ -3,10 +3,12 @@ export SHELL=@SHELL@ . @BASEENV@/setup -export NIX_CFLAGS="-isystem @GLIBC@/include -isystem @LINUX@/include $NIX_CFLAGS" -export NIX_LDFLAGS="-L@GLIBC@/lib -Wl,-dynamic-linker,@GLIBC@/lib/ld-linux.so.2,-rpath,@GLIBC@/lib $NIX_LDFLAGS -L@GCC@/lib -Wl,-rpath,@GCC@/lib" +export NIX_CFLAGS_COMPILE="-isystem @GLIBC@/include -isystem @LINUX@/include $NIX_CFLAGS_COMPILE" +export NIX_CFLAGS_LINK="-L@GLIBC@/lib -L@GCC@/lib $NIX_CFLAGS_LINK" +export NIX_LDFLAGS="-dynamic-linker @GLIBC@/lib/ld-linux.so.2 -rpath @GLIBC@/lib -rpath @GCC@/lib $NIX_LDFLAGS" export NIX_CC=@CC@ export NIX_CXX=@CXX@ +export NIX_LD=@LD@ export NIX_LIBC_INCLUDES="@GLIBC@/include" export NIX_LIBC_LIBS="@GLIBC@/lib" diff --git a/pkgs/stdenv-linux/stdenv-build.sh b/pkgs/stdenv-linux/stdenv-build.sh index c73f08ea6ce1..437707f74126 100755 --- a/pkgs/stdenv-linux/stdenv-build.sh +++ b/pkgs/stdenv-linux/stdenv-build.sh @@ -6,7 +6,7 @@ mkdir $out || exit 1 p= first=1 -for i in $tools; do +for i in $tools $gcc $binutils $shell; do if test "$first" == 1; then first= else @@ -17,6 +17,7 @@ done cc=$gcc/bin/gcc cxx=$gcc/bin/g++ +ld=$binutils/bin/ld shell=$shell/bin/sh echo "########## $p" @@ -27,6 +28,7 @@ sed \ -e s^@GCC\@^$gcc^g \ -e s^@CC\@^$cc^g \ -e s^@CXX\@^$cxx^g \ + -e s^@LD\@^$ld^g \ -e s^@BASEENV\@^$baseenv^g \ -e s^@PATH\@^$p^g \ -e s^@SHELL\@^$shell^g \ diff --git a/pkgs/stdenv-linux/stdenv-nativetools-build.sh b/pkgs/stdenv-linux/stdenv-nativetools-build.sh index 4b1d6d2d6820..16ac884f7e1e 100755 --- a/pkgs/stdenv-linux/stdenv-nativetools-build.sh +++ b/pkgs/stdenv-linux/stdenv-nativetools-build.sh @@ -6,9 +6,5 @@ mkdir $out || exit 1 sed \ -e s^@GLIBC\@^$glibc^g \ - -e s^@CC\@^$cc^g \ - -e s^@CXX\@^$cxx^g \ -e s^@BASEENV\@^$baseenv^g \ - -e s^@PATH\@^$p^g \ - -e s^@SHELL\@^$shell^g \ < $setup > $out/setup || exit 1 diff --git a/pkgs/stdenv-linux/stdenv-nativetools.fix b/pkgs/stdenv-linux/stdenv-nativetools.fix index 5e1187b9d36c..28a7f8095398 100644 --- a/pkgs/stdenv-linux/stdenv-nativetools.fix +++ b/pkgs/stdenv-linux/stdenv-nativetools.fix @@ -1,5 +1,5 @@ Package( - [ ("name", "stdenv-linux") + [ ("name", "stdenv-nativetools") , ("build", Relative("stdenv-linux/stdenv-nativetools-build.sh")) , ("setup", Relative("stdenv-linux/setup-nativetools.sh")) diff --git a/pkgs/stdenv-linux/stdenv.fix b/pkgs/stdenv-linux/stdenv.fix index eea9541c5e29..75457300baf6 100644 --- a/pkgs/stdenv-linux/stdenv.fix +++ b/pkgs/stdenv-linux/stdenv.fix @@ -18,11 +18,11 @@ Package( , IncludeFix("gzip/gzip.fix") , IncludeFix("bzip2/bzip2.fix") , IncludeFix("gnumake/gnumake.fix") - , IncludeFix("binutils/binutils.fix") , IncludeFix("bash/bash.fix") ]) , ("gcc", IncludeFix("gcc/gcc.fix")) + , ("binutils", IncludeFix("binutils/binutils.fix")) , ("shell", IncludeFix("bash/bash.fix")) ] )