{bintools,cc}-wrapper: use a fallback SDK when `DEVELOPER_DIR` is not set

It is unusual to invoke a wrapped compiler without setting
`DEVELOPER_DIR`, but it can happen when a user adds a compiler to their
installed packages or when a package intentionally invokes the compiler
without an environment (such as the GHC binary packages).

+10 -2
+1 -1
pkgs/build-support/bintools-wrapper/add-darwin-ldflags-before.sh
··· 84 85 # Allow wrapped bintools to do something useful when no `DEVELOPER_DIR` is set, which can happen when 86 # the compiler is run outside of a stdenv or intentionally in an environment with no environment variables set. 87 - DEVELOPER_DIR=${DEVELOPER_DIR_@suffixSalt@} 88 89 # Darwin looks for frameworks in the SDK located at `DEVELOPER_DIR`. 90 extraBefore+=("-F$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks")
··· 84 85 # Allow wrapped bintools to do something useful when no `DEVELOPER_DIR` is set, which can happen when 86 # the compiler is run outside of a stdenv or intentionally in an environment with no environment variables set. 87 + DEVELOPER_DIR=${DEVELOPER_DIR_@suffixSalt@:-@fallback_sdk@} 88 89 # Darwin looks for frameworks in the SDK located at `DEVELOPER_DIR`. 90 extraBefore+=("-F$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks")
+4
pkgs/build-support/bintools-wrapper/default.nix
··· 10 , stdenvNoCC 11 , runtimeShell 12 , bintools ? null, libc ? null, coreutils ? null, gnugrep ? null 13 , netbsd ? null 14 , sharedLibraryLoader ? 15 if libc == null then ··· 412 inherit dynamicLinker targetPrefix suffixSalt coreutils_bin; 413 inherit bintools_bin libc_bin libc_dev libc_lib; 414 default_hardening_flags_str = builtins.toString defaultHardeningFlags; 415 }; 416 417 meta =
··· 10 , stdenvNoCC 11 , runtimeShell 12 , bintools ? null, libc ? null, coreutils ? null, gnugrep ? null 13 + , apple-sdk ? null 14 , netbsd ? null 15 , sharedLibraryLoader ? 16 if libc == null then ··· 413 inherit dynamicLinker targetPrefix suffixSalt coreutils_bin; 414 inherit bintools_bin libc_bin libc_dev libc_lib; 415 default_hardening_flags_str = builtins.toString defaultHardeningFlags; 416 + } // lib.optionalAttrs (apple-sdk != null && stdenvNoCC.targetPlatform.isDarwin) { 417 + # Wrapped compilers should do something useful even when no SDK is provided at `DEVELOPER_DIR`. 418 + fallback_sdk = apple-sdk.__spliced.buildTarget or apple-sdk; 419 }; 420 421 meta =
+1 -1
pkgs/build-support/cc-wrapper/add-flags.sh
··· 90 91 # Allow wrapped compilers to do something useful when no `DEVELOPER_DIR` is set, which can happen when 92 # the compiler is run outside of a stdenv or intentionally in an environment with no environment variables set. 93 - DEVELOPER_DIR=${DEVELOPER_DIR_@suffixSalt@} 94 95 # xcbuild needs `SDKROOT` to be the name of the SDK, which it sets in its own wrapper, 96 # but compilers expect it to point to the absolute path.
··· 90 91 # Allow wrapped compilers to do something useful when no `DEVELOPER_DIR` is set, which can happen when 92 # the compiler is run outside of a stdenv or intentionally in an environment with no environment variables set. 93 + DEVELOPER_DIR=${DEVELOPER_DIR_@suffixSalt@:-@fallback_sdk@} 94 95 # xcbuild needs `SDKROOT` to be the name of the SDK, which it sets in its own wrapper, 96 # but compilers expect it to point to the absolute path.
+4
pkgs/build-support/cc-wrapper/default.nix
··· 10 , stdenvNoCC 11 , runtimeShell 12 , cc ? null, libc ? null, bintools, coreutils ? null 13 , zlib ? null 14 , nativeTools, noLibc ? false, nativeLibc, nativePrefix ? "" 15 , propagateDoc ? cc != null && cc ? man ··· 749 inherit libc_bin libc_dev libc_lib; 750 inherit darwinPlatformForCC darwinMinVersion darwinMinVersionVariable; 751 default_hardening_flags_str = builtins.toString defaultHardeningFlags; 752 }; 753 754 meta =
··· 10 , stdenvNoCC 11 , runtimeShell 12 , cc ? null, libc ? null, bintools, coreutils ? null 13 + , apple-sdk ? null 14 , zlib ? null 15 , nativeTools, noLibc ? false, nativeLibc, nativePrefix ? "" 16 , propagateDoc ? cc != null && cc ? man ··· 750 inherit libc_bin libc_dev libc_lib; 751 inherit darwinPlatformForCC darwinMinVersion darwinMinVersionVariable; 752 default_hardening_flags_str = builtins.toString defaultHardeningFlags; 753 + } // lib.optionalAttrs (apple-sdk != null && stdenvNoCC.targetPlatform.isDarwin) { 754 + # Wrapped compilers should do something useful even when no SDK is provided at `DEVELOPER_DIR`. 755 + fallback_sdk = apple-sdk.__spliced.buildTarget or apple-sdk; 756 }; 757 758 meta =