Fix 'recompiled linkstamps after shutdown' bug
TLDR: This cl fixes a Bazel bug when linkstamps would be recompiled after bazel server
restart even though not a single file was modified.
Before, when building with --nostamp, bazel recompiled every linkstamp for every
C++ executable, test, or transitive shared library in the build after every
bazel server restart.
Before, when building with --stamp, bazel recompiled every linkstamp for every
c++ executable, test, or transitive shared library in the build, and that
resulted in relinking of those (after every bazel server restart).
After this cl, bazel correctly notices that nothing has changed, and will not
recompile linkstamps at all. Null build after a shutdown is again behaving like
a null build :)
RELNOTES: Linkstamps are no longer recompiled after server restart.
PiperOrigin-RevId: 209454160
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
index 8492e10..bd7bcde 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
@@ -917,6 +917,7 @@
HashSet<Artifact> result = new HashSet<>();
addNonSources(result, mandatoryInputs);
addNonSources(result, additionalPrunableHeaders);
+ addNonSources(result, inputsForInvalidation);
addNonSources(result, getDeclaredIncludeSrcs());
addNonSources(result, ccCompilationContext.getTransitiveModules(usePic));
Artifact artifact = getSourceFile();