Add platform data into to the ToolchainContext unconditionally.
Part of #4128.
Change-Id: I1e043e7290912de5b246dbb8748cb2ad865ce38c
PiperOrigin-RevId: 176664440
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainUtil.java b/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainUtil.java
index ca311c8..a47e373 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainUtil.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainUtil.java
@@ -55,15 +55,36 @@
Environment env,
String targetDescription,
Set<Label> requiredToolchains,
- BuildConfiguration configuration)
+ @Nullable BuildConfiguration configuration)
throws ToolchainContextException, InterruptedException {
+
+ // In some cases this is called with a missing configuration, so we skip toolchain context.
+ if (configuration == null) {
+ return null;
+ }
+
+ // TODO(katre): Load several possible execution platforms, and select one based on available
+ // toolchains.
+
+ // Load the execution and target platforms for the current configuration.
+ PlatformDescriptors platforms = loadPlatformDescriptors(env, configuration);
+ if (platforms == null) {
+ return null;
+ }
+
ImmutableBiMap<Label, Label> resolvedLabels =
- resolveToolchainLabels(env, requiredToolchains, configuration);
+ resolveToolchainLabels(env, requiredToolchains, configuration, platforms);
if (resolvedLabels == null) {
return null;
}
+
ToolchainContext toolchainContext =
- ToolchainContext.create(targetDescription, requiredToolchains, resolvedLabels);
+ ToolchainContext.create(
+ targetDescription,
+ platforms.execPlatform(),
+ platforms.targetPlatform(),
+ requiredToolchains,
+ resolvedLabels);
return toolchainContext;
}
@@ -152,7 +173,10 @@
@Nullable
private static ImmutableBiMap<Label, Label> resolveToolchainLabels(
- Environment env, Set<Label> requiredToolchains, BuildConfiguration configuration)
+ Environment env,
+ Set<Label> requiredToolchains,
+ BuildConfiguration configuration,
+ PlatformDescriptors platforms)
throws InterruptedException, ToolchainContextException {
// If there are no required toolchains, bail out early.
@@ -160,12 +184,6 @@
return ImmutableBiMap.of();
}
- // Load the execution and target platforms for the current configuration.
- PlatformDescriptors platforms = loadPlatformDescriptors(env, configuration);
- if (platforms == null) {
- return null;
- }
-
// Find the toolchains for the required toolchain types.
List<SkyKey> registeredToolchainKeys = new ArrayList<>();
for (Label toolchainType : requiredToolchains) {