diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh index 1c60beb9bf57b..42472f16f1291 100644 --- a/pkgs/build-support/cc-wrapper/cc-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh @@ -146,6 +146,12 @@ extraBefore=(${hardeningCFlags[@]+"${hardeningCFlags[@]}"} $NIX_CFLAGS_COMPILE_B if [ "$dontLink" != 1 ]; then + # Disable the -dynamic-linker flag if NIX_DYNAMIC_LINKER is the special darwin + # value. -dynamic-linker is not supported on darwin systems. + if [[ "$NIX_DYNAMIC_LINKER_@suffixSalt@" = "darwin" ]]; then + setDynamicLinker=0 + fi + # Add the flags that should only be passed to the compiler when # linking. extraAfter+=($NIX_CFLAGS_LINK_@suffixSalt@) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index ad9d2e1b84166..aad5c0ada8b52 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -62,7 +62,6 @@ let else ""; useGccForLibs = isClang - && libcxx == null && !(stdenv.targetPlatform.useLLVM or false) && !(stdenv.targetPlatform.useAndroidPrebuilt or false) && gccForLibs != null; @@ -154,6 +153,7 @@ stdenv.mkDerivation { local dst="$1" local wrapper="$2" export prog="$3" + export isdarwin="${toString targetPlatform.isDarwin or false}" substituteAll "$wrapper" "$out/bin/$dst" chmod +x "$out/bin/$dst" } diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index f07b1ee73b87a..dd551fd3d4850 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -36,6 +36,7 @@ in rec { export NIX_ENFORCE_NO_NATIVE=''${NIX_ENFORCE_NO_NATIVE-1} export NIX_ENFORCE_PURITY=''${NIX_ENFORCE_PURITY-1} export NIX_IGNORE_LD_THROUGH_GCC=1 + export NIX_DYNAMIC_LINKER="darwin" unset SDKROOT export MACOSX_DEPLOYMENT_TARGET=${macosVersionMin}