apple-sdk: clean up and improve compatibility with Swift (#445094)

This commit is contained in:
Emily
2025-09-24 18:18:14 +01:00
committed by GitHub
6 changed files with 37 additions and 17 deletions
@@ -42,7 +42,6 @@ in
self: super: {
buildPhase = super.buildPhase or "" + ''
mkdir -p System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/Headers
ln -s A System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/Current
ln -s Versions/Current/Headers System/Library/PrivateFrameworks/CoreSymbolication.framework/Headers
cp '${CoreSymbolication}/include/'*.h System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/Headers
'';
+16 -3
View File
@@ -2,15 +2,28 @@
lib,
stdenvNoCC,
xcodePlatform,
sdkVersion,
}:
let
inherit (lib.generators) toPlist;
Info = {
CFBundleIdentifier = "com.apple.platform.${lib.toLower xcodePlatform}";
Type = "Platform";
Info = rec {
CFBundleIdentifier = "com.apple.platform.${Name}";
DefaultProperties = {
COMPRESS_PNG_FILES = "NO";
DEPLOYMENT_TARGET_SETTING_NAME = stdenvNoCC.hostPlatform.darwinMinVersionVariable;
STRIP_PNG_TEXT = "NO";
};
Description = if stdenvNoCC.hostPlatform.isMacOS then "macOS" else "iOS";
FamilyDisplayName = Description;
FamilyIdentifier = lib.toLower xcodePlatform;
FamilyName = Description;
Identifier = CFBundleIdentifier;
MinimumSDKVersion = stdenvNoCC.hostPlatform.darwinMinVersion;
Name = lib.toLower xcodePlatform;
Type = "Platform";
Version = sdkVersion;
};
# These files are all based off of Xcode spec files found in
@@ -56,16 +56,19 @@ self: super: {
darwin.libsbuf
# Shipped with the SDK only as a library with no headers
(lib.getLib darwin.libutil)
# Required by some SDK headers
cupsHeaders
]
# x86_64-darwin links the object files from Csu when targeting very old releases
++ lib.optionals stdenvNoCC.hostPlatform.isx86_64 [ darwin.Csu ];
# The Darwin module for Swift requires certain headers to be included in the SDK (and not just be propagated).
buildPhase = super.buildPhase or "" + ''
for header in '${lib.getDev libiconv}/include/'* '${lib.getDev ncurses}/include/'*; do
for header in '${lib.getDev libiconv}/include/'* '${lib.getDev ncurses}/include/'* '${cupsHeaders}/include/'*; do
ln -s "$header" "usr/include/$(basename "$header")"
done
'';
# Exported to allow the headers to pass the requisites check in the stdenv bootstrap.
passthru = (super.passthru or { }) // {
cups-headers = cupsHeaders;
};
}
@@ -3,11 +3,12 @@
pkgsBuildHost,
stdenv,
stdenvNoCC,
sdkVersion,
}:
let
plists = import ./plists.nix {
inherit lib stdenvNoCC;
inherit lib stdenvNoCC sdkVersion;
xcodePlatform = if stdenvNoCC.hostPlatform.isMacOS then "MacOSX" else "iPhoneOS";
};
inherit (pkgsBuildHost) darwin cctools xcbuild;
@@ -38,11 +39,15 @@ self: super: {
# Include `libtool` in the toolchain, so `xcrun -find libtool` can find it without requiring `cctools.libtool`
# as a `nativeBuildInput`.
mkdir -p "$toolchainsPath/usr/bin"
ln -s '${cctools.libtool}/bin/${stdenv.cc.targetPrefix}libtool' "$toolchainsPath/usr/bin/libtool"
if [ -e '${cctools.libtool}/bin/${stdenv.cc.targetPrefix}libtool' ]; then
ln -s '${cctools.libtool}/bin/${stdenv.cc.targetPrefix}libtool' "$toolchainsPath/usr/bin/libtool"
fi
# Include additional binutils required by some packages (such as Chromium).
for tool in lipo nm otool size strip; do
ln -s '${darwin.binutils-unwrapped}/bin/${stdenv.cc.targetPrefix}'$tool "$toolchainsPath/usr/bin/$tool"
if [ -e '${darwin.binutils-unwrapped}/bin/${stdenv.cc.targetPrefix}'$tool ]; then
ln -s '${darwin.binutils-unwrapped}/bin/${stdenv.cc.targetPrefix}'$tool "$toolchainsPath/usr/bin/$tool"
fi
done
'';
}
+6 -7
View File
@@ -41,7 +41,7 @@ let
# Avoid infinite recursions by not propagating certain packages, so they can themselves build with the SDK.
++ lib.optionals (!enableBootstrap) [
(callPackage ./common/propagate-inputs.nix { })
(callPackage ./common/propagate-xcrun.nix { })
(callPackage ./common/propagate-xcrun.nix { inherit sdkVersion; })
]
# This has to happen last.
++ [
@@ -58,12 +58,6 @@ stdenvNoCC.mkDerivation (
dontConfigure = true;
# TODO(@connorbaker):
# This is a quick fix unblock builds broken by https://github.com/NixOS/nixpkgs/pull/370750.
# Fails due to a reflexive symlink:
# $out/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/A
dontCheckForBrokenSymlinks = true;
strictDeps = true;
setupHooks = [
@@ -96,6 +90,11 @@ stdenvNoCC.mkDerivation (
ln -s "${sdkName}" "$sdkpath/MacOSX${sdkMajor}.sdk"
ln -s "${sdkName}" "$sdkpath/MacOSX.sdk"
# Swift adds these locations to its search paths. Avoid spurious warnings by making sure they exist.
mkdir -p "$platformPath/Developer/Library/Frameworks"
mkdir -p "$platformPath/Developer/Library/PrivateFrameworks"
mkdir -p "$platformPath/Developer/usr/lib"
runHook postInstall
'';
+1
View File
@@ -1121,6 +1121,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
with prevStage;
[
apple-sdk
apple-sdk.cups-headers
bashNonInteractive
bzip2.bin
bzip2.out