Merge "Use single module for clang runtime libraries" into sc-v2-dev-plus-aosp

This commit is contained in:
Colin Cross
2022-03-01 00:55:39 +00:00
committed by Android (Google) Code Review
11 changed files with 32 additions and 119 deletions

View File

@@ -1415,7 +1415,7 @@ func (a *apexBundle) AddSanitizerDependencies(ctx android.BottomUpMutatorContext
for _, target := range ctx.MultiTargets() { for _, target := range ctx.MultiTargets() {
if target.Arch.ArchType.Multilib == "lib64" { if target.Arch.ArchType.Multilib == "lib64" {
addDependenciesForNativeModules(ctx, ApexNativeDependencies{ addDependenciesForNativeModules(ctx, ApexNativeDependencies{
Native_shared_libs: []string{"libclang_rt.hwasan-aarch64-android"}, Native_shared_libs: []string{"libclang_rt.hwasan"},
Tests: nil, Tests: nil,
Jni_libs: nil, Jni_libs: nil,
Binaries: nil, Binaries: nil,

View File

@@ -1415,13 +1415,14 @@ func TestRuntimeApexShouldInstallHwasanIfLibcDependsOnIt(t *testing.T) {
} }
cc_prebuilt_library_shared { cc_prebuilt_library_shared {
name: "libclang_rt.hwasan-aarch64-android", name: "libclang_rt.hwasan",
no_libcrt: true, no_libcrt: true,
nocrt: true, nocrt: true,
stl: "none", stl: "none",
system_shared_libs: [], system_shared_libs: [],
srcs: [""], srcs: [""],
stubs: { versions: ["1"] }, stubs: { versions: ["1"] },
stem: "libclang_rt.hwasan-aarch64-android",
sanitize: { sanitize: {
never: true, never: true,
@@ -1434,7 +1435,7 @@ func TestRuntimeApexShouldInstallHwasanIfLibcDependsOnIt(t *testing.T) {
"lib64/bionic/libclang_rt.hwasan-aarch64-android.so", "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") installed := hwasan.Description("install libclang_rt.hwasan")
ensureContains(t, installed.Output.String(), "/system/lib64/bootstrap/libclang_rt.hwasan-aarch64-android.so") 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 { cc_prebuilt_library_shared {
name: "libclang_rt.hwasan-aarch64-android", name: "libclang_rt.hwasan",
no_libcrt: true, no_libcrt: true,
nocrt: true, nocrt: true,
stl: "none", stl: "none",
system_shared_libs: [], system_shared_libs: [],
srcs: [""], srcs: [""],
stubs: { versions: ["1"] }, stubs: { versions: ["1"] },
stem: "libclang_rt.hwasan-aarch64-android",
sanitize: { sanitize: {
never: true, never: true,
@@ -1482,7 +1484,7 @@ func TestRuntimeApexShouldInstallHwasanIfHwaddressSanitized(t *testing.T) {
"lib64/bionic/libclang_rt.hwasan-aarch64-android.so", "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") installed := hwasan.Description("install libclang_rt.hwasan")
ensureContains(t, installed.Output.String(), "/system/lib64/bootstrap/libclang_rt.hwasan-aarch64-android.so") ensureContains(t, installed.Output.String(), "/system/lib64/bootstrap/libclang_rt.hwasan-aarch64-android.so")

View File

@@ -1383,7 +1383,7 @@ func isBionic(name string) bool {
} }
func InstallToBootstrap(name string, config android.Config) bool { func InstallToBootstrap(name string, config android.Config) bool {
if name == "libclang_rt.hwasan-aarch64-android" { if name == "libclang_rt.hwasan" {
return true return true
} }
return isBionic(name) return isBionic(name)

View File

@@ -2944,13 +2944,13 @@ func TestStaticLibDepExport(t *testing.T) {
// Check the shared version of lib2. // Check the shared version of lib2.
variant := "android_arm64_armv8-a_shared" variant := "android_arm64_armv8-a_shared"
module := ctx.ModuleForTests("lib2", variant).Module().(*Module) 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. // Check the static version of lib2.
variant = "android_arm64_armv8-a_static" variant = "android_arm64_armv8-a_static"
module = ctx.ModuleForTests("lib2", variant).Module().(*Module) module = ctx.ModuleForTests("lib2", variant).Module().(*Module)
// libc++_static is linked additionally. // 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 { var compilerFlagsTestCases = []struct {

View File

@@ -227,14 +227,7 @@ func addPrefix(list []string, prefix string) []string {
} }
func LibclangRuntimeLibrary(t Toolchain, library string) string { func LibclangRuntimeLibrary(t Toolchain, library string) string {
arch := t.LibclangRuntimeLibraryArch() return "libclang_rt." + library
if arch == "" {
return ""
}
if !t.Bionic() {
return "libclang_rt." + library + "-" + arch
}
return "libclang_rt." + library + "-" + arch + "-android"
} }
func BuiltinsRuntimeLibrary(t Toolchain) string { func BuiltinsRuntimeLibrary(t Toolchain) string {

View File

@@ -24,11 +24,7 @@ import (
var prepareForAsanTest = android.FixtureAddFile("asan/Android.bp", []byte(` var prepareForAsanTest = android.FixtureAddFile("asan/Android.bp", []byte(`
cc_library_shared { cc_library_shared {
name: "libclang_rt.asan-aarch64-android", name: "libclang_rt.asan",
}
cc_library_shared {
name: "libclang_rt.asan-arm-android",
} }
`)) `))

View File

@@ -86,53 +86,19 @@ func commonDefaultModules() string {
} }
cc_prebuilt_library_static { cc_prebuilt_library_static {
name: "libclang_rt.builtins-arm-android", name: "libclang_rt.builtins",
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",
defaults: ["toolchain_libs_defaults"], defaults: ["toolchain_libs_defaults"],
host_supported: true, host_supported: true,
vendor_available: true,
vendor_ramdisk_available: true,
native_bridge_supported: true,
} }
cc_prebuilt_library_shared { cc_prebuilt_library_shared {
name: "libclang_rt.hwasan-aarch64-android", name: "libclang_rt.hwasan",
defaults: ["toolchain_libs_defaults"], 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 { cc_prebuilt_library_static {
name: "libunwind", name: "libunwind",
defaults: [ defaults: [
@@ -144,30 +110,7 @@ func commonDefaultModules() string {
} }
cc_prebuilt_library_static { cc_prebuilt_library_static {
name: "libclang_rt.fuzzer-arm-android", name: "libclang_rt.fuzzer",
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",
defaults: [ defaults: [
"linux_bionic_supported", "linux_bionic_supported",
"toolchain_libs_defaults", "toolchain_libs_defaults",
@@ -176,17 +119,12 @@ func commonDefaultModules() string {
// Needed for sanitizer // Needed for sanitizer
cc_prebuilt_library_shared { cc_prebuilt_library_shared {
name: "libclang_rt.ubsan_standalone-aarch64-android", name: "libclang_rt.ubsan_standalone",
defaults: ["toolchain_libs_defaults"], defaults: ["toolchain_libs_defaults"],
} }
cc_prebuilt_library_static { cc_prebuilt_library_static {
name: "libclang_rt.ubsan_minimal-aarch64-android", name: "libclang_rt.ubsan_minimal",
defaults: ["toolchain_libs_defaults"],
}
cc_prebuilt_library_static {
name: "libclang_rt.ubsan_minimal-arm-android",
defaults: ["toolchain_libs_defaults"], defaults: ["toolchain_libs_defaults"],
} }

View File

@@ -450,7 +450,7 @@ var _ android.OutputFileProducer = &vndkLibrariesTxt{}
// Therefore, by removing the library here, we cause it to only be installed if libc // Therefore, by removing the library here, we cause it to only be installed if libc
// depends on it. // depends on it.
func llndkLibrariesTxtFactory() android.SingletonModule { 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 // vndksp_libraries_txt is a singleton module whose content is a list of VNDKSP libraries

View File

@@ -121,14 +121,7 @@ func LibFuzzerRuntimeLibrary(t Toolchain) string {
} }
func LibclangRuntimeLibrary(t Toolchain, library string) string { func LibclangRuntimeLibrary(t Toolchain, library string) string {
arch := t.LibclangRuntimeLibraryArch() return "libclang_rt." + library
if arch == "" {
return ""
}
if !t.Bionic() {
return "libclang_rt." + library + "-" + arch
}
return "libclang_rt." + library + "-" + arch + "-android"
} }
func LibRustRuntimeLibrary(t Toolchain, library string) string { func LibRustRuntimeLibrary(t Toolchain, library string) string {

View File

@@ -88,13 +88,13 @@ func GatherRequiredDepsForTest() string {
export_include_dirs: ["libprotobuf-cpp-full-includes"], export_include_dirs: ["libprotobuf-cpp-full-includes"],
} }
cc_library { cc_library {
name: "libclang_rt.asan-aarch64-android", name: "libclang_rt.asan",
no_libcrt: true, no_libcrt: true,
nocrt: true, nocrt: true,
system_shared_libs: [], system_shared_libs: [],
} }
cc_library { cc_library {
name: "libclang_rt.hwasan_static-aarch64-android", name: "libclang_rt.hwasan_static",
no_libcrt: true, no_libcrt: true,
nocrt: true, nocrt: true,
system_shared_libs: [], system_shared_libs: [],

View File

@@ -561,7 +561,7 @@ func TestVendorSnapshotUse(t *testing.T) {
static_libs: [ static_libs: [
"libvendor", "libvendor",
"libvndk", "libvndk",
"libclang_rt.builtins-aarch64-android", "libclang_rt.builtins",
"note_memtag_heap_sync", "note_memtag_heap_sync",
], ],
shared_libs: [ shared_libs: [
@@ -589,7 +589,7 @@ func TestVendorSnapshotUse(t *testing.T) {
static_libs: [ static_libs: [
"libvendor", "libvendor",
"libvndk", "libvndk",
"libclang_rt.builtins-arm-android", "libclang_rt.builtins",
], ],
shared_libs: [ shared_libs: [
"libvendor_available", "libvendor_available",
@@ -731,19 +731,7 @@ func TestVendorSnapshotUse(t *testing.T) {
} }
vendor_snapshot_static { vendor_snapshot_static {
name: "libclang_rt.builtins-aarch64-android", name: "libclang_rt.builtins",
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",
version: "30", version: "30",
target_arch: "arm64", target_arch: "arm64",
vendor: true, vendor: true,
@@ -751,6 +739,9 @@ func TestVendorSnapshotUse(t *testing.T) {
arm: { arm: {
src: "libclang_rt.builtins-arm-android.a", 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 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) 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 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) t.Errorf("wanted memtag_binary AndroidMkStaticLibs %q, got %q", w, g)
} }
} }