Skip to content

Commit

Permalink
darwin: change the SDK pattern, update the SDKs, and update source re…
Browse files Browse the repository at this point in the history
…leases (NixOS#346043)
  • Loading branch information
emilazy authored and nxmatic committed Nov 25, 2024
1 parent d9f46a9 commit f343865
Show file tree
Hide file tree
Showing 29 changed files with 21,140 additions and 1,263 deletions.
59 changes: 6 additions & 53 deletions maintainers/team-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,11 @@ with lib.maintainers;

darwin = {
members = [
emily
reckenrode
toonn
];
githubTeams = [ "darwin-core" ];
scope = "Maintain core platform support and packages for macOS and other Apple platforms.";
githubTeams = [ "darwin-maintainers" ];
scope = "Maintain Darwin compatibility of packages and Darwin-only packages.";
shortName = "Darwin";
enableFeatureFreezePing = true;
};
Expand Down Expand Up @@ -282,11 +281,7 @@ with lib.maintainers;
};

emacs = {
members = [
AndersonTorres
adisbladis
linj
];
members = [ adisbladis ];
scope = "Maintain the Emacs editor and packages.";
shortName = "Emacs";
};
Expand Down Expand Up @@ -449,6 +444,7 @@ with lib.maintainers;
haskell = {
members = [
cdepillabout
expipiplus1
maralorn
ncfavier
sternenseemann
Expand All @@ -464,7 +460,6 @@ with lib.maintainers;
members = [
das_j
conni2461
helsinki-Jo
];
scope = "Group registration for packages maintained by Helsinki Systems";
shortName = "Helsinki Systems employees";
Expand Down Expand Up @@ -497,25 +492,13 @@ with lib.maintainers;
shortName = "Input-Output Global employees";
};

java = {
githubTeams = [ "java" ];
members = [
chayleaf
fliegendewurst
infinidoge
tomodachi94
];
shortName = "Java";
scope = "Maintainers of the Nixpkgs Java ecosystem (JDK, JVM, Java, Gradle, Maven, Ant, and adjacent projects)";
enableFeatureFreezePing = true;
};

jitsi = {
members = [
cleeyv
ryantm
lassulus
yayayayaka
asymmetric
];
scope = "Maintain Jitsi.";
shortName = "Jitsi";
Expand Down Expand Up @@ -765,16 +748,6 @@ with lib.maintainers;
enableFeatureFreezePing = true;
};

ngi = {
members = [
eljamm
fricklerhandwerk
wegank
];
scope = "Maintain NGI-supported software.";
shortName = "NGI";
};

node = {
members = [ winter ];
scope = "Maintain Node.js runtimes and build tooling.";
Expand Down Expand Up @@ -858,14 +831,9 @@ with lib.maintainers;
};

postgres = {
members = [
thoughtpolice
ma27
wolfgangwalther
];
members = [ thoughtpolice ];
scope = "Maintain the PostgreSQL package and plugins along with the NixOS module.";
shortName = "PostgreSQL";
enableFeatureFreezePing = true;
};

python = {
Expand Down Expand Up @@ -985,21 +953,6 @@ with lib.maintainers;
shortName = "Serokell employees";
};

stdenv = {
members = [
artturin
emily
ericson2314
philiptaron
reckenrode
RossComputerGuy
];
scope = "Maintain the standard environment and its surrounding logic.";
shortName = "stdenv";
enableFeatureFreezePing = true;
githubTeams = [ "stdenv" ];
};

steam = {
members = [
atemu
Expand Down
10 changes: 10 additions & 0 deletions pkgs/build-support/bintools-wrapper/add-darwin-ldflags-before.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,13 @@ if [ ! "$havePlatformVersionFlag" ]; then
extraBefore+=(-@darwinPlatform@_version_min "${@darwinMinVersionVariable@_@suffixSalt@:-@darwinMinVersion@}")
fi
fi

mangleVarSingle DEVELOPER_DIR ${role_suffixes[@]+"${role_suffixes[@]}"}

# Allow wrapped bintools to do something useful when no `DEVELOPER_DIR` is set, which can happen when
# the compiler is run outside of a stdenv or intentionally in an environment with no environment variables set.
DEVELOPER_DIR=${DEVELOPER_DIR_@suffixSalt@:-@fallback_sdk@}

# Darwin looks for frameworks in the SDK located at `DEVELOPER_DIR`.
extraBefore+=("-F$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks")
extraBefore+=("-L$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib")
35 changes: 23 additions & 12 deletions pkgs/build-support/bintools-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
, isCCTools ? bintools.isCCTools or false
, expand-response-params
, targetPackages ? {}
, useMacosReexportHack ? false
, wrapGas ? false

# Note: the hardening flags are part of the bintools-wrapper, rather than
Expand Down Expand Up @@ -136,7 +137,6 @@ let
else if targetPlatform.isLoongArch64 then "${sharedLibraryLoader}/lib/ld-linux-loongarch*.so.1"
else if targetPlatform.isDarwin then "/usr/lib/dyld"
else if targetPlatform.isFreeBSD then "${sharedLibraryLoader}/libexec/ld-elf.so.1"
else if targetPlatform.isOpenBSD then "${sharedLibraryLoader}/libexec/ld.so"
else if hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1"
else "";

Expand Down Expand Up @@ -230,9 +230,16 @@ stdenvNoCC.mkDerivation {
fi
done
'' + (if !useMacosReexportHack then ''
if [ -e ''${ld:-$ldPath/${targetPrefix}ld} ]; then
wrap ${targetPrefix}ld ${./ld-wrapper.sh} ''${ld:-$ldPath/${targetPrefix}ld}
fi
'' else ''
ldInner="${targetPrefix}ld-reexport-delegate"
wrap "$ldInner" ${./macos-sierra-reexport-hack.bash} ''${ld:-$ldPath/${targetPrefix}ld}
wrap "${targetPrefix}ld" ${./ld-wrapper.sh} "$out/bin/$ldInner"
unset ldInner
'') + ''
for variant in $ldPath/${targetPrefix}ld.*; do
basename=$(basename "$variant")
Expand Down Expand Up @@ -372,15 +379,24 @@ stdenvNoCC.mkDerivation {
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash
substituteAll ${../wrapper-common/darwin-sdk-setup.bash} $out/nix-support/darwin-sdk-setup.bash
''

###
### Ensure consistent LC_VERSION_MIN_MACOSX
###
+ optionalString targetPlatform.isDarwin ''
substituteAll ${./add-darwin-ldflags-before.sh} $out/nix-support/add-local-ldflags-before.sh
''
+ optionalString targetPlatform.isDarwin (
let
inherit (targetPlatform)
darwinPlatform darwinSdkVersion
darwinMinVersion darwinMinVersionVariable;
in ''
export darwinPlatform=${darwinPlatform}
export darwinMinVersion=${darwinMinVersion}
export darwinSdkVersion=${darwinSdkVersion}
export darwinMinVersionVariable=${darwinMinVersionVariable}
substituteAll ${./add-darwin-ldflags-before.sh} $out/nix-support/add-local-ldflags-before.sh
''
)

##
## Extra custom steps
Expand All @@ -394,17 +410,10 @@ stdenvNoCC.mkDerivation {
# TODO(@sternenseemann): rename env var via stdenv rebuild
shell = (getBin runtimeShell + runtimeShell.shellPath or "");
gnugrep_bin = optionalString (!nativeTools) gnugrep;
rm = if nativeTools then "rm" else lib.getExe' coreutils "rm";
mktemp = if nativeTools then "mktemp" else lib.getExe' coreutils "mktemp";
wrapperName = "BINTOOLS_WRAPPER";
inherit dynamicLinker targetPrefix suffixSalt coreutils_bin;
inherit bintools_bin libc_bin libc_dev libc_lib;
default_hardening_flags_str = builtins.toString defaultHardeningFlags;
} // lib.mapAttrs (_: lib.optionalString targetPlatform.isDarwin) {
# These will become empty strings when not targeting Darwin.
inherit (targetPlatform)
darwinPlatform darwinSdkVersion
darwinMinVersion darwinMinVersionVariable;
} // lib.optionalAttrs (apple-sdk != null && stdenvNoCC.targetPlatform.isDarwin) {
# Wrapped compilers should do something useful even when no SDK is provided at `DEVELOPER_DIR`.
fallback_sdk = apple-sdk.__spliced.buildTarget or apple-sdk;
Expand All @@ -417,5 +426,7 @@ stdenvNoCC.mkDerivation {
attrByPath ["meta" "description"] "System binary utilities" bintools_
+ " (wrapper script)";
priority = 10;
} // optionalAttrs useMacosReexportHack {
platforms = platforms.darwin;
};
}
18 changes: 17 additions & 1 deletion pkgs/build-support/cc-wrapper/add-flags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,28 @@ if [ -e @out@/nix-support/cc-cflags-before ]; then
NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@="$(< @out@/nix-support/cc-cflags-before) $NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@"
fi

# Only add darwin min version flag if a default darwin min version is set,
# Only add darwin min version flag and set up `DEVELOPER_DIR` if a default darwin min version is set,
# which is a signal that we're targetting darwin.
if [ "@darwinMinVersion@" ]; then
mangleVarSingle @darwinMinVersionVariable@ ${role_suffixes[@]+"${role_suffixes[@]}"}

NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@="-m@darwinPlatformForCC@-version-min=${@darwinMinVersionVariable@_@suffixSalt@:-@darwinMinVersion@} $NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@"

# `DEVELOPER_DIR` is used to dynamically locate libSystem (and the SDK frameworks) based on the SDK at that path.
mangleVarSingle DEVELOPER_DIR ${role_suffixes[@]+"${role_suffixes[@]}"}

# Allow wrapped compilers to do something useful when no `DEVELOPER_DIR` is set, which can happen when
# the compiler is run outside of a stdenv or intentionally in an environment with no environment variables set.
DEVELOPER_DIR=${DEVELOPER_DIR_@suffixSalt@:-@fallback_sdk@}

# xcbuild needs `SDKROOT` to be the name of the SDK, which it sets in its own wrapper,
# but compilers expect it to point to the absolute path.
SDKROOT="$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"

# Set up various library paths since compilers may not support (or may have disabled) finding them in the sysroot.
NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@+=" -isysroot $SDKROOT"
NIX_CFLAGS_COMPILE_@suffixSalt@+=" -idirafter $SDKROOT/usr/include"
NIX_CFLAGS_COMPILE_@suffixSalt@+=" -iframework $SDKROOT/System/Library/Frameworks"
fi

# That way forked processes will not extend these environment variables again.
Expand Down
17 changes: 9 additions & 8 deletions pkgs/build-support/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,13 @@ let
if (targetPlatform.darwinPlatform == "macos" && isGNU) then "macosx"
else targetPlatform.darwinPlatform
);

darwinMinVersion = optionalString targetPlatform.isDarwin (
targetPlatform.darwinMinVersion
);

darwinMinVersionVariable = optionalString targetPlatform.isDarwin
targetPlatform.darwinMinVersionVariable;
in

assert includeFortifyHeaders' -> fortify-headers != null;
Expand Down Expand Up @@ -700,7 +707,6 @@ stdenvNoCC.mkDerivation {
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash
substituteAll ${../wrapper-common/darwin-sdk-setup.bash} $out/nix-support/darwin-sdk-setup.bash
''

+ optionalString cc.langAda or false ''
Expand Down Expand Up @@ -733,23 +739,18 @@ stdenvNoCC.mkDerivation {

# for substitution in utils.bash
# TODO(@sternenseemann): invent something cleaner than passing in "" in case of absence
expandResponseParams = lib.optionalString (expand-response-params != "") (lib.getExe expand-response-params);
expandResponseParams = "${expand-response-params}/bin/expand-response-params";
# TODO(@sternenseemann): rename env var via stdenv rebuild
shell = getBin runtimeShell + runtimeShell.shellPath or "";
gnugrep_bin = optionalString (!nativeTools) gnugrep;
rm = if nativeTools then "rm" else lib.getExe' coreutils "rm";
mktemp = if nativeTools then "mktemp" else lib.getExe' coreutils "mktemp";
# stdenv.cc.cc should not be null and we have nothing better for now.
# if the native impure bootstrap is gotten rid of this can become `inherit cc;` again.
cc = optionalString (!nativeTools) cc;
wrapperName = "CC_WRAPPER";
inherit suffixSalt coreutils_bin bintools;
inherit libc_bin libc_dev libc_lib;
inherit darwinPlatformForCC;
inherit darwinPlatformForCC darwinMinVersion darwinMinVersionVariable;
default_hardening_flags_str = builtins.toString defaultHardeningFlags;
} // lib.mapAttrs (_: lib.optionalString targetPlatform.isDarwin) {
# These will become empty strings when not targeting Darwin.
inherit (targetPlatform) darwinMinVersion darwinMinVersionVariable;
} // lib.optionalAttrs (apple-sdk != null && stdenvNoCC.targetPlatform.isDarwin) {
# Wrapped compilers should do something useful even when no SDK is provided at `DEVELOPER_DIR`.
fallback_sdk = apple-sdk.__spliced.buildTarget or apple-sdk;
Expand Down
2 changes: 0 additions & 2 deletions pkgs/by-name/ap/apple-sdk/common/propagate-inputs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ self: super: {
libiconv
darwin.libresolv
darwin.libsbuf
# Shipped with the SDK only as a library with no headers
(lib.getLib darwin.libutil)
# Required by some SDK headers
cupsHeaders
]
Expand Down
Loading

0 comments on commit f343865

Please sign in to comment.