treewide: fixes to allow x64 darwin to default to sdk 11

update code to not assume that x64 darwin must use sdk 10.12. After this
change it's possible to build a sdk 11 stdenv on darwin x64
This commit is contained in:
Reno Dakota 2024-06-30 23:42:02 +00:00
parent c00f20377b
commit 3cb23cec23
No known key found for this signature in database
8 changed files with 1508 additions and 15 deletions

View file

@ -51,7 +51,7 @@ let
};
mkCc = cc:
if stdenv.isAarch64 then cc
if lib.versionAtLeast stdenv.hostPlatform.darwinSdkVersion "11" then cc
else
cc.override {
bintools = stdenv.cc.bintools.override { libc = packages.Libsystem; };
@ -59,7 +59,7 @@ let
};
mkStdenv = stdenv:
if stdenv.isAarch64 then stdenv
if lib.versionAtLeast stdenv.hostPlatform.darwinSdkVersion "11" then stdenv
else
let
darwinMinVersion = "10.12";

View file

@ -1,6 +1,10 @@
{ lib, stdenv, fetchurl, fetchFromGitHub, pkgs }:
let
isSdk10_12 = stdenv.hostPlatform.darwinSdkVersion == "10.12";
# This attrset can in theory be computed automatically, but for that to work nicely we need
# import-from-derivation to work properly. Currently it's rather ugly when we try to bootstrap
# a stdenv out of something like this. With some care we can probably get rid of this, but for
@ -271,10 +275,10 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
Libinfo = applePackage "Libinfo" "osx-10.11.6" "sha256-6F7wiwerv4nz/xXHtp1qCHSaFzZgzcRN+jbmXA5oWOQ=" {};
Libm = applePackage "Libm" "osx-10.7.4" "sha256-KjMETfT4qJm0m0Ux/F6Rq8bI4Q4UVnFx6IKbKxXd+Es=" {};
Libnotify = applePackage "Libnotify" "osx-10.12.6" "sha256-6wvMBxAUfiYcQtmlfYCj1d3kFmFM/jdboTd7hRvi3e4=" {};
libmalloc = if stdenv.isx86_64 then
libmalloc = if isSdk10_12 then
applePackage "libmalloc" "osx-10.12.6" "sha256-brfG4GEF2yZipKdhlPq6DhT2z5hKYSb2MAmffaikdO4=" {}
else macosPackages_11_0_1.libmalloc;
libplatform = if stdenv.isx86_64 then
libplatform = if isSdk10_12 then
applePackage "libplatform" "osx-10.12.6" "sha256-6McMTjw55xtnCsFI3AB1osRagnuB5pSTqeMKD3gpGtM=" {}
else macosPackages_11_0_1.libplatform;
libpthread = applePackage "libpthread" "osx-10.12.6" "sha256-QvJ9PERmrCWBiDmOWrLvQUKZ4JxHuh8gS5nlZKDLqE8=" {};
@ -286,7 +290,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
objc4 = applePackage "objc4" "osx-10.12.6" "sha256-ZsxRpdsfv3Dxs7yBBCkjbKXKR6aXwkEpxc1XYXz7ueM=" {};
ppp = applePackage "ppp" "osx-10.12.6" "sha256-M1zoEjjeKIDUEP6ACbpUJk3OXjobw4g/qzUmxGdX1J0=" {};
removefile = applePackage "removefile" "osx-10.12.6" "sha256-UpNk27kGXnZss1ZXWVJU9jLz/NW63ZAZEDLhyCYoi9M=" {};
xnu = if stdenv.isx86_64 then
xnu = if isSdk10_12 then
applePackage "xnu" "osx-10.12.6" "sha256-C8TPQlUT3RbzAy8YnZPNtr70hpaVG9Llv0h42s3NENI=" {}
else macosPackages_11_0_1.xnu;
hfs = applePackage "hfs" "osx-10.12.6" "sha256-eGi18HQFJrU5UHoBOE0LqO5gQ0xOf8+OJuAWQljfKE4=" {};
@ -297,7 +301,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
diskdev_cmds = applePackage "diskdev_cmds" "osx-10.11.6" "sha256-VX+hcZ7JhOA8EhwLloPlM3Yx79RXp9OYHV9Mi10uw3Q=" {
macosPackages_11_0_1 = macosPackages_11_0_1;
};
network_cmds = if stdenv.isx86_64 then
network_cmds = if isSdk10_12 then
applePackage "network_cmds" "osx-10.11.6" "sha256-I89CLIswGheewOjiNZwQTgWvWbhm0qtB5+KUqzxnQ5M=" {}
else macosPackages_11_0_1.network_cmds;
file_cmds = applePackage "file_cmds" "osx-10.11.6" "sha256-JYy6HwmultKeZtLfaysbsyLoWg+OaTh7eJu54JkJC0Q=" {};

