aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google
diff options
context:
space:
mode:
authorGravatar lberki <lberki@google.com>2018-01-16 06:07:59 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-16 06:09:37 -0800
commit543e3b67616f5b3dd93d9ded725b93e8a61e40b7 (patch)
treede3e72988d8f4812f30416ac1ac6a00058ecf253 /src/main/java/com/google
parent290970c1e0567f1ecd39a64cd6fd14324367126e (diff)
Change the mnemonic of C++ link stamp compile actions so that extra actions can be attached to C++ compile actions without tickling the bug that makes Blaze crash when extra actions are attached to shared actions that do input discovery.
RELNOTES: None. PiperOrigin-RevId: 182044169
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java24
1 files changed, 19 insertions, 5 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 549341a872..8f2a0c63b5 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
@@ -186,6 +186,7 @@ public class CppCompileAction extends AbstractAction
@VisibleForTesting public final CompileCommandLine compileCommandLine;
private final ImmutableMap<String, String> executionInfo;
private final ImmutableMap<String, String> environment;
+ private final String actionName;
@VisibleForTesting final CppConfiguration cppConfiguration;
private final FeatureConfiguration featureConfiguration;
@@ -330,6 +331,7 @@ public class CppCompileAction extends AbstractAction
this.actionClassId = actionClassId;
this.executionInfo = executionInfo;
this.environment = environment;
+ this.actionName = actionName;
// We do not need to include the middleman artifact since it is a generated
// artifact and will definitely exist prior to this action execution.
@@ -1281,11 +1283,23 @@ public class CppCompileAction extends AbstractAction
@Override
public String getMnemonic() {
- if (sourceFile.isFileType(CppFileTypes.OBJC_SOURCE)
- || sourceFile.isFileType(CppFileTypes.OBJCPP_SOURCE)) {
- return "ObjcCompile";
- } else {
- return "CppCompile";
+ switch (actionName) {
+ case OBJC_COMPILE:
+ case OBJCPP_COMPILE:
+ return "ObjcCompile";
+
+ case LINKSTAMP_COMPILE:
+ // When compiling shared native deps, e.g. when two java_binary rules have the same set of
+ // native dependencies, the CppCompileAction for link stamp data is shared also. This means
+ // that out of two CppCompileAction instances, only one is actually executed, which means
+ // that if extra actions are attached to both, one of the extra actions will find a
+ // CppCompileAction for which discoverInputs() hasn't been called and thus trigger an
+ // assertion. As a band-aid, change the mnemonic of said actions so that one can attach
+ // extra actions to regular CppCompileActions without tickling this bug.
+ return "CppLinkstampCompile";
+
+ default:
+ return "CppCompile";
}
}