Set direct/transitive module sets for CppCompileAction without include scanning - #30396
Open
fmeum wants to merge 1 commit into
Open
Set direct/transitive module sets for CppCompileAction without include scanning#30396fmeum wants to merge 1 commit into
fmeum wants to merge 1 commit into
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. |
fmeum
force-pushed
the
claude/bazel-cpp-compile-modules-4spvby
branch
from
July 21, 2026 16:09
5bb1cb4 to
cc82226
Compare
When include scanning is disabled, CppCompileAction never populated its top-level modules nor its discovered (transitive) modules: the former caused getOverwrittenVariables() to fall back to flattening all inputs, putting every transitive .pcm on the command line, and the latter left ActionExecutionValue without discovered modules for module-producing compiles. Fix this by computing a suitable upper bound at action construction time when header modules are used without include scanning: * Top-level modules: the modules of direct dependencies plus the separate module of the current context (except for its own compile), mirroring the exclusions of CcCompilationContext#computeUsedModules. Modules that are only used transitively are found by the compiler through the paths embedded in the direct .pcm files, just as in the include scanning case. * Discovered (transitive) modules: all transitive modules plus the top-level bound, which are all provided as inputs. Since the separate module of the current context is not part of the transitive modules, CppCompileActionBuilder now also adds it as an input to all compiles of the context other than its own compile, matching the existing allowedDerivedInputs special case.
fmeum
force-pushed
the
claude/bazel-cpp-compile-modules-4spvby
branch
from
July 21, 2026 17:14
cc82226 to
7737d92
Compare
fmeum
marked this pull request as ready for review
July 21, 2026 21:18
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.
Description
When include scanning is disabled,
CppCompileActionnever populated its top-level modules nor its discovered (transitive) modules: the former causedgetOverwrittenVariables()to fall back to putting every transitive.pcmon the command line, and the latter leftActionExecutionValuewithout discovered modules for module-producing compiles.Fix this by computing a suitable upper bound at action construction time when header modules are used without include scanning:
CcCompilationContext#computeUsedModules. Modules that are only used transitively are found by the compiler through the paths embedded in the direct.pcmfiles, just as in the include scanning case.Since the separate module of the current context is not part of the transitive modules,
CppCompileActionBuildernow also adds it as an input to all compiles of the context other than its own compile, matching the existingallowedDerivedInputsspecial case.Motivation
Fixing header module compilation in Bazel with default settings, i.e., without include scanning.
Build API Changes
No
Checklist
Release Notes
RELNOTES: None