Skip to content

Commit

Permalink
Make BaselineOptionsFunction non-hermetic and inject minimal versio…
Browse files Browse the repository at this point in the history
…n as the mtsv. This also means any dep mtsv of the `BaselineOptionsValue.Key` will be ignored.

Since the point of the `BaselineOptionsFunction` is to compute output directory names, this change should be safe.

PiperOrigin-RevId: 658478145
Change-Id: I98021683178e594599f37169251ba4b92132f19c
  • Loading branch information
Googler authored and copybara-github committed Aug 1, 2024
1 parent 1ec4365 commit 61edc46
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -725,7 +726,9 @@ private ImmutableMap<SkyFunctionName, SkyFunction> 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));
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 61edc46

Please sign in to comment.