View file

@ -1,4 +1,4 @@
{ appleDerivation', lib, stdenv, stdenvNoCC, buildPackages
{ appleDerivation', lib, stdenv, stdenvNoCC, buildPackages, pkgsBuildBuild
, bootstrap_cmds, bison, flex
, gnum4, unifdef, perl, python3
, headersOnly ? true
@ -12,7 +12,7 @@ appleDerivation' (if headersOnly then stdenvNoCC else stdenv) (
nativeBuildInputs = [ bootstrap_cmds bison flex gnum4 unifdef perl python3 ];
patches = lib.optionals stdenv.isx86_64 [ ./python3.patch ];
patches = lib.optionals (lib.versionOlder stdenv.hostPlatform.darwinSdkVersion "11") [ ./python3.patch ];
postPatch = ''
substituteInPlace Makefile \
@ -48,7 +48,7 @@ appleDerivation' (if headersOnly then stdenvNoCC else stdenv) (
--replace 'MACHINE_ARCH=armv7' 'MACHINE_ARCH=arm64' # this might break the comments saying 32-bit is required
patchShebangs .
'' + lib.optionalString stdenv.isAarch64 ''
'' + lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinSdkVersion "11") ''
# iig is closed-sourced, we don't have it
# create an empty file to the header instead
# this line becomes: echo "" > $@; echo --header ...
@ -72,7 +72,11 @@ appleDerivation' (if headersOnly then stdenvNoCC else stdenv) (
HOST_FLEX = "flex";
HOST_BISON = "bison";
HOST_GM4 = "m4";
MIGCC = "cc";
# use unwrapped clang to generate headers because wrapper is not compatible with a 32 bit -arch.
# aarch64 should likely do this as well and remove the --replace MACHINE_ARCH above
MIGCC = if stdenv.isx86_64 && lib.versionAtLeast stdenv.hostPlatform.darwinSdkVersion "11"
then "${lib.getBin pkgsBuildBuild.stdenv.cc.cc}/bin/clang"
else "cc";
ARCHS = arch;
ARCH_CONFIGS = arch;
@ -80,7 +84,7 @@ appleDerivation' (if headersOnly then stdenvNoCC else stdenv) (
preBuild = let macosVersion =
"10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 10.10 10.11" +
lib.optionalString stdenv.isAarch64 " 10.12 10.13 10.14 10.15 11.0";
lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinSdkVersion "11") " 10.12 10.13 10.14 10.15 11.0";
in ''
# This is a bit of a hack...
mkdir -p sdk/usr/local/libexec
@ -150,7 +154,7 @@ appleDerivation' (if headersOnly then stdenvNoCC else stdenv) (
mv $out/Library/Frameworks/IOKit.framework $out/Library/PrivateFrameworks
'';
appleHeaders = builtins.readFile (./. + "/headers-${arch}.txt");
appleHeaders = builtins.readFile (./. + "/headers-${stdenv.hostPlatform.darwinSdkVersion}-${arch}.txt");
} // lib.optionalAttrs headersOnly {
HOST_CODESIGN = "echo";
HOST_CODESIGN_ALLOCATE = "echo";

File diff suppressed because it is too large Load diff

View file

@ -25,7 +25,7 @@ assert crossSystem == localSystem;
let
inherit (localSystem) system;
useAppleSDKLibs = localSystem.isAarch64;
useAppleSDKLibs = lib.versionAtLeast localSystem.darwinSdkVersion "11";
commonImpureHostDeps = [
"/bin/sh"

View file

@ -48,11 +48,15 @@ makeScopeWithSplicing' {
};
# Pick an SDK
apple_sdk = if stdenv.hostPlatform.isAarch64 then apple_sdk_11_0 else apple_sdk_10_12;
apple_sdk = {
"10.12" = apple_sdk_10_12;
"11.0" = apple_sdk_11_0;
}.${stdenv.hostPlatform.darwinSdkVersion}
or (throw "Unsupported sdk: ${stdenv.hostPlatform.darwinSdkVersion}");
# Pick the source of libraries: either Apple's open source releases, or the
# SDK.
useAppleSDKLibs = stdenv.hostPlatform.isAarch64;
useAppleSDKLibs = lib.versionAtLeast stdenv.hostPlatform.darwinSdkVersion "11";
selectAttrs = attrs: names:
lib.listToAttrs (lib.concatMap (n: lib.optionals (attrs ? "${n}") [(lib.nameValuePair n attrs."${n}")]) names);