Skip to content

Commit

Permalink
Remove the command line option --incompatible_remove_cpu_and_compiler…
Browse files Browse the repository at this point in the history
…_attributes_from_cc_toolchain .

RELNOTES[INC]: The --incompatible_remove_cpu_and_compiler_attributes_from_cc_toolchain command line option is not available anymore. Using the "cpu" and "compiler" options of the cc_toolchain rule now results in a slightly different error that is signaled earlier.

PiperOrigin-RevId: 569423443
Change-Id: I66415b33baa1f469b92cfb21f7fcf0194408a362
  • Loading branch information
lberki authored and copybara-github committed Sep 29, 2023
1 parent c9edba3 commit 0567176
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ public class CcToolchainAttributesProvider extends NativeInfo implements HasCcTo
private final NestedSet<Artifact> fullInputsForCrosstool;
private final NestedSet<Artifact> fullInputsForLink;
private final NestedSet<Artifact> coverage;
private final String compiler;
private final String cpu;
private final Artifact ifsoBuilder;
private final Artifact linkDynamicLibraryTool;
@Nullable private final Artifact grepIncludes;
Expand Down Expand Up @@ -115,21 +113,12 @@ public CcToolchainAttributesProvider(
super();
this.ccToolchainLabel = ruleContext.getLabel();
this.toolchainIdentifier = ruleContext.attributes().get("toolchain_identifier", Type.STRING);
if (ruleContext.getFragment(CppConfiguration.class).removeCpuCompilerCcToolchainAttributes()
&& (ruleContext.attributes().isAttributeValueExplicitlySpecified("cpu")
|| ruleContext.attributes().isAttributeValueExplicitlySpecified("compiler"))) {
ruleContext.ruleError(
"attributes 'cpu' and 'compiler' have been deprecated, please remove them. See "
+ "https://github.com/bazelbuild/bazel/issues/7075 for details.");
}

// grep_includes is not supported by Bazel.
String toolsRepository = ruleContext.getRuleClassProvider().getToolsRepository().getName();
this.grepIncludes =
toolsRepository.isEmpty() ? ruleContext.getPrerequisiteArtifact("$grep_includes") : null;

this.cpu = ruleContext.attributes().get("cpu", Type.STRING);
this.compiler = ruleContext.attributes().get("compiler", Type.STRING);
this.supportsParamFiles = ruleContext.attributes().get("supports_param_files", BOOLEAN);
this.supportsHeaderParsing = ruleContext.attributes().get("supports_header_parsing", BOOLEAN);
this.allFiles = getFiles(ruleContext, "all_files");
Expand Down Expand Up @@ -265,10 +254,6 @@ public StarlarkFunction getBuildVarsFunc(StarlarkThread thread) throws EvalExcep
return ccToolchainBuildVariablesFunc;
}

public String getCpu() {
return cpu;
}

public boolean isSupportsParamFiles() {
return supportsParamFiles;
}
Expand Down Expand Up @@ -562,10 +547,6 @@ public Label getTargetLibcTopLabel() {
return getTargetLibcTop() == null ? null : getTargetLibcTop().getLabel();
}

public String getCompiler() {
return compiler;
}

public Artifact getIfsoBuilder() {
return ifsoBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,6 @@ public boolean useLLVMCoverageMapFormat() {
return cppOptions.useLLVMCoverageMapFormat;
}

public boolean removeCpuCompilerCcToolchainAttributes() {
return cppOptions.removeCpuCompilerCcToolchainAttributes;
}

@Nullable
public static PathFragment computeDefaultSysroot(String builtInSysroot) {
if (builtInSysroot.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,18 +851,6 @@ public Label getMemProfProfileLabel() {
+ "(see https://github.com/bazelbuild/bazel/issues/7362 for migration instructions).")
public boolean removeLegacyWholeArchive;

@Option(
name = "incompatible_remove_cpu_and_compiler_attributes_from_cc_toolchain",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.TOOLCHAIN,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
help =
"If true, Bazel will complain when cc_toolchain.cpu and cc_toolchain.compiler attributes "
+ "are set "
+ "(see https://github.com/bazelbuild/bazel/issues/7075 for migration instructions).")
public boolean removeCpuCompilerCcToolchainAttributes;

@Option(
name = "incompatible_disable_legacy_cc_provider",
defaultValue = "true",
Expand Down Expand Up @@ -1189,7 +1177,6 @@ public FragmentOptions getExec() {
exec.inmemoryDotdFiles = inmemoryDotdFiles;

exec.disableLegacyCcProvider = disableLegacyCcProvider;
exec.removeCpuCompilerCcToolchainAttributes = removeCpuCompilerCcToolchainAttributes;
exec.enableCcToolchainResolution = enableCcToolchainResolution;
exec.removeLegacyWholeArchive = removeLegacyWholeArchive;
exec.dontEnableHostNonhost = dontEnableHostNonhost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ CcToolchainConfigInfo = _builtins.toplevel.CcToolchainConfigInfo
MemProfProfileInfo = _builtins.internal.MemProfProfileInfo

cc_toolchain_attrs_exec = {
"cpu": attr.string(),
"compiler": attr.string(),
# buildifier: disable=attr-license
"licenses": attr.license() if hasattr(attr, "license") else attr.string_list(),
# buildifier: disable=attr-license
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,99 +91,6 @@ public void testStarlarkCallables() throws Exception {
assertThat(usePicForDynamicLibraries).isTrue();
}

@Test
public void testRemoveCpuAndCompiler() throws Exception {
scratch.file(
"a/BUILD",
"load(':cc_toolchain_config.bzl', 'cc_toolchain_config')",
"filegroup(name = 'empty')",
"cc_toolchain_suite(",
" name = 'a_suite',",
" toolchains = { 'k8': ':a' },",
")",
"cc_toolchain_suite(",
" name = 'b_suite',",
" toolchains = { 'k9': ':b', },",
")",
"cc_toolchain_suite(",
" name = 'c_suite',",
" toolchains = { 'k10': ':c', },",
")",
"cc_toolchain(",
" name = 'a',",
" cpu = 'banana',",
" 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 = 'banana',",
" toolchain_config = ':banana_config',",
")",
"cc_toolchain(",
" name = 'b',",
" compiler = 'banana',",
" 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 = 'banana',",
" toolchain_config = ':banana_config',",
")",
"cc_toolchain(",
" name = 'c',",
" 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 = 'banana',",
" toolchain_config = ':banana_config',",
")",
"cc_toolchain_config(name = 'banana_config')");

scratch.file("a/cc_toolchain_config.bzl", MockCcSupport.EMPTY_CC_TOOLCHAIN);

reporter.removeHandler(failFastHandler);
useConfiguration(
"--crosstool_top=//a:a_suite",
"--cpu=k8",
"--host_cpu=k8",
"--incompatible_remove_cpu_and_compiler_attributes_from_cc_toolchain");
assertThat(getConfiguredTarget("//a:a_suite")).isNull();
assertContainsEvent(
"attributes 'cpu' and 'compiler' have been deprecated, please remove them.");
eventCollector.clear();

useConfiguration(
"--crosstool_top=//a:b_suite",
"--cpu=k9",
"--host_cpu=k9",
"--incompatible_remove_cpu_and_compiler_attributes_from_cc_toolchain");
assertThat(getConfiguredTarget("//a:b_suite")).isNull();
assertContainsEvent(
"attributes 'cpu' and 'compiler' have been deprecated, please remove them.");
eventCollector.clear();

useConfiguration(
"--crosstool_top=//a:c_suite",
"--cpu=k10",
"--host_cpu=k10",
"--incompatible_remove_cpu_and_compiler_attributes_from_cc_toolchain");
getConfiguredTarget("//a:c_suite");
assertNoEvents();
}

@Test
public void testToolchainAndSuiteDifferentPackages() throws Exception {
scratch.file(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ public void testFailWithMultipleModuleMaps() throws Exception {
" toolchain_identifier = 'toolchain-identifier-k8',",
" toolchain_config = ':toolchain_config',",
" module_map = ':multiple-maps',",
" cpu = 'cherry',",
" ar_files = 'ar-cherry',",
" as_files = 'as-cherry',",
" compiler_files = 'compile-cherry',",
Expand Down

0 comments on commit 0567176

Please sign in to comment.