From 4c4c1be915cc00cb5835cd187ee9382c52bac28a Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 10 Feb 2022 11:41:18 -0800 Subject: [PATCH] Use single module for clang runtime libraries The clang prebuilts now provide a single module with per-architecture variants instead of a module per architecture. Bug: 220019988 Test: m checkbuild Change-Id: I39e2cf8ae14edf8510276dab38011afaef85822c Merged-In: I39e2cf8ae14edf8510276dab38011afaef85822c --- apex/apex.go | 2 +- apex/apex_test.go | 10 +++-- cc/cc.go | 2 +- cc/cc_test.go | 4 +- cc/config/toolchain.go | 9 +---- cc/sanitize_test.go | 6 +-- cc/testing.go | 78 ++++-------------------------------- cc/vndk.go | 2 +- rust/config/toolchain.go | 9 +---- rust/testing.go | 4 +- rust/vendor_snapshot_test.go | 25 ++++-------- 11 files changed, 32 insertions(+), 119 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index 9031a4ea9..ac67feea2 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1415,7 +1415,7 @@ func (a *apexBundle) AddSanitizerDependencies(ctx android.BottomUpMutatorContext for _, target := range ctx.MultiTargets() { if target.Arch.ArchType.Multilib == "lib64" { addDependenciesForNativeModules(ctx, ApexNativeDependencies{ - Native_shared_libs: []string{"libclang_rt.hwasan-aarch64-android"}, + Native_shared_libs: []string{"libclang_rt.hwasan"}, Tests: nil, Jni_libs: nil, Binaries: nil, diff --git a/apex/apex_test.go b/apex/apex_test.go index 1c36c759f..4f2a58348 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -1415,13 +1415,14 @@ func TestRuntimeApexShouldInstallHwasanIfLibcDependsOnIt(t *testing.T) { } cc_prebuilt_library_shared { - name: "libclang_rt.hwasan-aarch64-android", + name: "libclang_rt.hwasan", no_libcrt: true, nocrt: true, stl: "none", system_shared_libs: [], srcs: [""], stubs: { versions: ["1"] }, + stem: "libclang_rt.hwasan-aarch64-android", sanitize: { never: true, @@ -1434,7 +1435,7 @@ func TestRuntimeApexShouldInstallHwasanIfLibcDependsOnIt(t *testing.T) { "lib64/bionic/libclang_rt.hwasan-aarch64-android.so", }) - hwasan := ctx.ModuleForTests("libclang_rt.hwasan-aarch64-android", "android_arm64_armv8-a_shared") + hwasan := ctx.ModuleForTests("libclang_rt.hwasan", "android_arm64_armv8-a_shared") installed := hwasan.Description("install libclang_rt.hwasan") ensureContains(t, installed.Output.String(), "/system/lib64/bootstrap/libclang_rt.hwasan-aarch64-android.so") @@ -1462,13 +1463,14 @@ func TestRuntimeApexShouldInstallHwasanIfHwaddressSanitized(t *testing.T) { } cc_prebuilt_library_shared { - name: "libclang_rt.hwasan-aarch64-android", + name: "libclang_rt.hwasan", no_libcrt: true, nocrt: true, stl: "none", system_shared_libs: [], srcs: [""], stubs: { versions: ["1"] }, + stem: "libclang_rt.hwasan-aarch64-android", sanitize: { never: true, @@ -1482,7 +1484,7 @@ func TestRuntimeApexShouldInstallHwasanIfHwaddressSanitized(t *testing.T) { "lib64/bionic/libclang_rt.hwasan-aarch64-android.so", }) - hwasan := ctx.ModuleForTests("libclang_rt.hwasan-aarch64-android", "android_arm64_armv8-a_shared") + hwasan := ctx.ModuleForTests("libclang_rt.hwasan", "android_arm64_armv8-a_shared") installed := hwasan.Description("install libclang_rt.hwasan") ensureContains(t, installed.Output.String(), "/system/lib64/bootstrap/libclang_rt.hwasan-aarch64-android.so") diff --git a/cc/cc.go b/cc/cc.go index a8adb0c4c..58ab28c7c 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -1383,7 +1383,7 @@ func isBionic(name string) bool { } func InstallToBootstrap(name string, config android.Config) bool { - if name == "libclang_rt.hwasan-aarch64-android" { + if name == "libclang_rt.hwasan" { return true } return isBionic(name) diff --git a/cc/cc_test.go b/cc/cc_test.go index 51a6a271f..278efa174 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -2944,13 +2944,13 @@ func TestStaticLibDepExport(t *testing.T) { // Check the shared version of lib2. variant := "android_arm64_armv8-a_shared" module := ctx.ModuleForTests("lib2", variant).Module().(*Module) - checkStaticLibs(t, []string{"lib1", "libc++demangle", "libclang_rt.builtins-aarch64-android"}, module) + checkStaticLibs(t, []string{"lib1", "libc++demangle", "libclang_rt.builtins"}, module) // Check the static version of lib2. variant = "android_arm64_armv8-a_static" module = ctx.ModuleForTests("lib2", variant).Module().(*Module) // libc++_static is linked additionally. - checkStaticLibs(t, []string{"lib1", "libc++_static", "libc++demangle", "libclang_rt.builtins-aarch64-android"}, module) + checkStaticLibs(t, []string{"lib1", "libc++_static", "libc++demangle", "libclang_rt.builtins"}, module) } var compilerFlagsTestCases = []struct { diff --git a/cc/config/toolchain.go b/cc/config/toolchain.go index 6cede11a0..7175fdc1a 100644 --- a/cc/config/toolchain.go +++ b/cc/config/toolchain.go @@ -227,14 +227,7 @@ func addPrefix(list []string, prefix string) []string { } func LibclangRuntimeLibrary(t Toolchain, library string) string { - arch := t.LibclangRuntimeLibraryArch() - if arch == "" { - return "" - } - if !t.Bionic() { - return "libclang_rt." + library + "-" + arch - } - return "libclang_rt." + library + "-" + arch + "-android" + return "libclang_rt." + library } func BuiltinsRuntimeLibrary(t Toolchain) string { diff --git a/cc/sanitize_test.go b/cc/sanitize_test.go index 0070e4026..c1ca03408 100644 --- a/cc/sanitize_test.go +++ b/cc/sanitize_test.go @@ -24,11 +24,7 @@ import ( var prepareForAsanTest = android.FixtureAddFile("asan/Android.bp", []byte(` cc_library_shared { - name: "libclang_rt.asan-aarch64-android", - } - - cc_library_shared { - name: "libclang_rt.asan-arm-android", + name: "libclang_rt.asan", } `)) diff --git a/cc/testing.go b/cc/testing.go index a03d147a0..32f7c6080 100644 --- a/cc/testing.go +++ b/cc/testing.go @@ -86,53 +86,19 @@ func commonDefaultModules() string { } cc_prebuilt_library_static { - name: "libclang_rt.builtins-arm-android", - defaults: ["toolchain_libs_defaults"], - native_bridge_supported: true, - vendor_ramdisk_available: true, - } - - cc_prebuilt_library_static { - name: "libclang_rt.builtins-aarch64-android", - defaults: ["toolchain_libs_defaults"], - native_bridge_supported: true, - vendor_ramdisk_available: true, - } - - cc_prebuilt_library_static { - name: "libclang_rt.builtins-x86_64", - defaults: ["toolchain_libs_defaults"], - host_supported: true, - } - - cc_prebuilt_library_static { - name: "libclang_rt.builtins-i386", + name: "libclang_rt.builtins", defaults: ["toolchain_libs_defaults"], host_supported: true, + vendor_available: true, + vendor_ramdisk_available: true, + native_bridge_supported: true, } cc_prebuilt_library_shared { - name: "libclang_rt.hwasan-aarch64-android", + name: "libclang_rt.hwasan", defaults: ["toolchain_libs_defaults"], } - cc_prebuilt_library_static { - name: "libclang_rt.builtins-i686-android", - defaults: ["toolchain_libs_defaults"], - vendor_ramdisk_available: true, - native_bridge_supported: true, - } - - cc_prebuilt_library_static { - name: "libclang_rt.builtins-x86_64-android", - defaults: [ - "linux_bionic_supported", - "toolchain_libs_defaults", - ], - native_bridge_supported: true, - vendor_ramdisk_available: true, - } - cc_prebuilt_library_static { name: "libunwind", defaults: [ @@ -144,30 +110,7 @@ func commonDefaultModules() string { } cc_prebuilt_library_static { - name: "libclang_rt.fuzzer-arm-android", - defaults: ["toolchain_libs_defaults"], - } - - cc_prebuilt_library_static { - name: "libclang_rt.fuzzer-aarch64-android", - defaults: ["toolchain_libs_defaults"], - } - - cc_prebuilt_library_static { - name: "libclang_rt.fuzzer-i686-android", - defaults: ["toolchain_libs_defaults"], - } - - cc_prebuilt_library_static { - name: "libclang_rt.fuzzer-x86_64-android", - defaults: [ - "linux_bionic_supported", - "toolchain_libs_defaults", - ], - } - - cc_prebuilt_library_static { - name: "libclang_rt.fuzzer-x86_64", + name: "libclang_rt.fuzzer", defaults: [ "linux_bionic_supported", "toolchain_libs_defaults", @@ -176,17 +119,12 @@ func commonDefaultModules() string { // Needed for sanitizer cc_prebuilt_library_shared { - name: "libclang_rt.ubsan_standalone-aarch64-android", + name: "libclang_rt.ubsan_standalone", defaults: ["toolchain_libs_defaults"], } cc_prebuilt_library_static { - name: "libclang_rt.ubsan_minimal-aarch64-android", - defaults: ["toolchain_libs_defaults"], - } - - cc_prebuilt_library_static { - name: "libclang_rt.ubsan_minimal-arm-android", + name: "libclang_rt.ubsan_minimal", defaults: ["toolchain_libs_defaults"], } diff --git a/cc/vndk.go b/cc/vndk.go index c9c9f2c08..bf6148b1c 100644 --- a/cc/vndk.go +++ b/cc/vndk.go @@ -450,7 +450,7 @@ var _ android.OutputFileProducer = &vndkLibrariesTxt{} // Therefore, by removing the library here, we cause it to only be installed if libc // depends on it. func llndkLibrariesTxtFactory() android.SingletonModule { - return newVndkLibrariesWithMakeVarFilter(llndkLibraries, "LLNDK_LIBRARIES", "libclang_rt.hwasan-") + return newVndkLibrariesWithMakeVarFilter(llndkLibraries, "LLNDK_LIBRARIES", "libclang_rt.hwasan") } // vndksp_libraries_txt is a singleton module whose content is a list of VNDKSP libraries diff --git a/rust/config/toolchain.go b/rust/config/toolchain.go index a769f121c..9c9d5724a 100644 --- a/rust/config/toolchain.go +++ b/rust/config/toolchain.go @@ -121,14 +121,7 @@ func LibFuzzerRuntimeLibrary(t Toolchain) string { } func LibclangRuntimeLibrary(t Toolchain, library string) string { - arch := t.LibclangRuntimeLibraryArch() - if arch == "" { - return "" - } - if !t.Bionic() { - return "libclang_rt." + library + "-" + arch - } - return "libclang_rt." + library + "-" + arch + "-android" + return "libclang_rt." + library } func LibRustRuntimeLibrary(t Toolchain, library string) string { diff --git a/rust/testing.go b/rust/testing.go index 1b34dfe8e..cb98bed65 100644 --- a/rust/testing.go +++ b/rust/testing.go @@ -88,13 +88,13 @@ func GatherRequiredDepsForTest() string { export_include_dirs: ["libprotobuf-cpp-full-includes"], } cc_library { - name: "libclang_rt.asan-aarch64-android", + name: "libclang_rt.asan", no_libcrt: true, nocrt: true, system_shared_libs: [], } cc_library { - name: "libclang_rt.hwasan_static-aarch64-android", + name: "libclang_rt.hwasan_static", no_libcrt: true, nocrt: true, system_shared_libs: [], diff --git a/rust/vendor_snapshot_test.go b/rust/vendor_snapshot_test.go index 03bd867a3..7be00425e 100644 --- a/rust/vendor_snapshot_test.go +++ b/rust/vendor_snapshot_test.go @@ -561,7 +561,7 @@ func TestVendorSnapshotUse(t *testing.T) { static_libs: [ "libvendor", "libvndk", - "libclang_rt.builtins-aarch64-android", + "libclang_rt.builtins", "note_memtag_heap_sync", ], shared_libs: [ @@ -589,7 +589,7 @@ func TestVendorSnapshotUse(t *testing.T) { static_libs: [ "libvendor", "libvndk", - "libclang_rt.builtins-arm-android", + "libclang_rt.builtins", ], shared_libs: [ "libvendor_available", @@ -731,19 +731,7 @@ func TestVendorSnapshotUse(t *testing.T) { } vendor_snapshot_static { - name: "libclang_rt.builtins-aarch64-android", - version: "30", - target_arch: "arm64", - vendor: true, - arch: { - arm64: { - src: "libclang_rt.builtins-aarch64-android.a", - }, - }, - } - - vendor_snapshot_static { - name: "libclang_rt.builtins-arm-android", + name: "libclang_rt.builtins", version: "30", target_arch: "arm64", vendor: true, @@ -751,6 +739,9 @@ func TestVendorSnapshotUse(t *testing.T) { arm: { src: "libclang_rt.builtins-arm-android.a", }, + arm64: { + src: "libclang_rt.builtins-aarch64-android.a", + }, }, } @@ -967,7 +958,7 @@ func TestVendorSnapshotUse(t *testing.T) { } libclientAndroidMkStaticLibs := ctx.ModuleForTests("libclient", sharedVariant).Module().(*Module).Properties.AndroidMkStaticLibs - if g, w := libclientAndroidMkStaticLibs, []string{"libvendor", "libvendor_without_snapshot", "libclang_rt.builtins-aarch64-android.vendor"}; !reflect.DeepEqual(g, w) { + if g, w := libclientAndroidMkStaticLibs, []string{"libvendor", "libvendor_without_snapshot", "libclang_rt.builtins.vendor"}; !reflect.DeepEqual(g, w) { t.Errorf("wanted libclient AndroidMkStaticLibs %q, got %q", w, g) } @@ -1024,7 +1015,7 @@ func TestVendorSnapshotUse(t *testing.T) { } memtagStaticLibs := ctx.ModuleForTests("memtag_binary", "android_vendor.30_arm64_armv8-a").Module().(*Module).Properties.AndroidMkStaticLibs - if g, w := memtagStaticLibs, []string{"libclang_rt.builtins-aarch64-android.vendor", "note_memtag_heap_sync.vendor"}; !reflect.DeepEqual(g, w) { + if g, w := memtagStaticLibs, []string{"libclang_rt.builtins.vendor", "note_memtag_heap_sync.vendor"}; !reflect.DeepEqual(g, w) { t.Errorf("wanted memtag_binary AndroidMkStaticLibs %q, got %q", w, g) } }