From b7bbbb148111139e2b6e6e717bc28b34da723e06 Mon Sep 17 00:00:00 2001 From: rosica Date: Fri, 3 May 2019 09:32:36 -0700 Subject: [PATCH] Remove --incompatible_disable_crosstool_file option 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 --- .../lib/bazel/rules/BazelRulesModule.java | 13 +++ .../rules/cpp/CcToolchainProviderHelper.java | 2 +- .../build/lib/rules/cpp/CppConfiguration.java | 4 - .../build/lib/rules/cpp/CppOptions.java | 17 ---- .../build/lib/rules/cpp/CcToolchainTest.java | 83 ------------------- 5 files changed, 14 insertions(+), 105 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java index 54cfa35234572f..7ec405c9fcf861 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java @@ -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", diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderHelper.java index 9749e653f9995f..355820c847405c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderHelper.java @@ -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."); diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java index 62aefdaecf9b8a..3b2e0341a52207 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java @@ -635,10 +635,6 @@ public boolean enableLegacyCcProvider() { return !cppOptions.disableLegacyCcProvider; } - public boolean disableCrosstool() { - return cppOptions.disableCrosstool; - } - public boolean dontEnableHostNonhost() { return cppOptions.dontEnableHostNonhost; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java index 82ea6d3f9d88f6..85c7cef6d0b279 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java @@ -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", @@ -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; diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java index cba3bbc0f20e9f..bffc79fabccd6d 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java @@ -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']", - ")"); - } }