From fd792992405b97c05c19e3b60fb54f46d6e9d6a4 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Fri, 10 Sep 2021 09:22:09 +0200 Subject: [PATCH] Trim input build settings after transition By convention, BuildOptions should not contain Starlark build settings that are set to their default values. However, if a Starlark transition has a build setting as an input, the value of that setting has to be added to the input BuildOptions temporarily so that it can be read by the transition. Before this commit, if a build setting was an input but not an output of a transition, its default value remained in the BuildOptions and could cause action conflicts. With this commit, all build settings rather than only output build settings are trimmed post-transition if they are set to their default value. Fixes #12888. --- .../analysis/starlark/StarlarkTransition.java | 8 +- .../StarlarkAttrTransitionProviderTest.java | 82 +++++++++++++++++++ 2 files changed, 87 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkTransition.java b/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkTransition.java index 317225b133a4dd..8f0001ddc977cd 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkTransition.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkTransition.java @@ -267,13 +267,15 @@ public static Map validate( Map buildSettingPackages, Map toOptions) throws TransitionException { - // collect settings changed during this transition and their types + // Collect settings changed during this transition and their types. This includes settings that + // were only used as inputs as to the transition and thus had their default values added to the + // fromOptions, which in case of a no-op transition directly end up in toOptions. Map changedSettingToRule = Maps.newHashMap(); root.visit( (StarlarkTransitionVisitor) transition -> { - ImmutableSet