Exclude cpp_module_codegen from source_compile_actions (#897) 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. Closes #897 COPYBARA_INTEGRATE_REVIEW=https://github.com/bazelbuild/rules_cc/pull/897 from fmeum:codegen-no-preprocessing-flags 1157d3784791939390992a0a840e1e91f935866d PiperOrigin-RevId: 1004579515 Change-Id: I51f7f91172ae614876080794a59278ca22faafcd
diff --git a/cc/toolchains/actions/BUILD b/cc/toolchains/actions/BUILD index 80cac26..cbf9395 100644 --- a/cc/toolchains/actions/BUILD +++ b/cc/toolchains/actions/BUILD
@@ -269,6 +269,10 @@ excludes = [ # `lto_backend` actions do not instantiate the full set of build variables. ":lto_backend", + # `cpp_module_codegen` actions compile a precompiled module and never + # preprocess, so include paths, defines and other preprocessing flags + # don't apply to them and only make Clang warn about unused arguments. + ":cpp_module_codegen", ], )
diff --git a/tests/rule_based_toolchain/action_type_sets/goldens/source_compile_actions.txt b/tests/rule_based_toolchain/action_type_sets/goldens/source_compile_actions.txt index e039c97..c59b6f5 100644 --- a/tests/rule_based_toolchain/action_type_sets/goldens/source_compile_actions.txt +++ b/tests/rule_based_toolchain/action_type_sets/goldens/source_compile_actions.txt
@@ -1,7 +1,6 @@ assemble c++-compile c++-header-parsing -c++-module-codegen c++-module-compile c-compile clif-match