From 11b744b59c09192c87b0c3f21b32036d7cf0bbf2 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sun, 2 May 2021 14:07:00 -0400 Subject: [PATCH] cc-wrapper.sh: make -nostdlib disable the standard C++ library, but not its includes Should be the correct fix for #111970 --- pkgs/build-support/cc-wrapper/cc-wrapper.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh index 5729fdc75e0..2e62aef4604 100644 --- a/pkgs/build-support/cc-wrapper/cc-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh @@ -27,6 +27,7 @@ cc1=0 # shellcheck disable=SC2193 [[ "@prog@" = *++ ]] && isCxx=1 || isCxx=0 cxxInclude=1 +cxxLibrary=1 cInclude=1 setDynamicLinker=1 @@ -53,7 +54,7 @@ while (( "$n" < "$nParams" )); do elif [[ "$p" = -x && "$p2" = c++* && "$isCxx" = 0 ]]; then isCxx=1 elif [ "$p" = -nostdlib ]; then - isCxx=-1 + cxxLibrary=0 elif [ "$p" = -nostdinc ]; then cInclude=0 cxxInclude=0 @@ -135,7 +136,9 @@ if [[ "$isCxx" = 1 ]]; then if [[ "$cxxInclude" = 1 ]]; then NIX_CFLAGS_COMPILE_@suffixSalt@+=" $NIX_CXXSTDLIB_COMPILE_@suffixSalt@" fi - NIX_CFLAGS_LINK_@suffixSalt@+=" $NIX_CXXSTDLIB_LINK_@suffixSalt@" + if [[ "$cxxLibrary" = 1 ]]; then + NIX_CFLAGS_LINK_@suffixSalt@+=" $NIX_CXXSTDLIB_LINK_@suffixSalt@" + fi fi source @out@/nix-support/add-hardening.sh