Skip to content

Commit

Permalink
treewide: fixes to allow x64 darwin to default to sdk 11
Browse files Browse the repository at this point in the history
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
  • Loading branch information
paparodeo committed Jul 2, 2024
1 parent c00f203 commit f2d69c1
Show file tree
Hide file tree
Showing 7 changed files with 1,525 additions and 30 deletions.
4 changes: 2 additions & 2 deletions pkgs/os-specific/darwin/apple-sdk-11.0/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ 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; };
libc = packages.Libsystem;
};

mkStdenv = stdenv:
if stdenv.isAarch64 then stdenv
if lib.versionAtLeast stdenv.hostPlatform.darwinSdkVersion "11" then stdenv
else
let
darwinMinVersion = "10.12";
Expand Down
12 changes: 8 additions & 4 deletions pkgs/os-specific/darwin/apple-source-releases/default.nix
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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=" {};
Expand All @@ -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=" {};
Expand All @@ -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=" {};
Expand Down
16 changes: 11 additions & 5 deletions pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 ...
Expand All @@ -72,15 +72,19 @@ 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 buildPackages.stdenv.cc.cc}/bin/clang"
else "cc";
ARCHS = arch;
ARCH_CONFIGS = arch;

env.NIX_CFLAGS_COMPILE = "-Wno-error";

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
Expand Down Expand Up @@ -150,7 +154,9 @@ appleDerivation' (if headersOnly then stdenvNoCC else stdenv) (
mv $out/Library/Frameworks/IOKit.framework $out/Library/PrivateFrameworks
'';

appleHeaders = builtins.readFile (./. + "/headers-${arch}.txt");
appleHeaders = let
name = if stdenv.hostPlatform.darwinSdkVersion == "10.12" then "headers-10.12-${arch}.txt" else "headers-${arch}.txt";
in builtins.readFile (./. + "/${name}");
} // lib.optionalAttrs headersOnly {
HOST_CODESIGN = "echo";
HOST_CODESIGN_ALLOCATE = "echo";
Expand Down
Loading

0 comments on commit f2d69c1

Please sign in to comment.