From 2f00d4f5af575e03a6324eeb0e9ddbee2b0c6803 Mon Sep 17 00:00:00 2001 From: djasper Date: Fri, 26 Feb 2021 04:09:19 -0800 Subject: [PATCH] Properly return separate module as an allowed derived input. Otherwise, the action cache does not properly understand these inputs. RELNOTES: None. PiperOrigin-RevId: 359729150 --- .../build/lib/rules/cpp/CppCompileAction.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) 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 5b33c14bb6697a..8afcf9c0b33ae4 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 @@ -1217,13 +1217,21 @@ public CcToolchainVariables getOverwrittenVariables() { @Override public NestedSet getAllowedDerivedInputs() { - return NestedSetBuilder.fromNestedSet(mandatoryInputs) - .addTransitive(additionalPrunableHeaders) - .addTransitive(inputsForInvalidation) - .addTransitive(getDeclaredIncludeSrcs()) - .addTransitive(ccCompilationContext.getTransitiveModules(usePic)) - .add(getSourceFile()) - .build(); + NestedSetBuilder builder = + NestedSetBuilder.fromNestedSet(mandatoryInputs) + .addTransitive(additionalPrunableHeaders) + .addTransitive(inputsForInvalidation) + .addTransitive(getDeclaredIncludeSrcs()) + .addTransitive(ccCompilationContext.getTransitiveModules(usePic)) + .add(getSourceFile()); + + // The separate module is an allowed input to all compiles of this context except for its own + // compile. + Artifact separateModule = ccCompilationContext.getSeparateHeaderModule(usePic); + if (separateModule != null && !separateModule.equals(outputFile)) { + builder.add(separateModule); + } + return builder.build(); } /**