From 54c7a0f42287f63c2db8086a8ad46ac981364378 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Thu, 4 Feb 2021 16:48:08 -0600 Subject: [PATCH] cc-wrapper: -nostdlib does not imply -nostdinc++ The check for including the C++ standard library headers was nested inside the check for linking with the C++ standard library. As a result, the `-nostdlib` flag incorrectly implied `-nostdinc++`, which made it virtually impossible to partially link C++ objects. --- pkgs/build-support/cc-wrapper/cc-wrapper.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh index d08fd24cd2d..b402893100b 100644 --- a/pkgs/build-support/cc-wrapper/cc-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh @@ -132,12 +132,13 @@ if [ "$NIX_ENFORCE_NO_NATIVE_@suffixSalt@" = 1 ]; then fi if [[ "$isCpp" = 1 ]]; then - if [[ "$cppInclude" = 1 ]]; then - NIX_CFLAGS_COMPILE_@suffixSalt@+=" $NIX_CXXSTDLIB_COMPILE_@suffixSalt@" - fi NIX_CFLAGS_LINK_@suffixSalt@+=" $NIX_CXXSTDLIB_LINK_@suffixSalt@" fi +if [[ "$cppInclude" = 1 ]]; then + NIX_CFLAGS_COMPILE_@suffixSalt@+=" $NIX_CXXSTDLIB_COMPILE_@suffixSalt@" +fi + source @out@/nix-support/add-hardening.sh # Add the flags for the C compiler proper.