diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java index c66995b6d7de5a..c9ace413bdbeaf 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java @@ -693,7 +693,7 @@ public Label getFdoPrefetchHintsLabel() { @Option( name = "incompatible_disable_cc_configuration_make_variables", - defaultValue = "false", + defaultValue = "true", documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, effectTags = {OptionEffectTag.UNKNOWN}, metadataTags = { diff --git a/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java b/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java index 3ae1f027f047aa..d56890a8b24e43 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java @@ -117,12 +117,6 @@ public void testHostCrosstoolTop() throws Exception { Label.parseAbsoluteUnchecked("//third_party/crosstool/mock:cc-compiler-k8-gcc-4.4.0")); } - @Test - public void testMakeEnvFlags() throws Exception { - BuildConfiguration config = create(); - assertThat(config.getMakeEnvironment().get("STRIP")).contains("strip"); - } - @Test public void testCaching() throws Exception { BuildConfiguration.Options a = Options.getDefaults(BuildConfiguration.Options.class); diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderTest.java index b510f5b8931abf..882e429a8bd0ed 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderTest.java @@ -17,9 +17,11 @@ 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; @@ -301,4 +303,100 @@ 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 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(); + } } diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java index 3c67a76d2b8cc9..3c06f353f37149 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java @@ -964,26 +964,4 @@ 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 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"); - } } diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java index 16d5735184a3b9..5521b9c0999d1b 100644 --- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java +++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java @@ -783,9 +783,10 @@ private void setUpMakeVarToolchain() throws Exception { "vars/BUILD", "load(':vars.bzl', 'make_var_supplier', 'make_var_user')", "make_var_supplier(name = 'supplier', value = 'foo')", + "cc_toolchain_alias(name = 'current_cc_toolchain')", "make_var_user(", " name = 'vars',", - " toolchains = [':supplier'],", + " toolchains = [':supplier', ':current_cc_toolchain'],", ")"); }