diff --git a/src/main/java/com/google/devtools/build/lib/analysis/starlark/FunctionTransitionUtil.java b/src/main/java/com/google/devtools/build/lib/analysis/starlark/FunctionTransitionUtil.java index c6903b01cc68d0..af82bab606ae52 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/starlark/FunctionTransitionUtil.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/starlark/FunctionTransitionUtil.java @@ -99,7 +99,8 @@ static ImmutableMap applyAndValidate( } for (Map.Entry> entry : transitions.entrySet()) { - Map newValues = handleImplicitPlatformChange(entry.getValue()); + Map newValues = handleImplicitPlatformChange(buildOptions, + entry.getValue()); BuildOptions transitionedOptions = applyTransition(buildOptions, newValues, optionInfoMap, starlarkTransition); splitBuildOptions.put(entry.getKey(), transitionedOptions); @@ -127,21 +128,22 @@ static ImmutableMap applyAndValidate( *

Transitions can also explicitly set --platforms to be clear what platform they set. * *

Platform mappings: https://bazel.build/concepts/platforms-intro#platform-mappings. - * - *

This doesn't check that the changed value is actually different than the source (i.e. - * setting {@code --cpu=foo} when {@code --cpu} is already {@code foo}). That could unnecessarily - * fork configurations that are really the same. That's a possible optimization TODO. */ private static Map handleImplicitPlatformChange( - Map originalOutput) { - boolean changesCpu = originalOutput.containsKey(COMMAND_LINE_OPTION_PREFIX + "cpu"); - boolean changesPlatforms = originalOutput.containsKey(COMMAND_LINE_OPTION_PREFIX + "platforms"); - return changesCpu && !changesPlatforms - ? ImmutableMap.builder() - .putAll(originalOutput) - .put(COMMAND_LINE_OPTION_PREFIX + "platforms", ImmutableList.