diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyFunctions.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyFunctions.java index aa593e8e84b313..4d38bb9ae95cf5 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyFunctions.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyFunctions.java @@ -101,7 +101,7 @@ public final class SkyFunctions { SkyFunctionName.createHermetic("BUILD_CONFIGURATION_KEY"); public static final SkyFunctionName PARSED_FLAGS = SkyFunctionName.createHermetic("PARSED_FLAGS"); public static final SkyFunctionName BASELINE_OPTIONS = - SkyFunctionName.createHermetic("BASELINE_OPTIONS"); + SkyFunctionName.createNonHermetic("BASELINE_OPTIONS"); public static final SkyFunctionName STARLARK_BUILD_SETTINGS_DETAILS = SkyFunctionName.createHermetic("STARLARK_BUILD_SETTINGS_DETAILS"); // Action execution can be nondeterministic, so semi-hermetic. diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java index fbaeaf5999d299..45835095d3364e 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java @@ -270,6 +270,7 @@ import com.google.devtools.build.skyframe.SkyFunctionName; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; +import com.google.devtools.build.skyframe.Version; import com.google.devtools.build.skyframe.WalkableGraph; import com.google.devtools.build.skyframe.WalkableGraph.WalkableGraphFactory; import com.google.devtools.build.skyframe.state.StateMachineEvaluatorForTesting; @@ -725,7 +726,9 @@ private ImmutableMap skyFunctions() { map.put( SkyFunctions.PARSED_FLAGS, new ParsedFlagsFunction(ruleClassProvider.getFragmentRegistry().getOptionsClasses())); - map.put(SkyFunctions.BASELINE_OPTIONS, new BaselineOptionsFunction()); + map.put( + SkyFunctions.BASELINE_OPTIONS, + new BaselineOptionsFunction(getMinimalVersionForBaselineOptionsFunction())); map.put( SkyFunctions.STARLARK_BUILD_SETTINGS_DETAILS, new StarlarkBuildSettingsDetailsFunction()); map.put(SkyFunctions.WORKSPACE_NAME, new WorkspaceNameFunction(ruleClassProvider)); @@ -836,6 +839,10 @@ protected SkyFunction newDirectoryListingStateFunction() { return new DirectoryListingStateFunction(externalFilesHelper, syscallCache); } + protected Version getMinimalVersionForBaselineOptionsFunction() { + return Version.minimal(); + } + protected SkyFunction newActionExecutionFunction() { return new ActionExecutionFunction( actionRewindStrategy, diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/config/BaselineOptionsFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/config/BaselineOptionsFunction.java index 7768e0b3a25b1b..c7f255298dba1d 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/config/BaselineOptionsFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/config/BaselineOptionsFunction.java @@ -13,6 +13,8 @@ // limitations under the License. package com.google.devtools.build.lib.skyframe.config; +import static com.google.common.base.Preconditions.checkNotNull; + import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.analysis.PlatformOptions; import com.google.devtools.build.lib.analysis.config.BuildOptions; @@ -33,16 +35,26 @@ import com.google.devtools.build.skyframe.SkyFunctionException; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; +import com.google.devtools.build.skyframe.Version; import com.google.devtools.common.options.OptionsParsingException; import java.util.Optional; import javax.annotation.Nullable; /** A builder for {@link BaselineOptionsValue} instances. */ public final class BaselineOptionsFunction implements SkyFunction { + + private final Version minimalVersionToInject; + + public BaselineOptionsFunction(Version minimalVersionToInject) { + this.minimalVersionToInject = checkNotNull(minimalVersionToInject); + } + @Override @Nullable public SkyValue compute(SkyKey skyKey, Environment env) throws InterruptedException, BaselineOptionsFunctionException { + env.injectVersionForNonHermeticFunction(minimalVersionToInject); + BaselineOptionsValue.Key key = (BaselineOptionsValue.Key) skyKey.argument(); BuildOptions rawBaselineOptions = PrecomputedValue.BASELINE_CONFIGURATION.get(env);