diff options
author | Martin Stjernholm <mast@google.com> | 2024-03-13 18:10:14 +0000 |
---|---|---|
committer | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-05-16 00:00:44 +0000 |
commit | 2336c21dacaab373f310ef0e1075f5ab38512082 (patch) | |
tree | c8203ae56d19d66a5e1af4c263ee87719bf9dc56 | |
parent | 3f3ac2c75b1cef76ef2af73371880cce8ec43455 (diff) | |
download | art-2336c21dacaab373f310ef0e1075f5ab38512082.tar.gz |
Link libnativeloader statically into gtests.
It needs to be statically linked together with the rest of the runtime
since it uses internal APIs, like android::IsNamespaceNativeBridged
from art/runtime/jni/jni_internal.cc.
This moves the RUNPATH entries from libnativeloader.so to the test
binaries, and the path is adjusted to account for the binary location
.../testcases/art_<something>_tests/<arch>/<test binary> relative to
.../testcases/art_common.
Test: atest art_compiler_tests art_libartbase_tests art_runtime_tests
on host and target in CI
Bug: 247108425
Change-Id: Ifbcc21a2746446b3d6434c73e20675602bb164b1
-rw-r--r-- | libnativeloader/Android.bp | 13 | ||||
-rw-r--r-- | runtime/Android.bp | 8 | ||||
-rw-r--r-- | test/Android.bp | 29 |
3 files changed, 26 insertions, 24 deletions
diff --git a/libnativeloader/Android.bp b/libnativeloader/Android.bp index 5e43915f04..236f27fb92 100644 --- a/libnativeloader/Android.bp +++ b/libnativeloader/Android.bp @@ -66,19 +66,6 @@ art_cc_library { "libbase", ], target: { - // Library search path needed for running host tests remotely (from testcases directory). - linux_glibc_x86: { - ldflags: [ - "-Wl,-rpath,$ORIGIN/../art_common/out/host/linux-x86/lib", - "-Wl,--enable-new-dtags", - ], - }, - linux_glibc_x86_64: { - ldflags: [ - "-Wl,-rpath,$ORIGIN/../art_common/out/host/linux-x86/lib64", - "-Wl,--enable-new-dtags", - ], - }, android: { srcs: [ "library_namespaces.cpp", diff --git a/runtime/Android.bp b/runtime/Android.bp index e8fb912789..45d416f0cc 100644 --- a/runtime/Android.bp +++ b/runtime/Android.bp @@ -652,6 +652,7 @@ cc_defaults { "liblz4", "liblzma", // libelffile dependency; must be repeated here since it's a static lib. "libnativebridge", + "libnativeloader", "libodrstatslog", ], target: { @@ -661,6 +662,11 @@ cc_defaults { "-Wno-unused-command-line-argument", ], }, + android: { + whole_static_libs: [ + "libPlatformProperties", // libnativeloader dependency. + ], + }, }, } @@ -677,7 +683,6 @@ cc_defaults { "libart-runtime", "libelffile", "libsigchain_fake", - "libnativeloader", ], } @@ -694,7 +699,6 @@ cc_defaults { "libartd-runtime", "libelffiled", "libsigchain_fake", - "libnativeloader", ], } diff --git a/test/Android.bp b/test/Android.bp index 304c72cc10..cefdae887e 100644 --- a/test/Android.bp +++ b/test/Android.bp @@ -252,12 +252,10 @@ art_cc_defaults { // These really are gtests, but the gtest library comes from `libart(d)-gtest.so`. gtest: false, + header_libs: [ + "libnativeloader-headers", + ], shared_libs: [ - // `libnativeloader` must be shared, otherwise host gtests can't load libraries from - // "art_common/out/host", which is present in `libnativeloader` RUNPATH. - // TODO(b/247108425): modify gtests RUNPATH so that `libnativeloader` can be static linked. - "libnativeloader", - // `libart(d)` (`art/runtime/jni/java_vm_ext.cc`) and `libnativehelper` // (`libnativehelper/JniInvocation.c`) define symbols with the same name // (e.g. `JNI_GetDefaultJavaVMInitArgs`). @@ -279,6 +277,12 @@ art_cc_defaults { "heapprofd_client_api", ], }, + host: { + cflags: [ + "-fsanitize-address-use-after-return=never", + "-Wno-unused-command-line-argument", + ], + }, linux: { ldflags: [ // Allow jni_compiler_test to find Java_MyClassNatives_bar @@ -295,10 +299,17 @@ art_cc_defaults { "-Wno-missing-noreturn", ], }, - host: { - cflags: [ - "-fsanitize-address-use-after-return=never", - "-Wno-unused-command-line-argument", + // Library search path needed for running host tests in CI (from testcases directory). + linux_glibc_x86: { + ldflags: [ + "-Wl,-rpath,$ORIGIN/../../art_common/out/host/linux-x86/lib", + "-Wl,--enable-new-dtags", + ], + }, + linux_glibc_x86_64: { + ldflags: [ + "-Wl,-rpath,$ORIGIN/../../art_common/out/host/linux-x86/lib64", + "-Wl,--enable-new-dtags", ], }, }, |