Skip to content

Exclude cpp_module_codegen from source_compile_actions - #897

Closed
fmeum wants to merge 1 commit into
bazelbuild:mainfrom
fmeum:codegen-no-preprocessing-flags
Closed

fmeum wants to merge 1 commit into
bazelbuild:mainfrom
fmeum:codegen-no-preprocessing-flags

Conversation

@fmeum

@fmeum fmeum commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

Module codegen actions compile a precompiled module into an object file and never preprocess. Bazel's legacy include_paths, includes and preprocessor_defines features accordingly don't cover the cpp_module_codegen action, but their rules-based counterparts (//cc/toolchains/args/include_flags and //cc/toolchains/args/preprocessor_defines, as well as the corresponding variables) apply to source_compile_actions, which does. Every module codegen action thus receives the include paths and defines of compile actions, and Clang warns about each include path as an unused argument (clang++: warning: argument unused during compilation: '-iquote .' [-Wunused-command-line-argument]).

This excludes the action from source_compile_actions like lto_backend already is, which restores parity with the legacy features.

Module codegen actions compile a precompiled module into an object
file and never preprocess. Bazel's legacy include_paths, includes and
preprocessor_defines features accordingly don't cover the
cpp_module_codegen action, but their rules-based counterparts apply to
source_compile_actions, which does, so every module codegen action
receives the include paths and defines of compile actions. Clang warns
about each include path as an unused argument:

  clang++: warning: argument unused during compilation: '-iquote .'
  [-Wunused-command-line-argument]

Exclude the action from source_compile_actions like lto_backend, which
also restores parity with the legacy features. Verified with a
rules-based toolchain that supports header modules: module codegen
actions no longer get include paths and defines, build without
warnings and the resulting objects link and run as before.
@fmeum
fmeum marked this pull request as ready for review September 18, 2026 21:16
AustinSchuh added a commit to AustinSchuh/rules_cc that referenced this pull request Oct 30, 2026
The merge left random_seed_unix_test unterminated, mangled the
compiler_input_flags and compiler_output_flags tests, and put a load out
of order. Restore both sides' tests.

Main also excluded cpp_module_codegen from the preprocessing action set
(bazelbuild#897), so drop it from the includes, include_paths and
preprocessor_defines goldens.

Signed-off-by: Austin Schuh <austin.linux@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants