summaryrefslogtreecommitdiff
path: root/pkgs/build-support/cc-wrapper
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support/cc-wrapper')
-rw-r--r--pkgs/build-support/cc-wrapper/cc-wrapper.sh28
-rw-r--r--pkgs/build-support/cc-wrapper/default.nix4
2 files changed, 17 insertions, 15 deletions
diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh
index b402893100b0..2e62aef46048 100644
--- a/pkgs/build-support/cc-wrapper/cc-wrapper.sh
+++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh
@@ -25,8 +25,9 @@ dontLink=0
nonFlagArgs=0
cc1=0
# shellcheck disable=SC2193
-[[ "@prog@" = *++ ]] && isCpp=1 || isCpp=0
-cppInclude=1
+[[ "@prog@" = *++ ]] && isCxx=1 || isCxx=0
+cxxInclude=1
+cxxLibrary=1
cInclude=1
setDynamicLinker=1
@@ -50,15 +51,15 @@ while (( "$n" < "$nParams" )); do
dontLink=1
elif [[ "$p" = -x && "$p2" = *-header ]]; then
dontLink=1
- elif [[ "$p" = -x && "$p2" = c++* && "$isCpp" = 0 ]]; then
- isCpp=1
+ elif [[ "$p" = -x && "$p2" = c++* && "$isCxx" = 0 ]]; then
+ isCxx=1
elif [ "$p" = -nostdlib ]; then
- isCpp=-1
+ cxxLibrary=0
elif [ "$p" = -nostdinc ]; then
cInclude=0
- cppInclude=0
+ cxxInclude=0
elif [ "$p" = -nostdinc++ ]; then
- cppInclude=0
+ cxxInclude=0
elif [[ "$p" = -static || "$p" = -static-pie ]]; then
setDynamicLinker=0
elif [[ "$p" != -?* ]]; then
@@ -131,12 +132,13 @@ if [ "$NIX_ENFORCE_NO_NATIVE_@suffixSalt@" = 1 ]; then
params=(${rest+"${rest[@]}"})
fi
-if [[ "$isCpp" = 1 ]]; then
- NIX_CFLAGS_LINK_@suffixSalt@+=" $NIX_CXXSTDLIB_LINK_@suffixSalt@"
-fi
-
-if [[ "$cppInclude" = 1 ]]; then
- NIX_CFLAGS_COMPILE_@suffixSalt@+=" $NIX_CXXSTDLIB_COMPILE_@suffixSalt@"
+if [[ "$isCxx" = 1 ]]; then
+ if [[ "$cxxInclude" = 1 ]]; then
+ NIX_CFLAGS_COMPILE_@suffixSalt@+=" $NIX_CXXSTDLIB_COMPILE_@suffixSalt@"
+ fi
+ if [[ "$cxxLibrary" = 1 ]]; then
+ NIX_CFLAGS_LINK_@suffixSalt@+=" $NIX_CXXSTDLIB_LINK_@suffixSalt@"
+ fi
fi
source @out@/nix-support/add-hardening.sh
diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix
index 14317cbe4cc5..36a98a180b3e 100644
--- a/pkgs/build-support/cc-wrapper/default.nix
+++ b/pkgs/build-support/cc-wrapper/default.nix
@@ -370,7 +370,7 @@ stdenv.mkDerivation {
done
''
+ optionalString (libcxx.isLLVM or false) (''
- echo "-isystem ${libcxx}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags
+ echo "-isystem ${lib.getDev libcxx}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags
echo "-stdlib=libc++" >> $out/nix-support/libcxx-ldflags
'' + lib.optionalString stdenv.targetPlatform.isLinux ''
echo "-lc++abi" >> $out/nix-support/libcxx-ldflags
@@ -404,7 +404,7 @@ stdenv.mkDerivation {
echo "$ccLDFlags" >> $out/nix-support/cc-ldflags
echo "$ccCFlags" >> $out/nix-support/cc-cflags
'' + optionalString (targetPlatform.isDarwin && (libcxx != null) && (cc.isClang or false)) ''
- echo " -L${libcxx}/lib" >> $out/nix-support/cc-ldflags
+ echo " -L${lib.getLib libcxx}/lib" >> $out/nix-support/cc-ldflags
''
##