diff options
Diffstat (limited to 'nixpkgs/pkgs/build-support/cc-wrapper/cc-wrapper.sh')
-rw-r--r-- | nixpkgs/pkgs/build-support/cc-wrapper/cc-wrapper.sh | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/nixpkgs/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/nixpkgs/pkgs/build-support/cc-wrapper/cc-wrapper.sh index ba3dfc96f5c..7e734f57773 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_@infixSalt@_FLAGS_SET:-}" ]; then - source @bintools@/nix-support/add-flags.sh -fi - -# Put this one second so libc ldflags take priority. -if [ -z "${NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; 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,9 +103,18 @@ 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_@infixSalt@_ENFORCE_NO_NATIVE" = 1 ]; then +if [ "$NIX_ENFORCE_NO_NATIVE_@suffixSalt@" = 1 ]; then rest=() # Old bash empty array hack for p in ${params+"${params[@]}"}; do @@ -129,36 +130,36 @@ fi if [[ "$isCpp" = 1 ]]; then if [[ "$cppInclude" = 1 ]]; then - NIX_@infixSalt@_CFLAGS_COMPILE+=" ${NIX_@infixSalt@_CXXSTDLIB_COMPILE:-@default_cxx_stdlib_compile@}" + NIX_CFLAGS_COMPILE_@suffixSalt@+=" $NIX_CXXSTDLIB_COMPILE_@suffixSalt@" fi - NIX_@infixSalt@_CFLAGS_LINK+=" $NIX_@infixSalt@_CXXSTDLIB_LINK" + NIX_CFLAGS_LINK_@suffixSalt@+=" $NIX_CXXSTDLIB_LINK_@suffixSalt@" fi source @out@/nix-support/add-hardening.sh # Add the flags for the C compiler proper. -extraAfter=($NIX_@infixSalt@_CFLAGS_COMPILE) -extraBefore=(${hardeningCFlags[@]+"${hardeningCFlags[@]}"} $NIX_@infixSalt@_CFLAGS_COMPILE_BEFORE) +extraAfter=($NIX_CFLAGS_COMPILE_@suffixSalt@) +extraBefore=(${hardeningCFlags[@]+"${hardeningCFlags[@]}"} $NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@) if [ "$dontLink" != 1 ]; then # Add the flags that should only be passed to the compiler when # linking. - extraAfter+=($NIX_@infixSalt@_CFLAGS_LINK) + extraAfter+=($NIX_CFLAGS_LINK_@suffixSalt@) # Add the flags that should be passed to the linker (and prevent - # `ld-wrapper' from adding NIX_@infixSalt@_LDFLAGS again). - for i in $NIX_@infixSalt@_LDFLAGS_BEFORE; do + # `ld-wrapper' from adding NIX_LDFLAGS_@suffixSalt@ again). + for i in $NIX_LDFLAGS_BEFORE_@suffixSalt@; do extraBefore+=("-Wl,$i") done - for i in $NIX_@infixSalt@_LDFLAGS; do + for i in $NIX_LDFLAGS_@suffixSalt@; do if [ "${i:0:3}" = -L/ ]; then extraAfter+=("$i") else extraAfter+=("-Wl,$i") fi done - export NIX_@infixSalt@_LDFLAGS_SET=1 + export NIX_LDFLAGS_SET_@suffixSalt@=1 fi # As a very special hack, if the arguments are just `-v', then don't |