From c0aca0607bf87187b1f34c55ea030660b1170398 Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 14 Mar 2018 10:57:47 -0700 Subject: [PATCH] Bazel: add ar_files/as_files to cc_toolchain targets These are mostly tests. This is a step toward making the ar_files/as_files attributes mandatory. RELNOTES: None. PiperOrigin-RevId: 189052327 --- .../android_ndk_cc_toolchain_template.txt | 2 ++ .../build/lib/analysis/LicensingTests.java | 2 ++ .../lib/packages/util/BazelMockCcSupport.java | 14 ++++---- .../build/lib/packages/util/Crosstool.java | 4 ++- .../lib/packages/util/MockObjcSupport.java | 2 ++ .../cpp/CcLibraryConfiguredTargetTest.java | 2 ++ .../rules/cpp/CcToolchainSelectionTest.java | 2 ++ .../lib/rules/cpp/CcToolchainSuiteTest.java | 12 +++++++ .../build/lib/rules/cpp/CcToolchainTest.java | 34 +++++++++++++++++++ .../tools/arm_compiler/BUILD.linaro | 4 +++ 10 files changed, 70 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_template.txt index b36534df35cb11..2019792fd335a5 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_template.txt +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_template.txt @@ -5,6 +5,8 @@ cc_toolchain( name = "%toolchainName%", all_files = ":%toolchainName%-all_files", + ar_files = ":%toolchainName%-all_files", + as_files = ":%toolchainName%-all_files", compiler_files = ":%toolchainName%-all_files", cpu = "%cpu%", dwp_files = ":%toolchainName%-all_files", diff --git a/src/test/java/com/google/devtools/build/lib/analysis/LicensingTests.java b/src/test/java/com/google/devtools/build/lib/analysis/LicensingTests.java index 7553068c3632d9..99d577789e6556 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/LicensingTests.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/LicensingTests.java @@ -457,6 +457,8 @@ public void testCcToolchainLicenseOverride() throws Exception { " name = 'c',", " output_licenses = ['notice'],", " cpu = 'cherry',", + " ar_files = 'ar-cherry',", + " as_files = 'as-cherry',", " compiler_files = 'compile-cherry',", " dwp_files = 'dwp-cherry',", " coverage_files = 'gcov-cherry',", diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/BazelMockCcSupport.java b/src/test/java/com/google/devtools/build/lib/packages/util/BazelMockCcSupport.java index 6f94f5a852b1cf..9408a49b42594c 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/util/BazelMockCcSupport.java +++ b/src/test/java/com/google/devtools/build/lib/packages/util/BazelMockCcSupport.java @@ -95,14 +95,14 @@ public void setup(MockToolsConfig config) throws IOException { "cc_toolchain(name = 'cc-compiler-k8', all_files = ':empty', compiler_files = ':empty',", " cpu = 'k8', compiler = 'compiler', libc = 'local', dwp_files = ':empty',", " dynamic_runtime_libs = [':empty'], ", - " linker_files = ':empty',", + " ar_files = ':empty', as_files = ':empty', linker_files = ':empty',", " module_map = 'crosstool.cppmap', supports_header_parsing = 1,", " objcopy_files = ':empty', static_runtime_libs = [':empty'], strip_files = ':empty',", ")", "cc_toolchain(name = 'cc-compiler-ppc', all_files = ':empty', compiler_files = ':empty',", " cpu = 'ppc', compiler = 'compiler', libc = 'local', dwp_files = ':empty',", " dynamic_runtime_libs = [':empty'], ", - " linker_files = ':empty',", + " ar_files = ':empty', as_files = ':empty', linker_files = ':empty',", " module_map = 'crosstool.cppmap', supports_header_parsing = 1,", " objcopy_files = ':empty', static_runtime_libs = [':empty'], strip_files = ':empty',", ")", @@ -110,7 +110,7 @@ public void setup(MockToolsConfig config) throws IOException { " compiler_files = ':compiler-files-piii',", " cpu = 'piii', compiler = 'compiler', libc = 'local', dwp_files = ':empty',", " dynamic_runtime_libs = [':empty'], ", - " linker_files = ':empty',", + " ar_files = ':empty', as_files = ':empty', linker_files = ':empty',", " module_map = 'crosstool.cppmap', supports_header_parsing = 1,", " objcopy_files = ':empty', static_runtime_libs = [':empty'], strip_files = ':empty',", ")", @@ -118,7 +118,7 @@ public void setup(MockToolsConfig config) throws IOException { " compiler_files = ':empty',", " cpu = 'darwin', compiler = 'compiler', libc = 'macosx', dwp_files = ':empty',", " dynamic_runtime_libs = [':empty'], ", - " linker_files = ':empty',", + " ar_files = ':empty', as_files = ':empty', linker_files = ':empty',", " module_map = 'crosstool.cppmap', supports_header_parsing = 1,", " objcopy_files = ':empty', static_runtime_libs = [':empty'], strip_files = ':empty',", ")", @@ -126,7 +126,7 @@ public void setup(MockToolsConfig config) throws IOException { " compiler_files = ':empty',", " cpu = 'ios_x86_64', compiler = 'compiler', libc = 'local', dwp_files = ':empty',", " dynamic_runtime_libs = [':empty'], ", - " linker_files = ':empty',", + " ar_files = ':empty', as_files = ':empty', linker_files = ':empty',", " module_map = 'crosstool.cppmap', supports_header_parsing = 1,", " objcopy_files = ':empty', static_runtime_libs = [':empty'], strip_files = ':empty',", ")", @@ -135,7 +135,7 @@ public void setup(MockToolsConfig config) throws IOException { " cpu = 'armeabi-v7a', compiler = 'compiler', libc = 'armeabi-v7a', ", " dwp_files = ':empty',", " dynamic_runtime_libs = [':empty'], ", - " linker_files = ':empty',", + " ar_files = ':empty', as_files = ':empty', linker_files = ':empty',", " module_map = 'crosstool.cppmap', supports_header_parsing = 1,", " objcopy_files = ':empty', static_runtime_libs = [':empty'], strip_files = ':empty',", ")", @@ -144,7 +144,7 @@ public void setup(MockToolsConfig config) throws IOException { " cpu = 'x64_windows', compiler = 'windows_msys64', libc = 'local', ", " dwp_files = ':empty',", " dynamic_runtime_libs = [':empty'], ", - " linker_files = ':empty',", + " ar_files = ':empty', as_files = ':empty', linker_files = ':empty',", " module_map = 'crosstool.cppmap', supports_header_parsing = 1,", " objcopy_files = ':empty', static_runtime_libs = [':empty'], strip_files = ':empty',", ")", diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/Crosstool.java b/src/test/java/com/google/devtools/build/lib/packages/util/Crosstool.java index 1f51043e4945e3..09e86633bb6d3c 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/util/Crosstool.java +++ b/src/test/java/com/google/devtools/build/lib/packages/util/Crosstool.java @@ -29,7 +29,7 @@ */ final class Crosstool { private static final ImmutableList CROSSTOOL_BINARIES = - ImmutableList.of("compile", "dwp", "link", "objcopy"); + ImmutableList.of("ar", "as", "compile", "dwp", "link", "objcopy"); private final MockToolsConfig config; @@ -141,6 +141,8 @@ public void write() throws IOException { " cpu = '" + arch + "',", " compiler = 'gcc-4.4.0',", " libc = 'glibc-2.3.6-grte',", + " ar_files = 'ar-" + arch + "',", + " as_files = 'as-" + arch + "',", " compiler_files = 'compile-" + arch + "',", " dwp_files = 'dwp-" + arch + "',", " linker_files = 'link-" + arch + "',", diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java b/src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java index 5bf57cfefa6bfd..7b00131830b33f 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java +++ b/src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java @@ -293,6 +293,8 @@ public static void createCrosstoolPackage( "apple_cc_toolchain(", " name = 'cc-compiler-" + arch + "',", " all_files = ':empty',", + " ar_files = ':empty',", + " as_files = ':empty',", " compiler_files = ':empty',", " cpu = 'ios',", " dwp_files = ':empty',", diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java index d249fb1f84fb8d..c2cef00e5b1426 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java @@ -180,6 +180,8 @@ public void testFilesToBuildWithoutDSO() throws Exception { " name = 'cc-compiler-k8',", " output_licenses = ['unencumbered'],", " cpu = 'k8',", + " ar_files = ':empty',", + " as_files = ':empty',", " compiler_files = ':empty',", " dwp_files = ':empty',", " coverage_files = ':empty',", diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java index ff807fa369290c..2a67f8c0055697 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java @@ -159,6 +159,8 @@ public void testIncompleteCcToolchain() throws Exception { "cc_toolchain(", " name = 'incomplete_cc-compiler-piii',", " cpu = 'piii',", + " ar_files = 'ar-piii',", + " as_files = 'as-piii',", " compiler_files = 'compile-piii',", " dwp_files = 'dwp-piii',", " linker_files = 'link-piii',", diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSuiteTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSuiteTest.java index 71d0ab37f620fa..db890c891eb7c2 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSuiteTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSuiteTest.java @@ -75,6 +75,7 @@ public void testFilesToBuild() throws Exception { " default_grte_top: '//cc:grtetop'", " tool_path { name: 'cpu-compiler', path: 'k8/compiler' }", " tool_path { name: 'ar', path: 'k8/ar' }", + " tool_path { name: 'as', path: 'k8/as' }", " tool_path { name: 'cpp', path: 'k8/cpp' }", " tool_path { name: 'gcc', path: 'k8/gcc' }", " tool_path { name: 'gcov', path: 'k8/gcov' }", @@ -97,6 +98,7 @@ public void testFilesToBuild() throws Exception { " default_grte_top: '//cc:grtetop'", " tool_path { name: 'darwin-compiler', path: 'darwin/compiler' }", " tool_path { name: 'ar', path: 'darwin/ar' }", + " tool_path { name: 'as', path: 'darwin/as' }", " tool_path { name: 'cpp', path: 'darwin/cpp' }", " tool_path { name: 'gcc', path: 'darwin/gcc' }", " tool_path { name: 'gcov', path: 'darwin/gcov' }", @@ -119,6 +121,7 @@ public void testFilesToBuild() throws Exception { " default_grte_top: '//cc:grtetop'", " tool_path { name: 'windows-compiler', path: 'windows/compiler' }", " tool_path { name: 'ar', path: 'windows/ar' }", + " tool_path { name: 'as', path: 'windows/as' }", " tool_path { name: 'cpp', path: 'windows/cpp' }", " tool_path { name: 'gcc', path: 'windows/gcc' }", " tool_path { name: 'gcov', path: 'windows/gcov' }", @@ -139,6 +142,7 @@ public void testFilesToBuild() throws Exception { " target_system_name: 'local'", " toolchain_identifier: 'local_linux'", " tool_path { name: 'ar' path: '/usr/bin/ar' }", + " tool_path { name: 'as' path: '/usr/bin/as' }", " tool_path { name: 'compat-ld' path: '/usr/bin/ld' }", " tool_path { name: 'cpp' path: '/usr/bin/cpp' }", " tool_path { name: 'dwp' path: '/usr/bin/dwp' }", @@ -155,6 +159,8 @@ public void testFilesToBuild() throws Exception { " name = 'k8-toolchain',", " module_map = 'map',", " cpu = 'cpu',", + " ar_files = 'ar',", + " as_files = 'as',", " compiler_files = 'compile',", " dwp_files = 'dwp',", " coverage_files = 'gcov',", @@ -172,6 +178,8 @@ public void testFilesToBuild() throws Exception { " name = 'darwin-toolchain',", " module_map = 'map',", " cpu = 'cpu',", + " ar_files = 'ar',", + " as_files = 'as',", " compiler_files = 'compile',", " dwp_files = 'dwp',", " coverage_files = 'gcov',", @@ -188,6 +196,8 @@ public void testFilesToBuild() throws Exception { " name = 'windows-toolchain',", " module_map = 'map',", " cpu = 'cpu',", + " ar_files = 'ar',", + " as_files = 'as',", " compiler_files = 'compile',", " dwp_files = 'dwp',", " coverage_files = 'gcov',", @@ -204,6 +214,8 @@ public void testFilesToBuild() throws Exception { " name = 'local_linux',", " module_map = 'map',", " cpu = 'cpu',", + " ar_files = 'ar',", + " as_files = 'as',", " compiler_files = 'compile',", " dwp_files = 'dwp',", " coverage_files = 'gcov',", diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java index 2d98b517bf8505..c4afac299f2663 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java @@ -56,6 +56,8 @@ public void testFilesToBuild() throws Exception { " name = 'b',", " cpu = 'banana',", " all_files = ':banana',", + " ar_files = ':empty',", + " as_files = ':empty',", " compiler_files = ':empty',", " dwp_files = ':empty',", " linker_files = ':empty',", @@ -82,6 +84,8 @@ public void testInterfaceSharedObjects() throws Exception { " name = 'b',", " cpu = 'banana',", " all_files = ':banana',", + " ar_files = ':empty',", + " as_files = ':empty',", " compiler_files = ':empty',", " dwp_files = ':empty',", " linker_files = ':empty',", @@ -152,6 +156,8 @@ public void testFission() throws Exception { " name = 'b',", " cpu = 'banana',", " all_files = ':banana',", + " ar_files = ':empty',", + " as_files = ':empty',", " compiler_files = ':empty',", " dwp_files = ':empty',", " linker_files = ':empty',", @@ -281,6 +287,8 @@ public void testPic() throws Exception { " name = 'b',", " cpu = 'banana',", " all_files = ':banana',", + " ar_files = ':empty',", + " as_files = ':empty',", " compiler_files = ':empty',", " dwp_files = ':empty',", " linker_files = ':empty',", @@ -331,6 +339,8 @@ public void testBadDynamicRuntimeLib() throws Exception { "cc_toolchain(", " name = 'a',", " module_map = 'map',", + " ar_files = 'ar-a',", + " as_files = 'as-a',", " cpu = 'cherry',", " compiler_files = 'compile-a',", " dwp_files = 'dwp-a',", @@ -365,6 +375,8 @@ public void testTurnOffDynamicLinkWhenLipoBinary() throws Exception { " name = 'b',", " cpu = 'banana',", " all_files = ':banana',", + " ar_files = ':empty',", + " as_files = ':empty',", " compiler_files = ':empty',", " dwp_files = ':empty',", " linker_files = ':empty',", @@ -405,6 +417,8 @@ public void testDynamicMode() throws Exception { " name = 'b',", " cpu = 'banana',", " all_files = ':banana',", + " ar_files = ':empty',", + " as_files = ':empty',", " compiler_files = ':empty',", " dwp_files = ':empty',", " linker_files = ':empty',", @@ -469,6 +483,8 @@ private void writeDummyCcToolchain() throws IOException { " name = 'b',", " cpu = 'banana',", " all_files = ':banana',", + " ar_files = ':empty',", + " as_files = ':empty',", " compiler_files = ':empty',", " dwp_files = ':empty',", " linker_files = ':empty',", @@ -604,6 +620,8 @@ public void assertInvalidIncludeDirectoryMessage(String entry, String messageReg " name = 'b',", " cpu = 'k8',", " all_files = ':banana',", + " ar_files = ':empty',", + " as_files = ':empty',", " compiler_files = ':empty',", " dwp_files = ':empty',", " linker_files = ':empty',", @@ -651,6 +669,8 @@ public void testModuleMapAttribute() throws Exception { " name = 'c',", " module_map = 'map',", " cpu = 'cherry',", + " ar_files = 'ar-cherry',", + " as_files = 'as-cherry',", " compiler_files = 'compile-cherry',", " dwp_files = 'dwp-cherry',", " coverage_files = 'gcov-cherry',", @@ -668,6 +688,8 @@ public void testModuleMapAttributeOptional() throws Exception { "cc_toolchain(", " name = 'c',", " cpu = 'cherry',", + " ar_files = 'ar-cherry',", + " as_files = 'as-cherry',", " compiler_files = 'compile-cherry',", " dwp_files = 'dwp-cherry',", " linker_files = 'link-cherry',", @@ -686,6 +708,8 @@ public void testFailWithMultipleModuleMaps() throws Exception { " name = 'c',", " module_map = ':multiple-maps',", " cpu = 'cherry',", + " ar_files = 'ar-cherry',", + " as_files = 'as-cherry',", " compiler_files = 'compile-cherry',", " dwp_files = 'dwp-cherry',", " coverage_files = 'gcov-cherry',", @@ -718,6 +742,8 @@ public void testFdoOptimizeInvalidUseGeneratedArtifact() throws Exception { " name = 'b',", " cpu = 'banana',", " all_files = ':banana',", + " ar_files = ':empty',", + " as_files = ':empty',", " compiler_files = ':empty',", " dwp_files = ':empty',", " linker_files = ':empty',", @@ -748,6 +774,8 @@ public void testFdoOptimizeUnexpectedExtension() throws Exception { " name = 'b',", " cpu = 'banana',", " all_files = ':banana',", + " ar_files = ':empty',", + " as_files = ':empty',", " compiler_files = ':empty',", " dwp_files = ':empty',", " linker_files = ':empty',", @@ -776,6 +804,8 @@ public void testFdoOptimizeNotInputFile() throws Exception { " name = 'b',", " cpu = 'banana',", " all_files = ':banana',", + " ar_files = ':empty',", + " as_files = ':empty',", " compiler_files = ':empty',", " dwp_files = ':empty',", " linker_files = ':empty',", @@ -802,6 +832,8 @@ public void testInlineCtoolchain_withoutToolchainResolution() throws Exception { " name = 'b',", " cpu = 'banana',", " all_files = ':empty',", + " ar_files = ':empty',", + " as_files = ':empty',", " compiler_files = ':empty',", " dwp_files = ':empty',", " linker_files = ':empty',", @@ -847,6 +879,8 @@ public void testInlineCtoolchain_withToolchainResolution() throws Exception { " name = 'b',", " cpu = 'banana',", " all_files = ':empty',", + " ar_files = ':empty',", + " as_files = ':empty',", " compiler_files = ':empty',", " dwp_files = ':empty',", " linker_files = ':empty',", diff --git a/src/test/shell/bazel/testdata/bazel_toolchain_test_data/tools/arm_compiler/BUILD.linaro b/src/test/shell/bazel/testdata/bazel_toolchain_test_data/tools/arm_compiler/BUILD.linaro index 9cbb2530843228..bdbd57f3ea4d66 100644 --- a/src/test/shell/bazel/testdata/bazel_toolchain_test_data/tools/arm_compiler/BUILD.linaro +++ b/src/test/shell/bazel/testdata/bazel_toolchain_test_data/tools/arm_compiler/BUILD.linaro @@ -70,6 +70,8 @@ filegroup( cc_toolchain( name = "cc-compiler-armeabi-v7a", all_files = ":linaro_linux_all_files", + ar_files = "//tools/arm_compiler/linaro_linux_gcc:ar", + as_files = "//tools/arm_compiler/linaro_linux_gcc:as", compiler_files = ":linaro_linux_compiler_files", cpu = "armeabi-v7a", dwp_files = ":empty", @@ -85,6 +87,8 @@ cc_toolchain( cc_toolchain( name = "cc-compiler-k8", all_files = ":empty", + ar_files = ":empty", + as_files = ":empty", compiler_files = ":empty", cpu = "local", dwp_files = ":empty",