Skip to content

Commit

Permalink
Remove --incompatible_disable_crosstool_file option
Browse files Browse the repository at this point in the history
CROSSTOOL files are permanently disallowed in Bazel. This flag was introduced to follow the incompatible changes policy (https://docs.bazel.build/versions/master/backward-compatibility.html), and has served its purpose.

See issue #5380

RELNOTES: None.
PiperOrigin-RevId: 246522041
  • Loading branch information
scentini authored and copybara-github committed May 3, 2019
1 parent 844e4e2 commit b7bbbb1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ public class BazelRulesModule extends BlazeModule {
/** This is where deprecated options go to die. */
public static class GraveyardOptions extends OptionsBase {

@Option(
name = "incompatible_disable_crosstool_file",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {
OptionMetadataTag.DEPRECATED,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES,
OptionMetadataTag.INCOMPATIBLE_CHANGE
},
help = "Deprecated no-op.")
public boolean disableCrosstool;

@Option(
name = "incompatible_disable_legacy_crosstool_fields",
oldName = "experimental_disable_legacy_crosstool_fields",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static CcToolchainProvider getCcToolchainProvider(
CToolchain toolchain = null;
CrosstoolRelease crosstoolFromCrosstoolFile = null;

if (cppConfiguration.disableCrosstool() && attributes.getCcToolchainConfigInfo() == null) {
if (attributes.getCcToolchainConfigInfo() == null) {
ruleContext.ruleError(
"cc_toolchain.toolchain_config attribute must be specified. See "
+ "https://github.com/bazelbuild/bazel/issues/7320 for details.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,6 @@ public boolean enableLegacyCcProvider() {
return !cppOptions.disableLegacyCcProvider;
}

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

public boolean dontEnableHostNonhost() {
return cppOptions.dontEnableHostNonhost;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,22 +809,6 @@ public Label getFdoPrefetchHintsLabel() {
+ "(see https://github.com/bazelbuild/bazel/issues/7008 for migration instructions).")
public boolean disableExpandIfAllAvailableInFlagSet;

@Option(
name = "incompatible_disable_crosstool_file",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.TOOLCHAIN,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES,
OptionMetadataTag.INCOMPATIBLE_CHANGE
},
help =
"If true, Bazel will not allow using the CROSSTOOL file for cc toolchain"
+ " configuration. Instead, cc_toolchain should have a toolchain_config attribute"
+ " that points to a rule written in Starlark that provides a CcToolchainConfigInfo"
+ " provider. See https://github.com/bazelbuild/bazel/issues/7320 for more info.")
public boolean disableCrosstool;

@Option(
name = "experimental_includes_attribute_subpackage_traversal",
defaultValue = "true",
Expand Down Expand Up @@ -929,7 +913,6 @@ public FragmentOptions getHost() {
host.disableExpandIfAllAvailableInFlagSet = disableExpandIfAllAvailableInFlagSet;
host.disableLegacyCcProvider = disableLegacyCcProvider;
host.removeCpuCompilerCcToolchainAttributes = removeCpuCompilerCcToolchainAttributes;
host.disableCrosstool = disableCrosstool;
host.enableCcToolchainResolution = enableCcToolchainResolution;
host.removeLegacyWholeArchive = removeLegacyWholeArchive;
host.dontEnableHostNonhost = dontEnableHostNonhost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,87 +627,4 @@ public void testSysroot_fromCrosstool_unset() throws Exception {

assertThat(toolchainProvider.getSysroot()).isEqualTo("/usr/grte/v1");
}

@Test
public void testCrosstoolNeededWhenStarlarkRuleIsNotPresent() throws Exception {
reporter.removeHandler(failFastHandler);
scratch.file("lib/BUILD", "cc_library(name = 'lib', srcs = ['a.cc'])");
getSimpleStarlarkRule(/* addToolchainConfigAttribute= */ false);

useConfiguration(
"--cpu=k8", "--crosstool_top=//a:a", "--noincompatible_disable_crosstool_file");
ConfiguredTarget target = getConfiguredTarget("//lib:lib");
// Skyframe cannot find the CROSSTOOL file
assertContainsEvent("errors encountered while analyzing target '//lib:lib'");
assertThat(target).isNull();
}

@Test
public void testCrosstoolReadWhenStarlarkRuleIsEnabledButNotPresent() throws Exception {
scratch.file("lib/BUILD", "cc_library(name = 'lib', srcs = ['a.cc'])");
getSimpleStarlarkRule(/* addToolchainConfigAttribute= */ false);

scratch.file("a/CROSSTOOL", MockCcSupport.EMPTY_CROSSTOOL);

useConfiguration(
"--cpu=k8", "--crosstool_top=//a:a", "--noincompatible_disable_crosstool_file");
ConfiguredTarget target = getConfiguredTarget("//lib:lib");
assertThat(target).isNotNull();
}

@Test
public void testCrosstoolNotNeededWhenStarlarkRuleIsEnabled() throws Exception {
scratch.file("lib/BUILD", "cc_library(name = 'lib', srcs = ['a.cc'])");
getSimpleStarlarkRule(/* addToolchainConfigAttribute= */ true);

useConfiguration("--cpu=k8", "--crosstool_top=//a:a");
// We don't have a CROSSTOOL, but we don't need it
ConfiguredTarget target = getConfiguredTarget("//lib:lib");
assertThat(target).isNotNull();
}

private void getSimpleStarlarkRule(boolean addToolchainConfigAttribute) throws IOException {
scratch.file(
"a/BUILD",
"load(':cc_toolchain_config_info.bzl', 'cc_toolchain_config_rule')",
"cc_toolchain_config_rule(name = 'toolchain_config')",
"filegroup(",
" name='empty')",
"cc_toolchain_suite(",
" name = 'a',",
" toolchains = { 'k8': ':b' },",
")",
"cc_toolchain(",
" name = 'b',",
" all_files = ':empty',",
" ar_files = ':empty',",
" as_files = ':empty',",
" compiler_files = ':empty',",
" dwp_files = ':empty',",
" linker_files = ':empty',",
" strip_files = ':empty',",
" objcopy_files = ':empty',",
" toolchain_identifier = 'mock-llvm-toolchain-k8',",
(addToolchainConfigAttribute ? " toolchain_config = ':toolchain_config'" : "") + ")");

scratch.file(
"a/cc_toolchain_config_info.bzl",
"def _impl(ctx):",
" return cc_common.create_cc_toolchain_config_info(",
" ctx = ctx,",
" toolchain_identifier = 'toolchain',",
" host_system_name = 'host',",
" target_system_name = 'target',",
" target_cpu = 'cpu',",
" target_libc = 'libc',",
" compiler = 'compiler',",
" abi_libc_version = 'abi_libc',",
" abi_version = 'banana')",
"cc_toolchain_config_rule = rule(",
" implementation = _impl,",
" attrs = {},",
" provides = [CcToolchainConfigInfo],",
" fragments = ['cpp']",
")");
}
}

0 comments on commit b7bbbb1

Please sign in to comment.