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 9fec2e5bc38438..87da5e139040a7 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 @@ -583,13 +583,10 @@ public NestedSet discoverInputs(ActionExecutionContext actionExecution } topLevelModules = topLevelModulesBuilder.build(); discoveredModulesBuilder.addTransitive(topLevelModules); - NestedSet discoveredModules = discoveredModulesBuilder.buildInterruptibly(); + discoveredModules = discoveredModulesBuilder.buildInterruptibly(); additionalInputs = NestedSetBuilder.fromNestedSet(additionalInputs).addTransitive(discoveredModules).build(); - if (outputFile.isFileType(CppFileTypes.CPP_MODULE)) { - this.discoveredModules = discoveredModules; - } usedModules = null; return additionalInputs; } @@ -1381,7 +1378,10 @@ public ActionContinuationOrResult beginExecution(ActionExecutionContext actionEx } if (shouldScanIncludes) { - updateActionInputs(additionalInputs); + updateActionInputs(discoveredModules); + } + if (!outputFile.isFileType(CppFileTypes.CPP_MODULE)) { + this.discoveredModules = null; } ActionExecutionContext spawnContext;