diff options
author | Robin Gloster <mail@glob.in> | 2016-04-18 13:00:40 +0000 |
---|---|---|
committer | Robin Gloster <mail@glob.in> | 2016-04-18 13:49:22 +0000 |
commit | d020caa5b2eca90ea051403fbb4c52b99ee071b9 (patch) | |
tree | ba44ef1e784bca89e0df6b249956fd035b1d86e3 /pkgs/build-support/cc-wrapper | |
parent | 3e68106afd95df012ddb548575f0133681687a90 (diff) | |
parent | 0729f606973870c03d21bb2f21b70d91216943ca (diff) | |
download | nixlib-d020caa5b2eca90ea051403fbb4c52b99ee071b9.tar nixlib-d020caa5b2eca90ea051403fbb4c52b99ee071b9.tar.gz nixlib-d020caa5b2eca90ea051403fbb4c52b99ee071b9.tar.bz2 nixlib-d020caa5b2eca90ea051403fbb4c52b99ee071b9.tar.lz nixlib-d020caa5b2eca90ea051403fbb4c52b99ee071b9.tar.xz nixlib-d020caa5b2eca90ea051403fbb4c52b99ee071b9.tar.zst nixlib-d020caa5b2eca90ea051403fbb4c52b99ee071b9.zip |
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
Diffstat (limited to 'pkgs/build-support/cc-wrapper')
-rw-r--r-- | pkgs/build-support/cc-wrapper/cc-wrapper.sh | 4 | ||||
-rw-r--r-- | pkgs/build-support/cc-wrapper/default.nix | 62 | ||||
-rw-r--r-- | pkgs/build-support/cc-wrapper/gnat-wrapper.sh | 4 | ||||
-rw-r--r-- | pkgs/build-support/cc-wrapper/ld-wrapper.sh | 4 | ||||
-rw-r--r-- | pkgs/build-support/cc-wrapper/setup-hook.sh | 16 |
5 files changed, 46 insertions, 44 deletions
diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh index 8dbf2b8452bf..688dd7be1c6f 100644 --- a/pkgs/build-support/cc-wrapper/cc-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh @@ -1,7 +1,7 @@ #! @shell@ -e path_backup="$PATH" -if [ -n "@coreutils@" ]; then - PATH="@coreutils@/bin:@gnugrep@/bin" +if [ -n "@coreutils_bin@" ]; then + PATH="@coreutils_bin@/bin:@gnugrep_bin@/bin" fi if [ -n "$NIX_CC_WRAPPER_START_HOOK" ]; then diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 2bf07747337f..0d862fe53dea 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -27,6 +27,13 @@ let ccVersion = (builtins.parseDrvName cc.name).version; ccName = (builtins.parseDrvName cc.name).name; + libc_bin = if nativeLibc then null else libc.bin or libc; + libc_dev = if nativeLibc then null else libc.dev or libc; + libc_lib = if nativeLibc then null else libc.out or libc; + cc_solib = cc.lib or cc; + binutils_bin = if nativeTools then "" else binutils.bin or binutils; + # The wrapper scripts use 'cat' and 'grep', so we may need coreutils. + coreutils_bin = if nativeTools then "" else coreutils.bin or coreutils; in stdenv.mkDerivation { @@ -36,15 +43,10 @@ stdenv.mkDerivation { preferLocalBuild = true; - inherit cc shell; - libc = if nativeLibc then null else libc; - binutils = if nativeTools then "" else binutils; - # The wrapper scripts use 'cat' and 'grep', so we may need coreutils - # and gnugrep. - coreutils = if nativeTools then "" else coreutils; - gnugrep = if nativeTools then "" else gnugrep; + inherit cc shell libc_bin libc_dev libc_lib binutils_bin coreutils_bin; + gnugrep_bin = if nativeTools then "" else gnugrep; - passthru = { inherit nativeTools nativeLibc nativePrefix isGNU isClang; }; + passthru = { inherit libc nativeTools nativeLibc nativePrefix isGNU isClang; }; buildCommand = '' @@ -60,11 +62,11 @@ stdenv.mkDerivation { '' + optionalString (!nativeLibc) (if (!stdenv.isDarwin) then '' - dynamicLinker="$libc/lib/$dynamicLinker" + dynamicLinker="${libc_lib}/lib/$dynamicLinker" echo $dynamicLinker > $out/nix-support/dynamic-linker - if [ -e $libc/lib/32/ld-linux.so.2 ]; then - echo $libc/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 + if [ -e ${libc_lib}/lib/32/ld-linux.so.2 ]; then + echo ${libc_lib}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 fi # The dynamic linker is passed in `ldflagsBefore' to allow @@ -78,7 +80,7 @@ stdenv.mkDerivation { '') + optionalString (!nativeLibc) '' - # The "-B$libc/lib/" flag is a quick hack to force gcc to link + # The "-B${libc_lib}/lib/" flag is a quick hack to force gcc to link # against the crt1.o from our own glibc, rather than the one in # /usr/lib. (This is only an issue when using an `impure' # compiler/linker, i.e., one that searches /usr/lib and so on.) @@ -89,11 +91,11 @@ stdenv.mkDerivation { # compile, because it uses "#include_next <limits.h>" to find the # limits.h file in ../includes-fixed. To remedy the problem, # another -idirafter is necessary to add that directory again. - echo "-B$libc/lib/ -idirafter $libc/include -idirafter $cc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags + echo "-B${libc_lib}/lib/ -idirafter ${libc_dev}/include -idirafter ${cc}/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags - echo "-L$libc/lib" > $out/nix-support/libc-ldflags + echo "-L${libc_lib}/lib" > $out/nix-support/libc-ldflags - echo $libc > $out/nix-support/orig-libc + echo "${libc_lib}" > $out/nix-support/orig-libc '' + (if nativeTools then '' @@ -102,23 +104,23 @@ stdenv.mkDerivation { '' else '' echo $cc > $out/nix-support/orig-cc - # GCC shows $cc/lib in `gcc -print-search-dirs', but not - # $cc/lib64 (even though it does actually search there...).. + # GCC shows ${cc_solib}/lib in `gcc -print-search-dirs', but not + # ${cc_solib}/lib64 (even though it does actually search there...).. # This confuses libtool. So add it to the compiler tool search # path explicitly. - if [ -e "$cc/lib64" -a ! -L "$cc/lib64" ]; then - ccLDFlags+=" -L$cc/lib64" - ccCFlags+=" -B$cc/lib64" + if [ -e "${cc_solib}/lib64" -a ! -L "${cc_solib}/lib64" ]; then + ccLDFlags+=" -L${cc_solib}/lib64" + ccCFlags+=" -B${cc_solib}/lib64" fi - ccLDFlags+=" -L$cc/lib" + ccLDFlags+=" -L${cc_solib}/lib" ${optionalString cc.langVhdl or false '' - ccLDFlags+=" -L${zlib}/lib" + ccLDFlags+=" -L${zlib.out}/lib" ''} # Find the gcc libraries path (may work only without multilib). ${optionalString cc.langAda or false '' - basePath=`echo $cc/lib/*/*/*` + basePath=`echo ${cc_solib}/lib/*/*/*` ccCFlags+=" -B$basePath -I$basePath/adainclude" gnatCFlags="-aI$basePath/adainclude -aO$basePath/adalib" echo "$gnatCFlags" > $out/nix-support/gnat-cflags @@ -134,13 +136,13 @@ stdenv.mkDerivation { echo "$ccLDFlags" > $out/nix-support/cc-ldflags echo "$ccCFlags" > $out/nix-support/cc-cflags - ccPath="$cc/bin" - ldPath="$binutils/bin" + ccPath="${cc}/bin" + ldPath="${binutils_bin}/bin" # Propagate the wrapped cc so that if you install the wrapper, # you get tools like gcov, the manpages, etc. as well (including # for binutils and Glibc). - echo $cc $binutils $libc > $out/nix-support/propagated-user-env-packages + echo ${cc} ${cc.man or ""} ${binutils_bin} ${libc_bin} > $out/nix-support/propagated-user-env-packages echo ${toString extraPackages} > $out/nix-support/propagated-native-build-inputs '' @@ -162,12 +164,12 @@ stdenv.mkDerivation { wrap ld ${./ld-wrapper.sh} ''${ld:-$ldPath/ld} - if [ -e $binutils/bin/ld.gold ]; then - wrap ld.gold ${./ld-wrapper.sh} $binutils/bin/ld.gold + if [ -e ${binutils_bin}/bin/ld.gold ]; then + wrap ld.gold ${./ld-wrapper.sh} ${binutils_bin}/bin/ld.gold fi - if [ -e $binutils/bin/ld.bfd ]; then - wrap ld.bfd ${./ld-wrapper.sh} $binutils/bin/ld.bfd + if [ -e ${binutils_bin}/bin/ld.bfd ]; then + wrap ld.bfd ${./ld-wrapper.sh} ${binutils_bin}/bin/ld.bfd fi export real_cc=cc diff --git a/pkgs/build-support/cc-wrapper/gnat-wrapper.sh b/pkgs/build-support/cc-wrapper/gnat-wrapper.sh index 012f826a111e..0d74527dd8ad 100644 --- a/pkgs/build-support/cc-wrapper/gnat-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/gnat-wrapper.sh @@ -1,7 +1,7 @@ #! @shell@ -e path_backup="$PATH" -if [ -n "@coreutils@" ]; then - PATH="@coreutils@/bin" +if [ -n "@coreutils_bin@" ]; then + PATH="@coreutils_bin@/bin" fi if [ -n "$NIX_GNAT_WRAPPER_START_HOOK" ]; then diff --git a/pkgs/build-support/cc-wrapper/ld-wrapper.sh b/pkgs/build-support/cc-wrapper/ld-wrapper.sh index 999959c8227b..44d9a047936a 100644 --- a/pkgs/build-support/cc-wrapper/ld-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/ld-wrapper.sh @@ -1,7 +1,7 @@ #! @shell@ -e path_backup="$PATH" -if [ -n "@coreutils@" ]; then - PATH="@coreutils@/bin" +if [ -n "@coreutils_bin@" ]; then + PATH="@coreutils_bin@/bin" fi if [ -n "$NIX_LD_WRAPPER_START_HOOK" ]; then diff --git a/pkgs/build-support/cc-wrapper/setup-hook.sh b/pkgs/build-support/cc-wrapper/setup-hook.sh index 35620483d2bc..f4f7ab181d3e 100644 --- a/pkgs/build-support/cc-wrapper/setup-hook.sh +++ b/pkgs/build-support/cc-wrapper/setup-hook.sh @@ -22,20 +22,20 @@ envHooks+=(addCVars) # Note: these come *after* $out in the PATH (see setup.sh). -if [ -n "@binutils@" ]; then - addToSearchPath _PATH @binutils@/bin -fi - if [ -n "@cc@" ]; then addToSearchPath _PATH @cc@/bin fi -if [ -n "@libc@" ]; then - addToSearchPath _PATH @libc@/bin +if [ -n "@binutils_bin@" ]; then + addToSearchPath _PATH @binutils_bin@/bin +fi + +if [ -n "@libc_bin@" ]; then + addToSearchPath _PATH @libc_bin@/bin fi -if [ -n "@coreutils@" ]; then - addToSearchPath _PATH @coreutils@/bin +if [ -n "@coreutils_bin@" ]; then + addToSearchPath _PATH @coreutils_bin@/bin fi if [ -z "$crossConfig" ]; then |