Skip to content

darwin.libcxx: (╯°□°)╯︵ ┻━┻#398727

Merged
emilazy merged 11 commits intoNixOS:stagingfrom
reckenrode:push-tquznrszxwpz
Sep 15, 2025
Merged

darwin.libcxx: (╯°□°)╯︵ ┻━┻#398727
emilazy merged 11 commits intoNixOS:stagingfrom
reckenrode:push-tquznrszxwpz

Conversation

@reckenrode
Copy link
Contributor

@reckenrode reckenrode commented Apr 15, 2025

Darwin currently uses libc++ from nixpkgs, but it probably shouldn’t (at least not by default). The libc++ that is built in nixpkgs comes from LLVM. According to Louis Dionne (of Apple and a member of the C++ committee), the libc++ shipped by Apple should be considered distinct from the libc++ in LLVM. We’ve been lucky that we have not had problems with ODR violations. This PR was prompted by leakage of symbols from the system libc++ that started happening with the release of macOS 15.4. It changes a number of things to improve the compatibility of C++ on Darwin.

  • It makes the system libc++ the default C++. The Darwin bootstrap is built against it. The default stdenv uses it. This is done by making the libc++ headers and text-based stubs available from the 15.2 SDK. This is safe to do because using symbols that are not available on your deployment target results in a compile-time error.

Testing

I also confirmed that all of the packages updated in this PR built (except for servo, which is broken due to Darwin having a case-insensitive build location), that Qt 5 and opencv4 built on x86_64-darwin, and that my configs built (except for util-linux, which appears broken again on Darwin).

Breaking Change

The primary points of breakage are as follows:

  • Packages (such as Bazel and MoltenVK) that work around #150655 by referencing libcxx should instead reference stdenv.cc.libcxx. (Those are also fixed in this PR.)
  • The system libc++ expects Clang 16 or newer (due to libc++ support policies). To build with an older Clang, you need to override the SDK used by libc++ to make it use older libc++ headers.
  • overrideLibcxx doesn’t work with the system libc++. If you really need to use it, you should use it with llvmPackages.libcxxStdenv.

Notes about fixed packages

  • Several packages depend on qt6.qtdeclarative, but it doesn’t build. Fixed in #398849.
  • python3Packages.py3exid2 looks for Boost in /usr/local/lib. Fixed in #399005.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: ocaml OCaml is a general-purpose, high-level, multi-paradigm programming language. 6.topic: stdenv Standard environment 6.topic: R R is a programming language for statistical computing and data visualization. 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related labels Apr 15, 2025
@github-actions github-actions bot added the 8.has: documentation This PR adds or changes documentation label Apr 15, 2025
@reckenrode reckenrode force-pushed the push-tquznrszxwpz branch 2 times, most recently from edac098 to 34d2d14 Compare April 15, 2025 01:33
@reckenrode reckenrode force-pushed the push-tquznrszxwpz branch 3 times, most recently from bc18c00 to d111455 Compare April 15, 2025 02:13
@github-actions github-actions bot added 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Apr 15, 2025
@github-actions github-actions bot added the 6.topic: qt/kde Object-oriented framework for GUI creation label Apr 17, 2025
@reckenrode
Copy link
Contributor Author

Fixed the signatures. I think I’m going to need to look into Sequoia as a replacement for GnuPG ….

Anyway, I confirmed that all of the packages changed in this PR build except for servo, which fails due to having README.md and Readme.md in one of its vendored crates (i.e., case-insensitive /tmp issues). I also confirmed that both Qt 5 and opencv4 build with their workarounds reverted from the last staging-next cycle.

@reckenrode reckenrode marked this pull request as ready for review April 17, 2025 00:16
@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Apr 17, 2025
@booxter booxter mentioned this pull request Apr 18, 2025
13 tasks
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label May 17, 2025
@reckenrode reckenrode force-pushed the push-tquznrszxwpz branch from 02a2048 to 8e5554e Compare May 30, 2025 00:27
@github-actions github-actions bot removed the 6.topic: python Python is a high-level, general-purpose programming language. label May 30, 2025
@github-project-automation github-project-automation bot moved this to In Progress in Stdenv Jul 29, 2025
@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Jul 29, 2025
@emilazy emilazy force-pushed the push-tquznrszxwpz branch 2 times, most recently from 088c7a6 to 996bbf6 Compare September 15, 2025 17:34
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 15, 2025
@emilazy emilazy enabled auto-merge September 15, 2025 18:09
@emilazy emilazy disabled auto-merge September 15, 2025 18:09
emilazy and others added 11 commits September 15, 2025 19:24
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 <vcs@emily.moe>
This reverts commit 04b49f4.

This workaround has a non-trivial cost in build time. Since it’s not
needed when linking against the system libc++, just drop it.
We now use the latest SDK’s libc++ headers, and longer have Clang
versions old enough for version compatibility to be a concern.
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
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
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Sep 15, 2025
@emilazy emilazy merged commit 1b180b8 into NixOS:staging Sep 15, 2025
28 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Stdenv Sep 15, 2025
@philiptaron
Copy link
Contributor

Woohoo!

@reckenrode reckenrode deleted the push-tquznrszxwpz branch September 22, 2025 01:50
Rhys-T added a commit to Rhys-T/nur-packages that referenced this pull request Oct 13, 2025
Reworked patch into a setup hook shared between phosg and resource_dasm.

Made the patch slightly less hacky.

Re-enabled patch when libc++ is Apple's version rather than LLVM's.
(See <NixOS/nixpkgs#398727>.)
@Rhys-T Rhys-T mentioned this pull request Oct 31, 2025
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: darwin Running or building packages on Darwin 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 6.topic: stdenv Standard environment 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants