Skip to content
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

Flip --incompatible_enable_cc_toolchain_resolution #19441

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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 @@ -1811,7 +1811,7 @@ public void ccCommonLink_cppLTOActionExecutesOnFirstPlatform() throws Exception
" srcs = ['custom.cc'],",
" deps = ['dep'],",
")");
useConfiguration("--incompatible_auto_exec_groups", "--features=thin_lto");
useConfiguration("--incompatible_auto_exec_groups", "--features=thin_lto", "--noincompatible_enable_cc_toolchain_resolution");
AnalysisMock.get()
.ccSupport()
.setupCcToolchainConfig(
Expand Down Expand Up @@ -1991,7 +1991,7 @@ public void ccCommonCompile_moduleActionsExecuteOnFirstPlatform() throws Excepti
" srcs = ['custom.cc'],",
" hdrs = ['custom.h'],",
")");
useConfiguration("--incompatible_auto_exec_groups", "--features=header_modules");
useConfiguration("--incompatible_auto_exec_groups", "--features=header_modules", "--noincompatible_enable_cc_toolchain_resolution");
AnalysisMock.get()
.ccSupport()
.setupCcToolchainConfig(
Expand Down Expand Up @@ -2061,7 +2061,8 @@ public void ccCommonCompile_codeGenModuleActionExecutesOnFirstPlatform() throws
useConfiguration(
"--incompatible_auto_exec_groups",
"--features=header_modules",
"--features=header_module_codegen");
"--features=header_module_codegen",
"--noincompatible_enable_cc_toolchain_resolution");
AnalysisMock.get()
.ccSupport()
.setupCcToolchainConfig(
Expand Down Expand Up @@ -2126,7 +2127,7 @@ public void ccCommonCompile_compileHeaderActionExecutesOnFirstPlatform() throws
" srcs = ['custom.cc'],",
" hdrs = ['custom.h'],",
")");
useConfiguration("--incompatible_auto_exec_groups", "--features=parse_headers");
useConfiguration("--incompatible_auto_exec_groups", "--features=parse_headers", "--noincompatible_enable_cc_toolchain_resolution");
AnalysisMock.get()
.ccSupport()
.setupCcToolchainConfig(
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
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public void aspectsPropagatingForDefaultAndImplicit() throws Exception {

assertThat(names).containsAtLeast("xxx", "yyy");
// 3-4 is the C++ toolchain and alias; its name changes between Blaze and Bazel.
assertThat(names).hasSize(4);
assertThat(names).hasSize(3);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ public void testJavaLauncherConfiguration() throws Exception {

@Test
public void testHostCrosstoolTop() throws Exception {
BuildConfigurationValue config = createConfiguration();
BuildConfigurationValue config = createConfiguration("--noincompatible_enable_cc_toolchain_resolution");
assertThat(config.getFragment(CppConfiguration.class).getRuleProvidingCcToolchainProvider())
.isEqualTo(
Label.parseCanonicalUnchecked(
TestConstants.TOOLS_REPOSITORY + "//tools/cpp:toolchain"));

BuildConfigurationValue execConfig = createExec();
BuildConfigurationValue execConfig = createExec("--noincompatible_enable_cc_toolchain_resolution");
assertThat(execConfig.getFragment(CppConfiguration.class).getRuleProvidingCcToolchainProvider())
.isEqualTo(
Label.parseCanonicalUnchecked(
Expand Down