Skip to content

[CMake] Generate darwin std modulemap from the libc++ of the compiler - #23923

Merged
guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:darwin-modules
Nov 3, 2026
Merged

guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:darwin-modules

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

With runtime_cxxmodules on macOS, the build generates std_darwin.modulemap by wrapping the libc++ module map, which it looks up in the SDK at "<CMAKE_OSX_SYSROOT>/usr/include/c++/v1". That is not necessarily the libc++ that is actually used: toolchains like Homebrew LLVM, Nix or conda-forge ship their own libc++ next to the compiler, and the SDK can be stripped of libc++ altogether (conda-forge and Nix do that), in which case the configuration fails with:

FileNotFoundError: Cannot find libc++ modulemap at /usr/include/c++/v1/module.modulemap

The generated module map must match the libc++ that cling uses at runtime, which is the one of the compiler: cling queries the compiler for its C++ include directory and mounts std_darwin.modulemap there. Hence, look for the libc++ include directory in the implicit include directories of the compiler (identified by the "__config" header and a module map) and hand it to the script, which prefers it over the SDK path. For the default Apple toolchain, the implicit include directories contain the libc++ of the SDK, so nothing changes there. The existing fallbacks are kept.

Also make the generated modulemap depend on the libc++ modulemap it is derived from, so that it is regenerated when the toolchain is updated in place (e.g. the Command Line Tools SDK).

🤖 Done with the help of AI

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Test Results

    22 files      22 suites   3d 15h 22m 1s ⏱️
 3 883 tests  3 883 ✅ 0 💤 0 ❌
76 010 runs  76 010 ✅ 0 💤 0 ❌

Results for commit 2bd42df.

♻️ This comment has been updated with latest results.

@guitargeek
guitargeek force-pushed the darwin-modules branch 2 times, most recently from 11e2b07 to 99abb89 Compare November 2, 2026 12:26
guitargeek added a commit to guitargeek/nixpkgs that referenced this pull request Nov 2, 2026
…ules workaround

Update to the current head of ROOT PR 23877. The fix for the openui5
install rule is part of the PR now.

The compiledata.sh and cling include directory fixes were upstreamed
as root-project/root@1b6d33beb82 and root-project/root#23924, so fetch
them from there instead of carrying local copies.

Also apply root-project/root#23923, which generates the Darwin std
modulemap from the libc++ of the compiler instead of the one in the
SDK. This was the reason for disabling runtime_cxxmodules on Darwin.
guitargeek added a commit to guitargeek/nixpkgs that referenced this pull request Nov 2, 2026
ROOT PR 23877 is merged, so take the sources from root-project/root
master instead of the feature branch. Master renamed the JSROOT archive
to jsroot-7.12.0.tar.gz, so adjust the pre-downloaded archive and
regenerate the ROOT_DOWNLOAD_DIR patch against it.

The compiledata.sh fix is in master as well, so drop it. The Darwin
modulemap fix is taken as the two commits of root-project/root#23923.
With runtime_cxxmodules on macOS, the build generates std_darwin.modulemap
by wrapping the libc++ module map, which it looks up in the SDK at
"<CMAKE_OSX_SYSROOT>/usr/include/c++/v1". That is not necessarily the
libc++ that is actually used: toolchains like Homebrew LLVM, Nix or
conda-forge ship their own libc++ next to the compiler, and the SDK can be
stripped of libc++ altogether (conda-forge and Nix do that), in which
case the configuration fails with:

  FileNotFoundError: Cannot find libc++ modulemap at <SDK>/usr/include/c++/v1/module.modulemap

The generated module map must match the libc++ that cling uses at
runtime, which is the one of the compiler: cling queries the compiler for
its C++ include directory and mounts std_darwin.modulemap there. Hence,
look for the libc++ include directory in the implicit include directories
of the compiler (identified by the "__config" header and a module map) and
hand it to the script, which prefers it over the SDK path. For the default
Apple toolchain, the implicit include directories contain the libc++ of the
SDK, so nothing changes there. The existing fallbacks are kept.

Also make the generated modulemap depend on the libc++ modulemap it is
derived from, so that it is regenerated when the toolchain is updated in
place (e.g. the Command Line Tools SDK).

🤖 Done with the help of AI
@guitargeek

Copy link
Copy Markdown
Contributor Author

@vepadulano, I have reverted this PR to only contain the original commit, and opened a draft PR with the conda-related change so we don't forget about it: #23962

@vepadulano vepadulano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changes LGTM in principle, they seem not to affect the CI. I think one of the codeowners @bellenot @hahnjo should be approving this one.

@guitargeek
guitargeek merged commit c349620 into root-project:master Nov 3, 2026
34 checks passed
@guitargeek
guitargeek deleted the darwin-modules branch November 3, 2026 15:42
@guitargeek

Copy link
Copy Markdown
Contributor Author

/backport to 6.42

@root-project-bot

Copy link
Copy Markdown

Preparing to backport PR #23923 to branch 6.42 requested by guitargeek

@root-project-bot

Copy link
Copy Markdown

This PR has been backported to branch 6.42: #23969

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants