cc-wrapper, bintools-wrapper: support MACOSX_DEPLOYMENT_TARGET with roles
In a typical build environment the toolchain will use the value of the MACOSX_DEPLOYMENT_TARGET environment variable to determine the version of macOS to support. When cross compiling there are two distinct toolchains, but they will look at this single environment variable. To avoid contamination, we always set the equivalent command line flag which effectively disables the toolchain's internal handling. Prior to this change, the MACOSX_DEPLOYMENT_TARGET variable was ignored, and the toolchains always used the Nix platform definition (`darwinMinVersion`) unless overridden with command line arguments. This change restores support for MACOSX_DEPLOYMENT_TARGET, and adds nix-specific MACOSX_DEPLOYMENT_TARGET_FOR_BUILD and MACOSX_DEPLOYMENT_TARGET_FOR_TARGET for cross compilation.
This commit is contained in:
@@ -100,6 +100,15 @@ let
|
||||
else
|
||||
false;
|
||||
|
||||
|
||||
darwinPlatformForCC = optionalString stdenv.targetPlatform.isDarwin (
|
||||
if (targetPlatform.darwinPlatform == "macos" && isGNU) then "macosx"
|
||||
else targetPlatform.darwinPlatform
|
||||
);
|
||||
|
||||
darwinMinVersion = optionalString stdenv.targetPlatform.isDarwin (
|
||||
stdenv.targetPlatform.darwinMinVersion
|
||||
);
|
||||
in
|
||||
|
||||
# Ensure bintools matches
|
||||
@@ -122,6 +131,7 @@ stdenv.mkDerivation {
|
||||
gnugrep_bin = if nativeTools then "" else gnugrep;
|
||||
|
||||
inherit targetPrefix suffixSalt;
|
||||
inherit darwinPlatformForCC darwinMinVersion;
|
||||
|
||||
outputs = [ "out" ] ++ optionals propagateDoc [ "man" "info" ];
|
||||
|
||||
@@ -473,6 +483,10 @@ stdenv.mkDerivation {
|
||||
done
|
||||
''
|
||||
|
||||
+ optionalString stdenv.targetPlatform.isDarwin ''
|
||||
echo "-arch ${targetPlatform.darwinArch}" >> $out/nix-support/cc-cflags
|
||||
''
|
||||
|
||||
# There are a few tools (to name one libstdcxx5) which do not work
|
||||
# well with multi line flags, so make the flags single line again
|
||||
+ ''
|
||||
@@ -485,16 +499,6 @@ stdenv.mkDerivation {
|
||||
substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash
|
||||
''
|
||||
|
||||
+ optionalString stdenv.targetPlatform.isDarwin (
|
||||
let darwinPlatformForCC =
|
||||
if (targetPlatform.darwinPlatform == "macos" && isGNU) then "macosx"
|
||||
else targetPlatform.darwinPlatform;
|
||||
in ''
|
||||
echo "-arch ${targetPlatform.darwinArch}" >> $out/nix-support/cc-cflags
|
||||
echo "-m${darwinPlatformForCC}-version-min=${targetPlatform.darwinMinVersion}" >> $out/nix-support/cc-cflags-before
|
||||
''
|
||||
)
|
||||
|
||||
##
|
||||
## Extra custom steps
|
||||
##
|
||||
|
||||
Reference in New Issue
Block a user