Skip to content

Flip --incompatible_enable_cc_toolchain_resolution #19441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ public Label getMemProfProfileLabel() {

@Option(
name = "incompatible_enable_cc_toolchain_resolution",
defaultValue = "false",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class CcToolchainSuiteTest extends BuildViewTestCase {
@Test
public void testInvalidCpu() throws Exception {
reporter.removeHandler(failFastHandler);
useConfiguration("--cpu=bogus");
useConfiguration("--cpu=bogus", "--noincompatible_enable_cc_toolchain_resolution");
getConfiguredTarget(
ruleClassProvider.getToolsRepository() + "//tools/cpp:current_cc_toolchain");
assertContainsEvent("does not contain a toolchain for cpu 'bogus'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5763,7 +5763,10 @@ private static void createFiles(
bzlFilePath + "/extension.bzl",
"load('//myinfo:myinfo.bzl', 'MyInfo')",
"def _cc_aspect_impl(target, ctx):",
" toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]",
" if ctx.attr._cc_toolchain:",
" toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]",
" else:",
" toolchain = ctx.toolchains['@bazel_tools//tools/cpp:toolchain_type'].cc",
" feature_configuration = cc_common.configure_features(",
" ctx = ctx,",
" cc_toolchain = toolchain,",
Expand Down Expand Up @@ -5795,14 +5798,18 @@ private static void createFiles(
+ " '@bazel_tools//tools/cpp:current_cc_toolchain'),",
" },",
fragments,
" toolchains = ['@bazel_tools//tools/cpp:toolchain_type']",
")",
"def _cc_starlark_library_impl(ctx):",
" dep_compilation_contexts = []",
" dep_linking_contexts = []",
" for dep in ctx.attr._deps:",
" dep_compilation_contexts.append(dep[CcInfo].compilation_context)",
" dep_linking_contexts.append(dep[CcInfo].linking_context)",
" toolchain = ctx.attr._my_cc_toolchain[cc_common.CcToolchainInfo]",
" if ctx.attr._my_cc_toolchain:",
" toolchain = ctx.attr._my_cc_toolchain[cc_common.CcToolchainInfo]",
" else:",
" toolchain = ctx.toolchains['@bazel_tools//tools/cpp:toolchain_type'].cc",
" feature_configuration = cc_common.configure_features(",
" ctx = ctx,",
" cc_toolchain=toolchain,",
Expand Down Expand Up @@ -5866,6 +5873,7 @@ private static void createFiles(
" configuration_field(fragment = 'cpp', name = 'cc_toolchain'))",
" },",
fragments,
" toolchains = ['@bazel_tools//tools/cpp:toolchain_type']",
")");
scratch.file(
"foo/BUILD",
Expand Down Expand Up @@ -6369,7 +6377,10 @@ private static void createCcBinRule(
extensionDirectory + "/extension.bzl",
"load('//myinfo:myinfo.bzl', 'MyInfo')",
"def _cc_bin_impl(ctx):",
" toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]",
" if ctx.attr._cc_toolchain:",
" toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]",
" else:",
" toolchain = ctx.toolchains['@bazel_tools//tools/cpp:toolchain_type'].cc",
" feature_configuration = cc_common.configure_features(",
" ctx = ctx,",
" cc_toolchain = toolchain,",
Expand Down Expand Up @@ -6406,6 +6417,7 @@ private static void createCcBinRule(
" 'additional_outputs': attr.output_list(),",
" },",
fragments,
" toolchains = ['@bazel_tools//tools/cpp:toolchain_type']",
")");
}

Expand Down Expand Up @@ -8175,14 +8187,19 @@ public void testGrepIncludesIsSetToNullInsideCcToolchain() throws Exception {
scratch.file(
"foo/extension.bzl",
"def _cc_skylark_library_impl(ctx):",
" return [ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]]",
" if ctx.attr._cc_toolchain:",
" toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]",
" else:",
" toolchain = ctx.toolchains['@bazel_tools//tools/cpp:toolchain_type'].cc",
" return [toolchain]",
"cc_skylark_library = rule(",
" implementation = _cc_skylark_library_impl,",
" attrs = {",
" '_cc_toolchain': attr.label(default =",
" configuration_field(fragment = 'cpp', name = 'cc_toolchain')),",
" },",
" fragments = ['cpp'],",
" toolchains = ['@bazel_tools//tools/cpp:toolchain_type']",
")");

ConfiguredTarget target = getConfiguredTarget("//foo:skylark_lib");
Expand Down