Description of the problem:
With gcc style compiler bazel performs "dotD" dependency pruning of unused headers to limit recompilations if these unused headers were touched. As a feature this is somewhat documented in CODEBASE.md and several issues here/mails on bazel-discuss.
It is less clear if bazel does/is supposed to do the same with MSVC toolchains. It is clear that bazel uses /showIncludes to perform header inclusion checking, but unclear if it goes further. #11765 hints at header pruning on Windows being a feature.
Bugs: what's the simplest, easiest way to reproduce this bug?
On Linux/gcc the second build does nothing, on Windows/MSVC the compilation unit is rebuild.
What operating system are you running Bazel on?
Ubuntu 21.10 / Windows 10
What's the output of bazel info release?
release 5.0.0
Any other information, logs, or outputs that you want to share?
The following change in
|
if (!shouldScanIncludes && dotdFile == null) { |
fixes the problem, but I am not sure if that modification is safe.
.../devtools/build/lib/rules/cpp/CppCompileActionBuilder.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java
index 36c81dc5..4472d771 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java
@@ -347,7 +347,7 @@ public class CppCompileActionBuilder {
if (grepIncludes != null) {
realMandatoryInputsBuilder.add(grepIncludes);
}
- if (!shouldScanIncludes && dotdFile == null) {
+ if (!shouldScanIncludes && dotdFile == null && !featureConfiguration.isEnabled(CppRuleClasses.PARSE_SHOWINCLUDES)) {
realMandatoryInputsBuilder.addTransitive(ccCompilationContext.getDeclaredIncludeSrcs());
realMandatoryInputsBuilder.addTransitive(additionalPrunableHeaders);
}
Description of the problem:
With
gccstyle compilerbazelperforms "dotD" dependency pruning of unused headers to limit recompilations if these unused headers were touched. As a feature this is somewhat documented inCODEBASE.mdand several issues here/mails on bazel-discuss.It is less clear if
bazeldoes/is supposed to do the same with MSVC toolchains. It is clear thatbazeluses/showIncludesto perform header inclusion checking, but unclear if it goes further. #11765 hints at header pruning on Windows being a feature.Bugs: what's the simplest, easiest way to reproduce this bug?
bazel build :main -sdead.hwhich may be used bymainbut is never included frommain.cppbazel build :main -sOn Linux/gcc the second build does nothing, on Windows/MSVC the compilation unit is rebuild.
What operating system are you running Bazel on?
Ubuntu 21.10 / Windows 10
What's the output of
bazel info release?release 5.0.0Any other information, logs, or outputs that you want to share?
The following change in
bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java
Line 350 in 6c955a5