diff options
author | Jörg Thalheim <joerg@thalheim.io> | 2020-07-01 21:55:06 +0100 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2020-11-27 13:27:32 +0000 |
commit | a8f71ebd898b2dcbd4c66d7a7bc7e6e5df563f58 (patch) | |
tree | fd595a79aef4e2890cb85349e510d83c8d9b37ed /nixpkgs/pkgs/build-support/cc-wrapper | |
parent | 9813779f5440de04f3074b388c02334faaeb0b94 (diff) | |
download | nixlib-a8f71ebd898b2dcbd4c66d7a7bc7e6e5df563f58.tar nixlib-a8f71ebd898b2dcbd4c66d7a7bc7e6e5df563f58.tar.gz nixlib-a8f71ebd898b2dcbd4c66d7a7bc7e6e5df563f58.tar.bz2 nixlib-a8f71ebd898b2dcbd4c66d7a7bc7e6e5df563f58.tar.lz nixlib-a8f71ebd898b2dcbd4c66d7a7bc7e6e5df563f58.tar.xz nixlib-a8f71ebd898b2dcbd4c66d7a7bc7e6e5df563f58.tar.zst nixlib-a8f71ebd898b2dcbd4c66d7a7bc7e6e5df563f58.zip |
stdenv: make -nostdinc work as intended
Right now we add glibc to search path also -nostdinc was provided, which breaks projects providing their own gcc. (cherry picked from commit 96092dc93640b8ad6520a8bae6f78d62eaba0ec2)
Diffstat (limited to 'nixpkgs/pkgs/build-support/cc-wrapper')
-rw-r--r-- | nixpkgs/pkgs/build-support/cc-wrapper/add-flags.sh | 6 | ||||
-rw-r--r-- | nixpkgs/pkgs/build-support/cc-wrapper/cc-wrapper.sh | 21 | ||||
-rw-r--r-- | nixpkgs/pkgs/build-support/cc-wrapper/default.nix | 4 |
3 files changed, 18 insertions, 13 deletions
diff --git a/nixpkgs/pkgs/build-support/cc-wrapper/add-flags.sh b/nixpkgs/pkgs/build-support/cc-wrapper/add-flags.sh index 04be3f408ee1..94589131b70e 100644 --- a/nixpkgs/pkgs/build-support/cc-wrapper/add-flags.sh +++ b/nixpkgs/pkgs/build-support/cc-wrapper/add-flags.sh @@ -33,10 +33,14 @@ NIX_CFLAGS_COMPILE_@suffixSalt@="-B@out@/bin/ $NIX_CFLAGS_COMPILE_@suffixSalt@" # Export and assign separately in order that a failing $(..) will fail # the script. -if [ -e @out@/nix-support/libc-cflags ]; then +if [[ "$cInclude" = 1 ]] && [ -e @out@/nix-support/libc-cflags ]; then NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@" fi +if [ -e @out@/nix-support/libc-crt1-cflags ]; then + NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/libc-crt1-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@" +fi + if [ -e @out@/nix-support/libcxx-cxxflags ]; then NIX_CXXSTDLIB_COMPILE_@suffixSalt@+=" $(< @out@/nix-support/libcxx-cxxflags)" fi diff --git a/nixpkgs/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/nixpkgs/pkgs/build-support/cc-wrapper/cc-wrapper.sh index 3f9f099f3bc1..7e734f57773e 100644 --- a/nixpkgs/pkgs/build-support/cc-wrapper/cc-wrapper.sh +++ b/nixpkgs/pkgs/build-support/cc-wrapper/cc-wrapper.sh @@ -17,16 +17,6 @@ fi source @out@/nix-support/utils.bash -# Flirting with a layer violation here. -if [ -z "${NIX_BINTOOLS_WRAPPER_FLAGS_SET_@suffixSalt@:-}" ]; then - source @bintools@/nix-support/add-flags.sh -fi - -# Put this one second so libc ldflags take priority. -if [ -z "${NIX_CC_WRAPPER_FLAGS_SET_@suffixSalt@:-}" ]; then - source @out@/nix-support/add-flags.sh -fi - # Parse command line options and set several variables. # For instance, figure out if linker flags should be passed. @@ -37,6 +27,7 @@ cc1=0 # shellcheck disable=SC2193 [[ "@prog@" = *++ ]] && isCpp=1 || isCpp=0 cppInclude=1 +cInclude=1 expandResponseParams "$@" declare -i n=0 @@ -63,6 +54,7 @@ while (( "$n" < "$nParams" )); do elif [ "$p" = -nostdlib ]; then isCpp=-1 elif [ "$p" = -nostdinc ]; then + cInclude=0 cppInclude=0 elif [ "$p" = -nostdinc++ ]; then cppInclude=0 @@ -111,6 +103,15 @@ if [[ "${NIX_ENFORCE_PURITY:-}" = 1 && -n "$NIX_STORE" ]]; then params=(${rest+"${rest[@]}"}) fi +# Flirting with a layer violation here. +if [ -z "${NIX_BINTOOLS_WRAPPER_FLAGS_SET_@suffixSalt@:-}" ]; then + source @bintools@/nix-support/add-flags.sh +fi + +# Put this one second so libc ldflags take priority. +if [ -z "${NIX_CC_WRAPPER_FLAGS_SET_@suffixSalt@:-}" ]; then + source @out@/nix-support/add-flags.sh +fi # Clear march/mtune=native -- they bring impurity. if [ "$NIX_ENFORCE_NO_NATIVE_@suffixSalt@" = 1 ]; then diff --git a/nixpkgs/pkgs/build-support/cc-wrapper/default.nix b/nixpkgs/pkgs/build-support/cc-wrapper/default.nix index 1fef3c459086..c2a06219f1d3 100644 --- a/nixpkgs/pkgs/build-support/cc-wrapper/default.nix +++ b/nixpkgs/pkgs/build-support/cc-wrapper/default.nix @@ -287,7 +287,7 @@ stdenv.mkDerivation { + optionalString (libc != null) ('' touch "$out/nix-support/libc-cflags" touch "$out/nix-support/libc-ldflags" - echo "-B${libc_lib}${libc.libdir or "/lib/"}" >> $out/nix-support/libc-cflags + echo "-B${libc_lib}${libc.libdir or "/lib/"}" >> $out/nix-support/libc-crt1-cflags '' + optionalString (!(cc.langD or false)) '' echo "-idirafter ${libc_dev}${libc.incdir or "/include"}" >> $out/nix-support/libc-cflags '' + optionalString (isGNU && (!(cc.langD or false))) '' @@ -429,7 +429,7 @@ stdenv.mkDerivation { + optionalString (libc != null && targetPlatform.isAvr) '' for isa in avr5 avr3 avr4 avr6 avr25 avr31 avr35 avr51 avrxmega2 avrxmega4 avrxmega5 avrxmega6 avrxmega7 tiny-stack; do - echo "-B${getLib libc}/avr/lib/$isa" >> $out/nix-support/libc-cflags + echo "-B${getLib libc}/avr/lib/$isa" >> $out/nix-support/libc-crt1-cflags done '' |