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.
This commit is contained in:
Jörg Thalheim
2020-07-23 08:39:46 +01:00
parent 434a0111f6
commit 96092dc936
10 changed files with 41 additions and 17 deletions
+11 -10
View File
@@ -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