Support C++20 modules in the rules-based toolchain API#750
Open
fmeum wants to merge 1 commit into
Open
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
1855ab6 to
2642dab
Compare
fmeum
commented
Jun 18, 2026
fmeum
commented
Jun 18, 2026
fmeum
commented
Jun 18, 2026
ae97e7e to
d9e66fb
Compare
Collaborator
Author
|
FYI @dzbarsky |
The rules-based cc/toolchains toolchain API was missing several pieces needed to drive Bazel's C++20 modules pipeline (clang-scan-deps -> .ddi -> aggregate-ddi -> generate-modmap -> module compile): - Add a cpp20_module_actions action type set grouping the module interface compile, codegen and dependency scanning actions. These are deliberately kept out of compile_actions/source_compile_actions so that flags incompatible with C++20 modules can keep targeting only the non-module compiles. - Register the cpp_module_output_file and cpp_module_modmap_file build variables and make dependency_file, output_file, source_file and user_compile_flags available to the C++20 module actions. - Extend the legacy compile features (compiler_input_flags, compiler_output_flags, dependency_file, user_compile_flags) to the C++20 module actions, so the generic -c / -o / -MD -MF / user-copt flags are emitted for module interface compile, codegen and dependency scanning the same way they are for ordinary compiles. Toolchains that use these features then need no module-specific source/output/dependency/copt args of their own. - Include the C++20 module actions in the compiler_files legacy file group so their tools (e.g. the dependency scanner) are available to the compile actions. The C++20 modules pipeline lives only in rules_cc's compile.bzl (Bazel's native rules do not implement it), and was previously untested here: Bazel's CppModulesConfiguredTargetTest only checks the --experimental_cpp_modules / cpp_modules gating, and the shell integration test self-skips unless a host clang >= 17 is present. Add an analysis test that drives the module interface compile + dependency scanning actions with a mock toolchain (no real compiler needed) and asserts the scanning action emits both the P1689 .ddi file and the Make-style .ddi.d dependency file. This test fails without the fixes in the preceding commit.
d9e66fb to
460d4a1
Compare
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.
Add toolchain variables and and an action type set for C++20 module actions, allowing them to be configured in a rule-based toolchain.