Report the "toolchain cannot be resolved" error in DependencyResolver.
This allows us to remove the special-casing of toolchain dependencies.
The alternative would be to inject the toolchain after the DependencyResolver#dependentNodeMap() call. This would let us do away with the (arguably ugly) toolchainLabels argument to the above method and keep the error message as it is.
However, it would also exempt toolchains from being subject to the configuration transition associated with their rule class (or else that would have to be added in as a special case). They *are* exempt at HEAD, so it wouldn't be a regression, but it seems that that is only an accidental thing and not by design. (not that it matters much because currently all toolchains are in the host configuration and that doesn't have any outgoing transition edges..)
RELNOTES: None.
PiperOrigin-RevId: 232680671
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
index 533ec1d..1cdddaf 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
@@ -29,6 +29,8 @@
import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.Dependency;
+import com.google.devtools.build.lib.analysis.DependencyResolver.AttributeDependencyKind;
+import com.google.devtools.build.lib.analysis.DependencyResolver.DependencyKind;
import com.google.devtools.build.lib.analysis.DependencyResolver.InconsistentAspectOrderException;
import com.google.devtools.build.lib.analysis.PlatformSemantics;
import com.google.devtools.build.lib.analysis.TargetAndConfiguration;
@@ -573,12 +575,14 @@
Map<Label, ConfigMatchingProvider> configConditions = new LinkedHashMap<>();
// Collect the labels of the configured targets we need to resolve.
- OrderedSetMultimap<Attribute, Label> configLabelMap = OrderedSetMultimap.create();
+ OrderedSetMultimap<DependencyKind, Label> configLabelMap = OrderedSetMultimap.create();
RawAttributeMapper attributeMap = RawAttributeMapper.of(((Rule) target));
for (Attribute a : ((Rule) target).getAttributes()) {
for (Label configLabel : attributeMap.getConfigurabilityKeys(a.getName(), a.getType())) {
if (!BuildType.Selector.isReservedLabel(configLabel)) {
- configLabelMap.put(a, target.getLabel().resolveRepositoryRelative(configLabel));
+ configLabelMap.put(
+ AttributeDependencyKind.forRule(a),
+ target.getLabel().resolveRepositoryRelative(configLabel));
}
}
}
@@ -587,7 +591,7 @@
}
Map<Label, Target> configurabilityTargets =
- resolver.getTargets(configLabelMap.values(), target, transitiveRootCauses);
+ resolver.getTargets(configLabelMap, target, transitiveRootCauses);
if (configurabilityTargets == null) {
return null;
}