Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treewide: change various flags to allow x64 darwin to default to sdk 11.0 when ready #324155

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkgs/development/compilers/llvm/13/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ in let
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
++ lib.optional (
stdenv.targetPlatform.isDarwin
&& !stdenv.targetPlatform.isAarch64
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
&& lib.versionOlder stdenv.targetPlatform.darwinSdkVersion "11.0"
) ./lldb/cpu_subtype_arm64e_replacement.patch;
};

Expand Down
3 changes: 1 addition & 2 deletions pkgs/development/compilers/llvm/14/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ in let
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
++ lib.optional (
stdenv.targetPlatform.isDarwin
&& !stdenv.targetPlatform.isAarch64
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
&& lib.versionOlder stdenv.targetPlatform.darwinSdkVersion "11.0"
) ./lldb/cpu_subtype_arm64e_replacement.patch;
};

Expand Down
3 changes: 1 addition & 2 deletions pkgs/development/compilers/llvm/15/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ in let
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
++ lib.optional (
stdenv.targetPlatform.isDarwin
&& !stdenv.targetPlatform.isAarch64
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
&& lib.versionOlder stdenv.targetPlatform.darwinSdkVersion "11.0"
) ./lldb/cpu_subtype_arm64e_replacement.patch;
};

Expand Down
3 changes: 1 addition & 2 deletions pkgs/development/compilers/llvm/16/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ in let
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
++ lib.optional (
stdenv.targetPlatform.isDarwin
&& !stdenv.targetPlatform.isAarch64
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
&& lib.versionOlder stdenv.targetPlatform.darwinSdkVersion "11.0"
) ./lldb/cpu_subtype_arm64e_replacement.patch;
};

Expand Down
3 changes: 1 addition & 2 deletions pkgs/development/compilers/llvm/17/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ in let
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
++ lib.optional (
stdenv.targetPlatform.isDarwin
&& !stdenv.targetPlatform.isAarch64
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
&& lib.versionOlder stdenv.targetPlatform.darwinSdkVersion "11.0"
) ./lldb/cpu_subtype_arm64e_replacement.patch;
};

Expand Down
3 changes: 1 addition & 2 deletions pkgs/development/compilers/llvm/18/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ in let
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
++ lib.optional (
stdenv.targetPlatform.isDarwin
&& !stdenv.targetPlatform.isAarch64
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
&& lib.versionOlder stdenv.targetPlatform.darwinSdkVersion "11.0"
) ./lldb/cpu_subtype_arm64e_replacement.patch;
};

Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/llvm/common/lldb.nix
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ stdenv.mkDerivation (rec {
++ lib.optional
(
stdenv.targetPlatform.isDarwin
&& !stdenv.targetPlatform.isAarch64
&& lib.versionOlder stdenv.targetPlatform.darwinSdkVersion "11.0"
&& (lib.versionAtLeast release_version "15")
)
(
Expand Down
3 changes: 1 addition & 2 deletions pkgs/development/compilers/llvm/git/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ in let
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
++ lib.optional (
stdenv.targetPlatform.isDarwin
&& !stdenv.targetPlatform.isAarch64
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
&& lib.versionOlder stdenv.targetPlatform.darwinSdkVersion "11.0"
) ./lldb/cpu_subtype_arm64e_replacement.patch;
};

Expand Down
6 changes: 5 additions & 1 deletion pkgs/development/libraries/webkitgtk/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ stdenv.mkDerivation (finalAttrs: {
] ++ lib.optionals stdenv.isDarwin [
libedit
readline
] ++ lib.optional (stdenv.isDarwin && !stdenv.isAarch64) (
] ++ lib.optional (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinSdkVersion "11.0") (
# this can likely be removed as:
# "libproc.h is included in the 10.12 SDK Libsystem and should be identical to this one."
# but the package is marked broken on darwin so unable to test

# Pull a header that contains a definition of proc_pid_rusage().
# (We pick just that one because using the other headers from `sdk` is not
# compatible with our C++ standard library. This header is already in
Expand Down
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: 10 additions & 6 deletions pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this shouldn't be conditional? Even the 10.12 script relies on the 32-bit arch compiler. Or does the wrapper only force a 64-bit architecture when using the 11 SDK?

then "${lib.getBin pkgsBuildBuild.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,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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we ever want to split on more than the architecture? I'd say the goal is to unsplit these header checks eventually. If they're even still useful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way to do these in the future probably requires us to inventory the upstream SDKs and compare our headers to those in the SDK. Otherwise, using headers + stubs with more than a few SDKs is going to get painful quickly.

(Or I wouldn’t worry too much about the current situation because it’s going to need to change.)

} // lib.optionalAttrs headersOnly {
HOST_CODESIGN = "echo";
HOST_CODESIGN_ALLOCATE = "echo";
Expand Down
Loading