Skip to content

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

Open
root-project-bot wants to merge 1 commit into
root-project:v6-42-00-patchesfrom
root-project-bot:BP_6.42_pull_23923
Open

root-project-bot wants to merge 1 commit into
root-project:v6-42-00-patchesfrom
root-project-bot:BP_6.42_pull_23923

Conversation

@root-project-bot

Copy link
Copy Markdown

Backport of #23923, requested by @guitargeek.

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

(cherry picked from commit c349620)

This branch has not been deployed

No deployments
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.

3 participants