From 53ac93da0a4d63a7e89155ad5231aa75511fd525 Mon Sep 17 00:00:00 2001 From: Emily Date: Tue, 9 Sep 2025 04:11:48 +0100 Subject: [PATCH 01/11] apple-sdk_15: 15.2 -> 15.5 --- .../metadata/apple-oss-lockfile.json | 92 +++++++++---------- .../ap/apple-sdk/metadata/versions.json | 8 +- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/pkgs/by-name/ap/apple-sdk/metadata/apple-oss-lockfile.json b/pkgs/by-name/ap/apple-sdk/metadata/apple-oss-lockfile.json index 5157b58ce3df4..2dc99f12620d5 100644 --- a/pkgs/by-name/ap/apple-sdk/metadata/apple-oss-lockfile.json +++ b/pkgs/by-name/ap/apple-sdk/metadata/apple-oss-lockfile.json @@ -711,14 +711,14 @@ "version": "10063.101.15" } }, - "15.2": { + "15.5": { "CarbonHeaders": { "hash": "sha256-nIPXnLr21yVnpBhx9K5q3l/nPARA6JL/dED08MeyhP8=", "version": "18.1" }, "CommonCrypto": { "hash": "sha256-+qAwL6+s7di9cX/qXtapLkjCFoDuZaSYltRJEG4qekM=", - "version": "600033.60.1" + "version": "600035" }, "IOAudioFamily": { "hash": "sha256-VSk3jvsITJugtL67Qt0m4qJ879i7Fj6B/NGBFVCwpiU=", @@ -757,16 +757,16 @@ "version": "261" }, "IOGraphics": { - "hash": "sha256-Ag37fd3tZJLXLVq1yzHOCWGOYYfwwTkC8hnvNaTEaWg=", - "version": "598" + "hash": "sha256-iysZE42mOKZbFxSZBNspaBTCRKEKK38DFGBxZWQxZxI=", + "version": "599" }, "IOHIDFamily": { - "hash": "sha256-utWAwmn9jss/6fc4flDHXeJR5ZBymO0ZFbDFIFVBnt4=", - "version": "2104.61.1" + "hash": "sha256-gEYPyjXgQ2ABGufCKPjmzMdNRLxhELkCvOURCokyTO4=", + "version": "2115.100.21" }, "IOKitUser": { - "hash": "sha256-vfz/kLZlVyoHKOlrNdNrf2HcUOB6bY+mpbCvEEg2sus=", - "version": "100140.60.14" + "hash": "sha256-p32U+jHfwA/tqnjF4p1BmojghEXK8KxiflW3IHs2iIY=", + "version": "100150.120.2" }, "IONetworkingFamily": { "hash": "sha256-gZ7Dkk4Iu7AV9K2ioqSeJ1W7bTNxv77bmT18iv3ljLg=", @@ -777,28 +777,28 @@ "version": "93" }, "IOStorageFamily": { - "hash": "sha256-tjzvlJYVjSTG7oF3AhHgCASKax1fYjOBAxcsrKh/urY=", - "version": "317.40.2" + "hash": "sha256-/0H0tqWUWkgYigYypucbc7lOCFYDuukwF9fvLEOhwOk=", + "version": "323" }, "IOUSBFamily": { "hash": "sha256-Z0E3TfKP49toYo1Fo9kElRap8CZ+mVDHy5RIexgJTpA=", "version": "630.4.5" }, "Libc": { - "hash": "sha256-/J1Oawa+cMbcAlMlpr6ce32KQQp2lMGnfbRi/2Oc1cY=", - "version": "1669.60.4" + "hash": "sha256-nWDokN0Vr5pUyNGculnDOah9RNgHiWr3S13RSQLmZrc=", + "version": "1698.100.8" }, "Libinfo": { - "hash": "sha256-D7JMCakQVCQ9j2zUHQSGB8zZcHD6azwYY3bsJU0JfEE=", - "version": "592" + "hash": "sha256-UI5mGvzZ6BPafGYD6CrNAJAKjeJLB6urAS2lpB6X/Ec=", + "version": "597" }, "Libm": { "hash": "sha256-p4BndAag9d0XSMYWQ+c4myGv5qXbKx5E1VghudSbpTk=", "version": "2026" }, "Libnotify": { - "hash": "sha256-XwVB4sYXPLAHDuLv8mxAWlC1ia17V4cf73DEJDDm4ck=", - "version": "327.60.1" + "hash": "sha256-GDYMVi1034f9empq0YOuumQp/BDJ7phTb0Zl4KTY9xg=", + "version": "342" }, "Librpcsvc": { "hash": "sha256-UWYdCQ9QsBqwM01bWr+igINAHSdSluB/FrOclC5AjTI=", @@ -813,80 +813,80 @@ "version": "146" }, "Security": { - "hash": "sha256-sRpFQyMk3x4kRthXpqeAnfQ9dE5RMxiSFUiUKRCneck=", - "version": "61439.60.117" + "hash": "sha256-ZOrOOCk+hZbzDilzkihpQfsDpzV3Ul4zy6fpFRWUQHw=", + "version": "61439.120.27" }, "architecture": { "hash": "sha256-PRNUrhzSOrwmxSPkKmV0LV7yEIik65sdkfKdBqcwFhU=", "version": "282" }, "configd": { - "hash": "sha256-xRaEzq/OOMBi7lvi2bV2/ObN5JJJ5vcFy8DGHLItUWM=", - "version": "1351" + "hash": "sha256-ZdUq1SrOwB88Lx68ekrA4zeVsLDZz4TAJywNnF+uAzY=", + "version": "1351.120.3" }, "copyfile": { - "hash": "sha256-Vz1fo4p2b6S8xfyDPu1FNgMkH1aX0tkpXCZkdzkRdq0=", - "version": "213.40.2" + "hash": "sha256-rLqT6e44W2ohgwUXREmiOyJBYCrV3gRLbtVnbUq60xc=", + "version": "221.121.1" }, "dtrace": { "hash": "sha256-iNEZyxK3DmEwO3gzrfvCaVZSEuuOMQm5IG/6FodPNdI=", "version": "411" }, "dyld": { - "hash": "sha256-DDhV7X81nhd3oeJuICEvF8FU43yE/afQ/LYgDNtXswA=", - "version": "1241.17" + "hash": "sha256-4OOghgUYyMJbsTe96fiWCndTJ1BS94rK9v6Kqn/ooYs=", + "version": "1285.19" }, "eap8021x": { - "hash": "sha256-2FdEb76KBbCAl2iwly4c1Xstar53O8qgGdN/3WXO23U=", - "version": "364" + "hash": "sha256-Kx/wwnt108hDm0qQPyTNbZ8KoHkD5m7L4yb5qjSuQjI=", + "version": "365.120.2" }, "hfs": { - "hash": "sha256-isTLSBDxh12W10I5KY6O6SsygqnOvqJ0TfdWIKSK3pM=", - "version": "677.60.1" + "hash": "sha256-5/3Ycp3cKqlgAl1kjBmbF5tFlfJYQS5rbrbk4SS66b8=", + "version": "683.120.3" }, "launchd": { "hash": "sha256-8mW9bnuHmRXCx9py8Wy28C5b2QPICW0rlAps5njYa00=", "version": "842.1.4" }, "libclosure": { - "hash": "sha256-I0PKQFnoJVRMA7H3yT+inHS0454/FXHhQB6nwmHFvFs=", - "version": "95" + "hash": "sha256-pvwfcbeEJmTEPdt6/lgVswiabLRG+sMN6VT5FwG7C4Q=", + "version": "96" }, "libdispatch": { - "hash": "sha256-f2ex/53OFeSR5A0nMapxC6AocqBSweecNtEhp4bWjhE=", - "version": "1504.60.7" + "hash": "sha256-jTp2DolOOCQPBt1HRotkmPnKgQ2LGgniEqeHoM+vlKg=", + "version": "1521.120.4" }, "libmalloc": { - "hash": "sha256-Rw/9s7yY3qPtKfDhP+p+0z+aaCsxgwvdUyRG2V1N6D8=", - "version": "657.60.21" + "hash": "sha256-d9AVHSYTqHDlgctv8Hh4HAYW53MJelj4F8LWPsjrsws=", + "version": "715.120.13" }, "libplatform": { - "hash": "sha256-o/W1pQ9yGTE8HQlGcggM+XiJbEyqgc/s0uiY3+yBtnA=", - "version": "340.60.2" + "hash": "sha256-gpijoTMvdkM0PdG8gyIllOJlh/MtTc4ro9ODDAhN6gM=", + "version": "349" }, "libpthread": { - "hash": "sha256-eYHDAt2wNk7hJZJxsC7Y9w4ASKdexidu613kPo7TAKs=", - "version": "535" + "hash": "sha256-N+MMXdbthsxauTTfZ5ElUs39dVH+Chn1yyU6pObZpkU=", + "version": "536" }, "mDNSResponder": { - "hash": "sha256-mDyY/2S4EHbGh02J6VWZVxhNXXZmWGX+NjUjPfMZgZA=", - "version": "2559.60.39.0.1" + "hash": "sha256-ILx12PRxj/+VqfpCCErJFEJXFI9yzTh4g+FK0UCenIE=", + "version": "2600.120.12" }, "objc4": { - "hash": "sha256-uBFS5extMQkXAXJfPtPlBYAQpz+zsRHQnEaLpDOcYGM=", - "version": "928.3" + "hash": "sha256-DMxa25gXjKCkiDnVJ/8SyJUjaBlmBGABg8EfCHcmTj0=", + "version": "940.4" }, "ppp": { "hash": "sha256-8+QUA79sHf85yvGSPE9qCmGsrZDT3NZnbgZVroJw/Hg=", "version": "1016" }, "removefile": { - "hash": "sha256-h1jb4DcgDHwi9eiUguc2e5OLP8ZHxCN3B4Myp/DFDBg=", - "version": "75" + "hash": "sha256-Z5UD0mk/s80CQB0PZWDzSl2JWXmnVmwUvlNb28+hR3k=", + "version": "81" }, "xnu": { - "hash": "sha256-o8CxHvM2OXiAWJmnFe5ERQYnrNyJ+Bpdb9H0sjd6L10=", - "version": "11215.61.5" + "hash": "sha256-o4tCuCAIgAYg/Li3wTs12mVWr5C/4vbwu1zi+kJ9d6w=", + "version": "11417.121.6" } } } diff --git a/pkgs/by-name/ap/apple-sdk/metadata/versions.json b/pkgs/by-name/ap/apple-sdk/metadata/versions.json index 8de44211cfa10..6c0b1ecabf462 100644 --- a/pkgs/by-name/ap/apple-sdk/metadata/versions.json +++ b/pkgs/by-name/ap/apple-sdk/metadata/versions.json @@ -33,10 +33,10 @@ }, "15": { "urls": [ - "https://swcdn.apple.com/content/downloads/36/33/072-44426-A_G1AII30AST/ddbss9h6gse6a32rg6luosbrm6vgniu033/CLTools_macOSNMOS_SDK.pkg", - "https://web.archive.org/web/20250210234739/https://swcdn.apple.com/content/downloads/36/33/072-44426-A_G1AII30AST/ddbss9h6gse6a32rg6luosbrm6vgniu033/CLTools_macOSNMOS_SDK.pkg" + "https://swcdn.apple.com/content/downloads/52/01/082-41241-A_0747ZN8FHV/dectd075r63pppkkzsb75qk61s0lfee22j/CLTools_macOSNMOS_SDK.pkg", + "https://web.archive.org/web/20250530132510/https://swcdn.apple.com/content/downloads/52/01/082-41241-A_0747ZN8FHV/dectd075r63pppkkzsb75qk61s0lfee22j/CLTools_macOSNMOS_SDK.pkg" ], - "version": "15.2", - "hash": "sha256-OP5Ah/JnSZ6sD42BD5vGDmikgFzjsfFBmz1hvQD1dOI=" + "version": "15.5", + "hash": "sha256-HBiSJuw1XBUK5R/8Sj65c3rftSEvQl/O9ZZVp/g1Amo=" } } From e53d3167d9b010225bcf90069fa4c79691d268ad Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 13 Apr 2025 13:57:35 -0400 Subject: [PATCH 02/11] darwin.libcxx: init at 19.1.2+apple-sdk-15.5 Adds the headers and text-based stubs for the system libc++. This package is using the newest available version (currently 15.5) because libc++ uses static availability checks to prevent using features not supported by older deployment targets. Co-authored-by: Emily --- pkgs/os-specific/darwin/libcxx/default.nix | 28 ++++++++++++++++++++++ pkgs/top-level/darwin-packages.nix | 2 ++ 2 files changed, 30 insertions(+) create mode 100644 pkgs/os-specific/darwin/libcxx/default.nix diff --git a/pkgs/os-specific/darwin/libcxx/default.nix b/pkgs/os-specific/darwin/libcxx/default.nix new file mode 100644 index 0000000000000..f1a0e63833b5a --- /dev/null +++ b/pkgs/os-specific/darwin/libcxx/default.nix @@ -0,0 +1,28 @@ +{ + # Use the text-based stubs and headers from the latest SDK (currently 15.x). This is safe because + # using features that are not available on an older deployment target is a hard error. + apple-sdk_15, + stdenvNoCC, +}: + +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "libcxx"; + # Keep this in sync with the corresponding LLVM libc++ version + # defined as `_LIBCPP_VERSION` in `usr/include/c++/v1/__config`. + version = "19.1.2+apple-sdk-${apple-sdk_15.version}"; + inherit (apple-sdk_15) src; + + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + mkdir -p "$out/include" "$out/lib" + cp -v usr/lib/libc++abi.tbd usr/lib/libc++.1.tbd "$out/lib" + ln -s libc++.1.tbd "$out/lib/libc++.tbd" + cp -rv usr/include/c++ "$out/include" + runHook postInstall + ''; + + passthru.isLLVM = true; +}) diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix index 395e7196bd6f4..59ff8b3dd349b 100644 --- a/pkgs/top-level/darwin-packages.nix +++ b/pkgs/top-level/darwin-packages.nix @@ -101,6 +101,8 @@ makeScopeWithSplicing' { libunwind = callPackage ../os-specific/darwin/libunwind { }; + libcxx = callPackage ../os-specific/darwin/libcxx { }; + sigtool = callPackage ../os-specific/darwin/sigtool { }; signingUtils = callPackage ../os-specific/darwin/signing-utils { }; From 5ea679485d0952d5d0d657ce4d6ab05bcfbb6e70 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 13 Apr 2025 13:57:35 -0400 Subject: [PATCH 03/11] llvmPackages.clang: add `systemLibcxxClang` (primarily for Darwin) --- pkgs/development/compilers/llvm/common/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/development/compilers/llvm/common/default.nix b/pkgs/development/compilers/llvm/common/default.nix index 5de10bf97f0ee..e3f8c25ad46c1 100644 --- a/pkgs/development/compilers/llvm/common/default.nix +++ b/pkgs/development/compilers/llvm/common/default.nix @@ -222,6 +222,15 @@ let extraBuildCommands = mkExtraBuildCommands cc; }; + # Darwin uses the system libc++ by default. It is set up as its own clang definition so that `libcxxClang` + # continues to use the libc++ from LLVM. + systemLibcxxClang = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = darwin.libcxx; + extraPackages = [ targetLlvmLibraries.compiler-rt ]; + extraBuildCommands = mkExtraBuildCommands cc; + }; + lld = callPackage ./lld { }; From c4c5d25f13ba0b54aedf0f4094a8b835766f5389 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 13 Apr 2025 13:57:35 -0400 Subject: [PATCH 04/11] pkgs/stdenv/darwin: switch to using the system libc++ by default --- .../compilers/llvm/common/default.nix | 5 ++++- pkgs/stdenv/darwin/default.nix | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pkgs/development/compilers/llvm/common/default.nix b/pkgs/development/compilers/llvm/common/default.nix index e3f8c25ad46c1..e86e5701a35cd 100644 --- a/pkgs/development/compilers/llvm/common/default.nix +++ b/pkgs/development/compilers/llvm/common/default.nix @@ -200,6 +200,8 @@ let clang = if stdenv.targetPlatform.libc == null then tools.clangNoLibc + else if stdenv.targetPlatform.isDarwin then + tools.systemLibcxxClang else if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM else if (pkgs.targetPackages.stdenv or args.stdenv).cc.isGNU then @@ -299,7 +301,8 @@ let clangWithLibcAndBasicRtAndLibcxx = wrapCCWith rec { cc = tools.clang-unwrapped; - libcxx = targetLlvmLibraries.libcxx; + # This is used to build compiler-rt. Make sure to use the system libc++ on Darwin. + libcxx = if stdenv.hostPlatform.isDarwin then darwin.libcxx else targetLlvmLibraries.libcxx; bintools = bintools'; extraPackages = [ targetLlvmLibraries.compiler-rt-no-libc diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index d7f4145ed3b95..0edf63dbc71e2 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -133,7 +133,14 @@ let isClang = true; inherit (prevStage) libc; - inherit (prevStage.llvmPackages) libcxx; + # TODO: replace with `darwin.libcxx` once the bootstrap tools no longer have libc++. + libcxx = + if + prevStage.darwin.libcxx == null || name == "bootstrap-stage1" || name == "bootstrap-stage-xclang" + then + prevStage.llvmPackages.libcxx + else + prevStage.darwin.libcxx; inherit lib; inherit (prevStage) coreutils gnugrep; @@ -298,6 +305,7 @@ let # LLVM tools packages are staged separately (xclang, stage3) from LLVM libs (xclang). llvmLibrariesPackages = prevStage: { inherit (prevStage.llvmPackages) compiler-rt libcxx; }; + llvmLibrariesDarwinDepsNoCC = prevStage: { inherit (prevStage.darwin) libcxx; }; llvmLibrariesDeps = _: { }; llvmToolsPackages = prevStage: { @@ -365,6 +373,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check darwin = { binutils = null; binutils-unwrapped = null; + libcxx = null; libSystem = null; sigtool = null; }; @@ -986,7 +995,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check _: _: llvmToolsPackages prevStage // { - libcxxClang = super.wrapCCWith rec { + systemLibcxxClang = super.wrapCCWith rec { nativeTools = false; nativeLibc = false; @@ -1008,7 +1017,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check isClang = true; libc = self.darwin.libSystem; - inherit (self.llvmPackages) libcxx; + inherit (self.darwin) libcxx; inherit lib; inherit (self) @@ -1160,6 +1169,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check ] ++ lib.optionals localSystem.isx86_64 [ prevStage.darwin.Csu ] ++ (with prevStage.darwin; [ + libcxx libiconv.out libresolv.out libsbuf.out @@ -1172,8 +1182,6 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check (lib.getLib clang-unwrapped) compiler-rt compiler-rt.dev - libcxx - libcxx.dev lld llvm llvm.lib @@ -1268,7 +1276,6 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check assert isBuiltByNixpkgsCompiler prevStage.llvmPackages.clang-unwrapped; assert isBuiltByNixpkgsCompiler prevStage.llvmPackages.libllvm; - assert isBuiltByNixpkgsCompiler prevStage.llvmPackages.libcxx; assert isBuiltByNixpkgsCompiler prevStage.llvmPackages.compiler-rt; # Make sure these evaluate since they were disabled explicitly in the bootstrap. From 9778e3abe542a1c91e583a16e95261e001c88647 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Wed, 16 Apr 2025 20:03:29 -0400 Subject: [PATCH 05/11] pkgs/stdenv/cross: use the system libc++ by default on Darwin --- pkgs/stdenv/cross/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix index 69ea14be5c83d..2c856c99c450e 100644 --- a/pkgs/stdenv/cross/default.nix +++ b/pkgs/stdenv/cross/default.nix @@ -117,7 +117,7 @@ lib.init bootStages then throw "no C compiler provided for this platform" else if crossSystem.isDarwin then - buildPackages.llvmPackages.libcxxClang + buildPackages.llvmPackages.systemLibcxxClang else if crossSystem.useLLVM or false then buildPackages.llvmPackages.clang else if crossSystem.useZig or false then From 5d2575c627a22d104594a167b4d807b75f026e5d Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Thu, 8 May 2025 21:36:37 -0400 Subject: [PATCH 06/11] Revert "apple-sdk: add hack for C++ issues on `x86_64-darwin`" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 04b49f4e8d44ccd9f13b58ac4c31f8af4c28d4a1. This workaround has a non-trivial cost in build time. Since it’s not needed when linking against the system libc++, just drop it. --- .../ap/apple-sdk/common/process-stubs.nix | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/pkgs/by-name/ap/apple-sdk/common/process-stubs.nix b/pkgs/by-name/ap/apple-sdk/common/process-stubs.nix index 28679553b7bf3..88ebf23ee2731 100644 --- a/pkgs/by-name/ap/apple-sdk/common/process-stubs.nix +++ b/pkgs/by-name/ap/apple-sdk/common/process-stubs.nix @@ -36,21 +36,5 @@ self: super: { llvm-readtapi --filetype=tbd-v4 usr/lib/$libSystem~ -o usr/lib/$libSystem rm usr/lib/$libSystem~ done - - # Strip weak C++ symbols to work around `libc++` leakage in system - # frameworks for now. These are only present on `x86_64-darwin`, so - # it should hopefully be harmless. - # - # TODO FIXME: This is kind of horrible. - while read -r -d "" stub; do - printf 'Stripping weak C++ symbols from %s\n' "$stub" - llvm-readtapi --filetype=tbd-v5 "$stub" \ - | jq ' - (.main_library, .libraries[]?).exported_symbols[]?.data.weak[]? |= - select(startswith("__Z") | not) - ' > $stub~ - llvm-readtapi --filetype=tbd-v4 $stub~ -o $stub - rm $stub~ - done < <(find . -name '*.tbd' -print0) ''; } From 22455076d7b361937528750e996dd34acc6243f4 Mon Sep 17 00:00:00 2001 From: Emily Date: Thu, 11 Sep 2025 05:00:02 +0100 Subject: [PATCH 07/11] overrideLibcxx: drop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We now use the latest SDK’s libc++ headers, and longer have Clang versions old enough for version compatibility to be a concern. --- pkgs/stdenv/adapters.nix | 44 -------------------------------------- pkgs/top-level/aliases.nix | 1 + 2 files changed, 1 insertion(+), 44 deletions(-) diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index fcfc01d7f8900..255ff6a688895 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -67,50 +67,6 @@ rec { extraBuildInputs = (prev.extraBuildInputs or [ ]) ++ pkgs; }); - # Override the libc++ dynamic library used in the stdenv to use the one from the platform’s - # default stdenv. This allows building packages and linking dependencies with different - # compiler versions while still using the same libc++ implementation for compatibility. - # - # Note that this adapter still uses the headers from the new stdenv’s libc++. This is necessary - # because older compilers may not be able to parse the headers from the default stdenv’s libc++. - overrideLibcxx = - stdenv: - assert stdenv.cc.libcxx != null; - assert pkgs.stdenv.cc.libcxx != null; - # only unified libcxx / libcxxabi stdenv's are supported - assert lib.versionAtLeast pkgs.stdenv.cc.libcxx.version "12"; - assert lib.versionAtLeast stdenv.cc.libcxx.version "12"; - let - llvmLibcxxVersion = lib.getVersion llvmLibcxx; - - stdenvLibcxx = pkgs.stdenv.cc.libcxx; - llvmLibcxx = stdenv.cc.libcxx; - - libcxx = - pkgs.runCommand "${stdenvLibcxx.name}-${llvmLibcxxVersion}" - { - outputs = [ - "out" - "dev" - ]; - isLLVM = true; - } - '' - mkdir -p "$dev/nix-support" - ln -s '${stdenvLibcxx}' "$out" - echo '${stdenvLibcxx}' > "$dev/nix-support/propagated-build-inputs" - ln -s '${lib.getDev llvmLibcxx}/include' "$dev/include" - ''; - in - overrideCC stdenv ( - stdenv.cc.override { - inherit libcxx; - extraPackages = [ - pkgs.buildPackages.targetPackages."llvmPackages_${lib.versions.major llvmLibcxxVersion}".compiler-rt - ]; - } - ); - # Override the setup script of stdenv. Useful for testing new # versions of the setup script without causing a rebuild of # everything. diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 2c41954b72aa3..e3306ad583ac1 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -1911,6 +1911,7 @@ mapAliases { oraclejdk11 = throw "All Oracle JDKs and JREs were dropped due to being unmaintained and heavily insecure. OpenJDK provides compatible replacements for JDKs and JREs."; # Added 2024-11-01 OSCAR = oscar; # Added 2024-06-12 osxfuse = throw "'osxfuse' has been renamed to/replaced by 'macfuse-stubs'"; # Converted to throw 2024-10-17 + overrideLibcxx = "overrideLibcxx has beeen removed, as it was no longer used and Darwin now uses libc++ from the latest SDK; see the Nixpkgs 25.11 release notes for details"; # Added 2025-09-15 overrideSDK = "overrideSDK has been removed as it was a legacy compatibility stub. See for migration instructions"; # Added 2025-08-04 ovn-lts = throw "ovn-lts has been removed. Please use the latest version available under ovn"; # Added 2024-08-24 oxygen-icons5 = throw '' From 8db6e714ee534d44719ad6483bd82188e013998a Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 13 Apr 2025 13:57:35 -0400 Subject: [PATCH 08/11] libtorch-bin: drop libc++ replacement Darwin now uses the system libc++ by default, so drop the replacement. The nixpkgs libc++ is not ABI-compatible with the system libc++, so this replacement was not guaranteed to work anyway. See: https://discourse.llvm.org/t/apples-libc-now-provides-std-type-descriptor-t-functionality-not-found-in-upstream-libc/73881/3 --- pkgs/development/libraries/science/math/libtorch/bin.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkgs/development/libraries/science/math/libtorch/bin.nix b/pkgs/development/libraries/science/math/libtorch/bin.nix index 5118017b247da..3f0168644a181 100644 --- a/pkgs/development/libraries/science/math/libtorch/bin.nix +++ b/pkgs/development/libraries/science/math/libtorch/bin.nix @@ -24,7 +24,6 @@ let device = if cudaSupport then "cuda" else "cpu"; srcs = import ./binary-hashes.nix version; unavailable = throw "libtorch is not available for this platform"; - libcxx-for-libtorch = if stdenv.hostPlatform.isDarwin then libcxx else (lib.getLib stdenv.cc.cc); in stdenv.mkDerivation { inherit version; @@ -87,9 +86,6 @@ stdenv.mkDerivation { for rpath in $(otool -L $f | grep rpath | awk '{print $1}');do install_name_tool -change $rpath $out/lib/$(basename $rpath) $f done - if otool -L $f | grep /usr/lib/libc++ >& /dev/null; then - install_name_tool -change /usr/lib/libc++.1.dylib ${libcxx-for-libtorch.outPath}/lib/libc++.1.0.dylib $f - fi done for f in $out/lib/*.dylib; do otool -L $f From cdb5d3a13cf1ceb8b411ff5bd821cd223a4440fe Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 12 Apr 2025 16:46:01 -0400 Subject: [PATCH 09/11] doc/stdenv/platform-notes: add section about libc++ --- doc/redirects.json | 6 ++++++ doc/stdenv/platform-notes.chapter.md | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/doc/redirects.json b/doc/redirects.json index 1230b6460b548..4b5484f5b5c3f 100644 --- a/doc/redirects.json +++ b/doc/redirects.json @@ -216,6 +216,12 @@ "sec-building-packages-with-llvm-using-clang-stdenv": [ "index.html#sec-building-packages-with-llvm-using-clang-stdenv" ], + "sec-darwin-libcxx-deployment-targets": [ + "index.html#sec-darwin-libcxx-deployment-targets" + ], + "sec-darwin-libcxx-versions": [ + "index.html#sec-darwin-libcxx-versions" + ], "sec-functions-library-treefmt": [ "index.html#sec-functions-library-treefmt" ], diff --git a/doc/stdenv/platform-notes.chapter.md b/doc/stdenv/platform-notes.chapter.md index f7e9b4fcc3517..06662bbc76fa5 100644 --- a/doc/stdenv/platform-notes.chapter.md +++ b/doc/stdenv/platform-notes.chapter.md @@ -12,6 +12,9 @@ If it does, you’re done; skip the rest of this. - Darwin uses Clang by default instead of GCC. Packages that refer to `$CC` or `cc` should just work in most cases. Some packages may hardcode `gcc` or `g++`. You can usually fix that by setting `makeFlags = [ "CC=cc" "CXX=C++" ]`. If that does not work, you will have to patch the build scripts yourself to use the correct compiler for Darwin. +- Darwin uses the system libc++ by default to avoid ODR violations and potential compatibility issues from mixing LLVM libc++ with the system libc++. + While mixing the two usually worked, the two implementations are not guaranteed to be ABI compatible and are considered distinct by upstream. + See the troubleshooting guide below if you need to use newer C++ library features than those supported by the default deployment target. - Darwin needs an SDK to build software. The SDK provides a default set of frameworks and libraries to build software, most of which are specific to Darwin. There are multiple versions of the SDK packages in Nixpkgs, but one is included by default in the `stdenv`. @@ -30,6 +33,20 @@ If you run into issues or failures, continue reading below for how to deal with ### Darwin Issue Troubleshooting {#sec-darwin-troubleshooting} +#### Building a C++ package or library says that certain APIs are unavailable {#sec-darwin-libcxx-versions} + +While some newer APIs may be available via headers only, some require using a system libc++ with the required API support. +When that happens, your build will fail because libc++ makes failure to use the correct deployment target an error. +To make the newer API available, increase the deployment target to the required version. +Note that it is possible to use libc++ from LLVM instead of increasing the deployment target, but it is not recommended. +Doing so can cause problems when multiple libc++ implementations are linked into a binary (e.g., from dependencies). + +##### Using a newer deployment target {#sec-darwin-libcxx-deployment-targets} + +See below for how to use a newer deployment target. +For example, `std::print` depends on features that are only available on macOS 13.3 or newer. +To make them available, set the deployment target to 13.3 using `darwinMinVersionHook`. + #### Package requires a non-default SDK or fails to build due to missing frameworks or symbols {#sec-darwin-troubleshooting-using-sdks} In some cases, you may have to use a non-default SDK. From dc4c97529db7073c9e70a4a161a67cff25efcd39 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 12 Apr 2025 16:46:01 -0400 Subject: [PATCH 10/11] doc/rl-2511: mention libc++ changes on Darwin --- doc/release-notes/rl-2511.section.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/release-notes/rl-2511.section.md b/doc/release-notes/rl-2511.section.md index 018554743449d..93c5476616405 100644 --- a/doc/release-notes/rl-2511.section.md +++ b/doc/release-notes/rl-2511.section.md @@ -10,6 +10,10 @@ supported. `pkgsCross.loongarch64-linux-embedded` can be used to build software and systems for these platforms. - The official Nix formatter `nixfmt` is now stable and available as `pkgs.nixfmt`, deprecating the temporary `pkgs.nixfmt-rfc-style` attribute. The classic `nixfmt` will stay available for some more time as `pkgs.nixfmt-classic`. +- Darwin has switched to using the system libc++. This was done for improved compatibility and to avoid ODR violations. + If a newer C++ library feature is not available on the default deployment target, you will need to increase the deployment target. + See the Darwin platform documentation for more details. + ## Backward Incompatibilities {#sec-nixpkgs-release-25.11-incompatibilities} From b5bbaf2d5264e929187fcf0d9d35d357fd8aa607 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 13 Apr 2025 13:57:35 -0400 Subject: [PATCH 11/11] ovftool: drop libc++ replacement The libc++ in nixpkgs is not ABI-compatible with the system libc++, so replacements are not guaranteed to work. See: https://discourse.llvm.org/t/apples-libc-now-provides-std-type-descriptor-t-functionality-not-found-in-upstream-libc/73881/3 --- pkgs/by-name/ov/ovftool/package.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/by-name/ov/ovftool/package.nix b/pkgs/by-name/ov/ovftool/package.nix index 20cb2cb206cf0..23c18565c4992 100644 --- a/pkgs/by-name/ov/ovftool/package.nix +++ b/pkgs/by-name/ov/ovftool/package.nix @@ -240,7 +240,6 @@ stdenv.mkDerivation (final: { done # Patches for ovftool binary - change_args+=(-change /usr/lib/libc++.1.dylib ${stdenv.cc.libcxx}/lib/libc++.1.dylib) change_args+=(-change /usr/lib/libiconv.2.dylib ${libiconv}/lib/libiconv.2.dylib) change_args+=(-change /usr/lib/libxml2.2.dylib ${libxml2}/lib/libxml2.2.dylib) change_args+=(-change /usr/lib/libz.1.dylib ${zlib}/lib/libz.1.dylib)