Skip to content

Commit

Permalink
Flip --incompatible_disable_legacy_flags_cc_toolchain_api
Browse files Browse the repository at this point in the history
    bazelbuild/bazel#6434

    RELNOTES: Incompatible flag --incompatible_disable_legacy_flags_cc_toolchain_api was flipped (#6434)
    PiperOrigin-RevId: 217852972
  • Loading branch information
Luca Di Grazia committed Sep 4, 2022
1 parent 8e251ca commit 76962c9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ public Label getFdoPrefetchHintsLabel() {

@Option(
name = "incompatible_disable_cc_configuration_make_variables",
defaultValue = "true",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.UNKNOWN},
metadataTags = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
import static com.google.common.truth.Truth.assertThat;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.config.CompilationMode;
import com.google.devtools.build.lib.analysis.platform.ToolchainInfo;
import com.google.devtools.build.lib.analysis.util.AnalysisMock;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig;
Expand Down Expand Up @@ -303,100 +301,4 @@ public void testDisablingLegacyCrosstoolFields() throws Exception {
assertThat(ccToolchainProvider.getTestOnlyLinkOptions())
.doesNotContain("-foo_test_only_linker_flag");
}

/*
* Crosstools should load fine with or without 'gcov-tool'. Those that define 'gcov-tool'
* should also add a make variable.
*/
@Test
public void testOptionalGcovTool() throws Exception {
// Crosstool without gcov-tool
scratch.file(
"a/BUILD",
"filegroup(",
" name='empty')",
"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',",
" dynamic_runtime_libs = [':empty'],",
" static_runtime_libs = [':empty'],",
" proto=\"\"\"",
" feature { name: 'no_legacy_features' }",
" tool_path { name: 'gcc' path: 'path-to-gcc-tool' }",
" tool_path { name: 'ar' path: 'ar' }",
" tool_path { name: 'cpp' path: 'cpp' }",
" tool_path { name: 'gcov' path: 'gcov' }",
" tool_path { name: 'ld' path: 'ld' }",
" tool_path { name: 'nm' path: 'nm' }",
" tool_path { name: 'objdump' path: 'objdump' }",
" tool_path { name: 'strip' path: 'strip' }",
" toolchain_identifier: \"banana\"",
" abi_version: \"banana\"",
" abi_libc_version: \"banana\"",
" compiler: \"banana\"",
" host_system_name: \"banana\"",
" target_system_name: \"banana\"",
" target_cpu: \"banana\"",
" target_libc: \"banana\"",
" \"\"\")");

CcToolchainProvider ccToolchainProvider =
(CcToolchainProvider) getConfiguredTarget("//a:a").get(ToolchainInfo.PROVIDER);
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
ccToolchainProvider.addGlobalMakeVariables(builder);
assertThat(builder.build().get("GCOVTOOL")).isNull();

// Crosstool with gcov-tool
scratch.file(
"b/BUILD",
"filegroup(",
" name='empty')",
"cc_toolchain(",
" name = 'b',",
" 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',",
" dynamic_runtime_libs = [':empty'],",
" static_runtime_libs = [':empty'],",
" proto=\"\"\"",
" feature { name: 'no_legacy_features' }",
" tool_path { name: 'gcc' path: 'path-to-gcc-tool' }",
" tool_path { name: 'gcov-tool' path: 'path-to-gcov-tool' }",
" tool_path { name: 'ar' path: 'ar' }",
" tool_path { name: 'cpp' path: 'cpp' }",
" tool_path { name: 'gcov' path: 'gcov' }",
" tool_path { name: 'ld' path: 'ld' }",
" tool_path { name: 'nm' path: 'nm' }",
" tool_path { name: 'objdump' path: 'objdump' }",
" tool_path { name: 'strip' path: 'strip' }",
" toolchain_identifier: \"banana\"",
" abi_version: \"banana\"",
" abi_libc_version: \"banana\"",
" compiler: \"banana\"",
" host_system_name: \"banana\"",
" target_system_name: \"banana\"",
" target_cpu: \"banana\"",
" target_libc: \"banana\"",
" \"\"\")");

ccToolchainProvider =
(CcToolchainProvider) getConfiguredTarget("//b:b").get(ToolchainInfo.PROVIDER);
builder = ImmutableMap.builder();
ccToolchainProvider.addGlobalMakeVariables(builder);
assertThat(builder.build().get("GCOVTOOL")).isNotNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -964,4 +964,26 @@ public void testCustomRuntimeLibraryPaths() throws Exception {
assertThat(customLibsToolchain.getDynamicRuntimeLibsLabel())
.isEqualTo(Label.create(ctTop, "dynamic-group"));
}

/*
* Crosstools should load fine with or without 'gcov-tool'. Those that define 'gcov-tool'
* should also add a make variable.
*/
@Test
public void testOptionalGcovTool() throws Exception {
// Crosstool with gcov-tool
CppConfigurationLoader loader =
loaderWithOptionalTool(" tool_path { name: \"gcov-tool\" path: \"path-to-gcov-tool\" }");
CppConfiguration cppConfig = create(loader, "--cpu=k8");
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
cppConfig.addGlobalMakeVariables(builder);
assertThat(builder.build().get("GCOVTOOL")).isNotNull();

// Crosstool without gcov-tool
loader = loaderWithOptionalTool("");
cppConfig = create(loader, "--cpu=k8");
builder = ImmutableMap.builder();
cppConfig.addGlobalMakeVariables(builder);
assertThat(builder.build()).doesNotContainKey("GCOVTOOL");
}
}

0 comments on commit 76962c9

Please sign in to comment.