Repository navigation
[6.42] [CMake] Generate darwin std modulemap from the libc++ of the compiler - #23969
Open
root-project-bot wants to merge 1 commit into
Open
root-project-bot wants to merge 1 commit into
root-project-bot wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #23923, requested by @guitargeek.