From d2f8077b1a37c857dabd5ac63a621bc9d2756f5b Mon Sep 17 00:00:00 2001 From: rosica Date: Tue, 4 Jun 2019 01:47:17 -0700 Subject: [PATCH] Add --incompatible_disable_static_cc_toolchains that will deprecate the cc_toolchain_suite and cc_toolchain rules under @bazel_tools//tools/cpp. Issue #8546 RELNOTES: None. PiperOrigin-RevId: 251395406 --- .../build/lib/rules/cpp/CppOptions.java | 15 +++++++++++ tools/cpp/BUILD | 27 +++++++++++++++++++ tools/cpp/cc_toolchain_config.bzl | 5 ++++ 3 files changed, 47 insertions(+) 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 91641f628c8422..eb27d8a5e8c951 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 @@ -889,6 +889,20 @@ public Label getFdoPrefetchHintsLabel() { + "actions. See https://github.com/bazelbuild/bazel/issues/8531") public boolean useSpecificToolFiles; + @Option( + name = "incompatible_disable_static_cc_toolchains", + defaultValue = "false", + documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, + effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, + help = + "@bazel_tools//tools/cpp:default-toolchain target was removed." + + "See https://github.com/bazelbuild/bazel/issues/8546.") + public boolean disableStaticCcToolchains; + @Override public FragmentOptions getHost() { CppOptions host = (CppOptions) getDefault(); @@ -944,6 +958,7 @@ public FragmentOptions getHost() { host.requireCtxInConfigureFeatures = requireCtxInConfigureFeatures; host.useStandaloneLtoIndexingCommandLines = useStandaloneLtoIndexingCommandLines; host.useSpecificToolFiles = useSpecificToolFiles; + host.disableStaticCcToolchains = disableStaticCcToolchains; // Save host options for further use. host.hostCoptList = hostCoptList; diff --git a/tools/cpp/BUILD b/tools/cpp/BUILD index c5e48ad0d83e87..075031023ca1f3 100644 --- a/tools/cpp/BUILD +++ b/tools/cpp/BUILD @@ -69,6 +69,13 @@ filegroup( srcs = [], ) +config_setting( + name = "disable_static_cc_toolchains", + values = { + "incompatible_disable_static_cc_toolchains": "true", + }, +) + # This is the entry point for --crosstool_top. Toolchains are found # by lopping off the name of --crosstool_top and searching for # "cc-compiler-${CPU}" in this BUILD file, where CPU is the target CPU @@ -128,6 +135,10 @@ cc_toolchain_config( name = "local_linux", compiler = "compiler", cpu = "local", + disable_static_cc_toolchains = select({ + ":disable_static_cc_toolchains": True, + "//conditions:default": False, + }), ) toolchain( @@ -269,6 +280,10 @@ cc_toolchain_config( name = "local_darwin", compiler = "compiler", cpu = "darwin", + disable_static_cc_toolchains = select({ + ":disable_static_cc_toolchains": True, + "//conditions:default": False, + }), ) toolchain( @@ -304,6 +319,10 @@ cc_toolchain_config( name = "local_freebsd", compiler = "compiler", cpu = "freebsd", + disable_static_cc_toolchains = select({ + ":disable_static_cc_toolchains": True, + "//conditions:default": False, + }), ) toolchain( @@ -339,6 +358,10 @@ cc_toolchain_config( name = "local_windows_msys64", compiler = "windows_msys64", cpu = "x64_windows", + disable_static_cc_toolchains = select({ + ":disable_static_cc_toolchains": True, + "//conditions:default": False, + }), ) toolchain( @@ -374,6 +397,10 @@ cc_toolchain_config( name = "vc_14_0_x64", compiler = "cl", cpu = "x64_windows_msvc", + disable_static_cc_toolchains = select({ + ":disable_static_cc_toolchains": True, + "//conditions:default": False, + }), ) toolchain( diff --git a/tools/cpp/cc_toolchain_config.bzl b/tools/cpp/cc_toolchain_config.bzl index 22d67d4e7c244d..c9fdb5389d5b21 100644 --- a/tools/cpp/cc_toolchain_config.bzl +++ b/tools/cpp/cc_toolchain_config.bzl @@ -99,6 +99,10 @@ all_link_actions = [ ] def _impl(ctx): + if ctx.attr.disable_static_cc_toolchains: + fail("@bazel_tools//tools/cpp:default-toolchain, as well as the cc_toolchains it points " + + "to have been removed. See https://github.com/bazelbuild/bazel/issues/8546.") + if (ctx.attr.cpu == "darwin"): toolchain_identifier = "local_darwin" elif (ctx.attr.cpu == "freebsd"): @@ -1482,6 +1486,7 @@ cc_toolchain_config = rule( attrs = { "cpu": attr.string(mandatory = True), "compiler": attr.string(), + "disable_static_cc_toolchains": attr.bool(), }, provides = [CcToolchainConfigInfo], executable = True,