Prevent crash when using a tree artifact in cc_library's srcs The check to determine which subset of the toolchain files to provide as inputs requires knowing the file type. actionBuilder::getActionName() throws IllegalStateException when given a tree artifact (directory). In this case, we provide all toolchain files as inputs, since Bazel does not know the content of the directory at this time. PiperOrigin-RevId: 339271792
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppSemantics.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppSemantics.java index f8b70cf..630e128 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppSemantics.java
@@ -68,6 +68,7 @@ actionBuilder .addTransitiveMandatoryInputs( configuration.getFragment(CppConfiguration.class).useSpecificToolFiles() + && !actionBuilder.getSourceFile().isTreeArtifact() ? (actionBuilder.getActionName().equals(CppActionNames.ASSEMBLE) ? toolchain.getAsFiles() : toolchain.getCompilerFiles())