Skip to content

Commit

Permalink
Make incompatible_require_ctx_in_configure_features flag no-op, it ha…
Browse files Browse the repository at this point in the history
…s been flipped

for a while.

PiperOrigin-RevId: 588730664
Change-Id: I7e1cfbf35557a5f54d13844fddd9f00e9ba04aba
  • Loading branch information
buildbreaker2021 authored and copybara-github committed Dec 7, 2023
1 parent 5b52f01 commit bc883d8
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -649,14 +649,7 @@ private static List<String> computeCcFlagsFromFeatureConfig(
throws RuleErrorException, InterruptedException {
FeatureConfiguration featureConfiguration = null;
CppConfiguration cppConfiguration;
if (toolchainProvider.requireCtxInConfigureFeatures()) {
// When --incompatible_require_ctx_in_configure_features is flipped, this whole method will go
// away. But I'm keeping it there so we can experiment with flags before they are flipped.
cppConfiguration = ruleContext.getFragment(CppConfiguration.class);
} else {
cppConfiguration =
toolchainProvider.getCppConfigurationEvenThoughItCanBeDifferentThanWhatTargetHas();
}
cppConfiguration = ruleContext.getFragment(CppConfiguration.class);
try {
featureConfiguration =
configureFeaturesOrThrowEvalException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,10 @@ public FeatureConfigurationForStarlark configureFeatures(
final CppConfiguration cppConfiguration;
final BuildOptions buildOptions;
if (ruleContext == null) {
if (toolchain.requireCtxInConfigureFeatures()) {
throw Starlark.errorf(
"Incompatible flag --incompatible_require_ctx_in_configure_features has been flipped, "
+ "and the mandatory parameter 'ctx' of cc_common.configure_features is missing. "
+ "Please add 'ctx' as a named parameter. See "
+ "https://github.com/bazelbuild/bazel/issues/7793 for details.");
}
cppConfiguration = toolchain.getCppConfigurationEvenThoughItCanBeDifferentThanWhatTargetHas();
buildOptions = null;
throw Starlark.errorf(
"Mandatory parameter 'ctx' of cc_common.configure_features is missing. "
+ "Please add 'ctx' as a named parameter. See "
+ "https://github.com/bazelbuild/bazel/issues/7793 for details.");
} else {
if (!ruleContext.getRuleContext().isLegalFragment(CppConfiguration.class)) {
throw Starlark.errorf(
Expand Down Expand Up @@ -2544,7 +2539,7 @@ public Tuple compile(
TargetUtils.getExecutionInfo(
actions.getRuleContext().getRule(),
actions.getRuleContext().isAllowTagsPropagation()),
/* shouldProcessHeaders= */ ccToolchainProvider.shouldProcessHeaders(
/* shouldProcessHeaders= */ CcToolchainProvider.shouldProcessHeaders(
featureConfiguration.getFeatureConfiguration(),
configuration.getFragment(CppConfiguration.class)));
boolean tuple =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1060,11 +1060,6 @@ public PathFragment getDefaultSysroot() {
return defaultSysroot;
}

public boolean requireCtxInConfigureFeatures() {
return getCppConfigurationEvenThoughItCanBeDifferentThanWhatTargetHas()
.requireCtxInConfigureFeatures();
}

@VisibleForTesting
NestedSet<Artifact> getStaticRuntimeLibForTesting() {
return staticRuntimeLinkInputs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,6 @@ public boolean dontEnableHostNonhost() {
return cppOptions.dontEnableHostNonhost;
}

public boolean requireCtxInConfigureFeatures() {
return cppOptions.requireCtxInConfigureFeatures;
}

public boolean collectCodeCoverage() {
return collectCodeCoverage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,11 +809,9 @@ public Label getMemProfProfileLabel() {
name = "incompatible_require_ctx_in_configure_features",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.TOOLCHAIN,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
effectTags = {OptionEffectTag.NO_OP},
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
help =
"If true, Bazel will require 'ctx' parameter in to cc_common.configure_features "
+ "(see https://github.com/bazelbuild/bazel/issues/7793 for more information).")
help = "This flag is a noop and scheduled for removal.")
public boolean requireCtxInConfigureFeatures;

@Option(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ public void testFeatureConfigurationRequiresCtx() throws Exception {
reporter.removeHandler(failFastHandler);

getConfiguredTarget("//a:r");
assertContainsEvent("mandatory parameter 'ctx' of cc_common.configure_features is missing");
assertContainsEvent("Mandatory parameter 'ctx' of cc_common.configure_features is missing");
}

@Test
Expand Down

0 comments on commit bc883d8

Please sign in to comment.