Skip to content

Commit c5641af

Browse files
katrecopybara-github
authored andcommitted
Automated rollback of commit 37db93f.
Add a validation that any call to `cc_module.compile` has a CC toolchain type available. *** Reason for rollback *** Re-re-enabling after fixing (more) issues PiperOrigin-RevId: 766786360 Change-Id: I670b0fa4e08f86435b18f2b4b461aeac66efb4d0
1 parent 1b20234 commit c5641af

File tree

1 file changed

+13
-0
lines changed
  • src/main/java/com/google/devtools/build/lib/rules/cpp

1 file changed

+13
-0
lines changed

src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,19 @@ public Tuple compile(
17521752
stripIncludePrefix,
17531753
additionalIncludeScanningRoots,
17541754
1); // stackDepth = 1 is the caller of native cc_common.compile().
1755+
// Ensure that the CC toolchain type is present, regardless of what was passed as
1756+
// starlarkCcToolchainProvider.
1757+
if (starlarkActionFactoryApi.getRuleContext().useAutoExecGroups()
1758+
&& !starlarkActionFactoryApi
1759+
.getRuleContext()
1760+
.getToolchainContexts()
1761+
.hasToolchainContext(getSemantics().getCppToolchainType().toString())) {
1762+
throw Starlark.errorf(
1763+
"cc_common.compile requires the CC toolchain type (%s), but rule %s does not"
1764+
+ " declare it",
1765+
getSemantics().getCppToolchainType(),
1766+
starlarkActionFactoryApi.getRuleContext().getRule().getRuleClass());
1767+
}
17551768

17561769
List<Artifact> includeScanningRoots =
17571770
getAdditionalIncludeScanningRoots(additionalIncludeScanningRoots, thread);

0 commit comments

Comments
 (0)