Skip to content

Commit

Permalink
Add --incompatible_disable_static_cc_toolchains that will deprecate t…
Browse files Browse the repository at this point in the history
…he cc_toolchain_suite and cc_toolchain rules under @bazel_tools//tools/cpp.

Issue bazelbuild#8546

RELNOTES: None.
PiperOrigin-RevId: 251395406
  • Loading branch information
scentini authored and irengrig committed Jul 15, 2019
1 parent daced9c commit 8cfbbe4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
27 changes: 27 additions & 0 deletions tools/cpp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions tools/cpp/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8cfbbe4

Please sign in to comment.