From 778cefa7e2252ec0a1c5afa7327ff4dd103d0450 Mon Sep 17 00:00:00 2001 From: Jack Gallagher Date: Tue, 14 Jan 2025 11:54:17 +0000 Subject: [PATCH 1/5] i#2154 Android64: Get tests building Made some tweaks to the CMake scripts to get the test suite building for Android: - Drmemtrace is not currently built for Android so we need to disable some tests which depend on it when building for Android (rseq). - Disable linux.infloop test because we don't currently build the test binary for Android. - Changed to --dynamic-list because --dynamic-list-data is not supported by lld which is the linker now used in the Android ndk. It should now be possible to build for Android64 with -DBUILD_TESTS=ON using the latest Android ndk (tested with r27c). Issues: #2154, #1874 --- make/DynamoRIOConfig.cmake.in | 6 ++++-- suite/tests/CMakeLists.txt | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/make/DynamoRIOConfig.cmake.in b/make/DynamoRIOConfig.cmake.in index 063a55def57..c9ab3cd098a 100644 --- a/make/DynamoRIOConfig.cmake.in +++ b/make/DynamoRIOConfig.cmake.in @@ -1141,10 +1141,12 @@ function (configure_DynamoRIO_static target) if (ANDROID) # The Android linker is not exporting the weak symbol _USES_DR_VERSION_. - # We use --dynamic-list-data to do so. + # We use --dynamic-list to do so. + file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/dynamic_symbol_list "{ _USES_DR_VERSION_; };") # Actually the Linux linker is exporting the entire DR API symbol set: # should we pass -Wl,--export-dynamic here to match it? - _DR_append_property_string(TARGET ${target} LINK_FLAGS "-Wl,--dynamic-list-data") + _DR_append_property_string(TARGET ${target} LINK_FLAGS + "-Wl,--dynamic-list=${CMAKE_CURRENT_BINARY_DIR}/dynamic_symbol_list") endif () # We need libc before the ntdll_imports pulled in for DR. _DR_get_static_libc_list(static_libc) diff --git a/suite/tests/CMakeLists.txt b/suite/tests/CMakeLists.txt index 714438c5115..b3a05a6ea24 100644 --- a/suite/tests/CMakeLists.txt +++ b/suite/tests/CMakeLists.txt @@ -1420,7 +1420,9 @@ function(torun test key source native standalone_dr dr_ops exe_ops added_out pas file(READ "${testpath}/${srcbase}.runall" runall) if (UNIX) # We always run infloop. - get_target_path_for_execution(app_path linux.infloop "${location_suffix}") + if (NOT ANDROID) + get_target_path_for_execution(app_path linux.infloop "${location_suffix}") + endif() if ("${runall}" MATCHES "") # Add a starting message with -v, and avoid mprotect for now (i#38: mprotect # is failing). @@ -2129,7 +2131,7 @@ if (BUILD_CLIENTS) endif () endif () -if (AARCH64 AND UNIX AND ZLIB_FOUND) +if (AARCH64 AND UNIX AND ZLIB_FOUND AND NOT ANDROID) # Test TLB simulator with a virtual to physical v2p.textproto mapping. set(srcdir ${PROJECT_SOURCE_DIR}/clients/drcachesim/tests/drmemtrace.threadsig.aarch64.raw) @@ -5712,7 +5714,7 @@ if (UNIX) # when running tests in parallel: have to generate pcaches first set(linux.persist-use_FLAKY_depends linux.persist_FLAKY) - if (LINUX AND X64 AND HAVE_RSEQ AND NOT RISCV64) + if (LINUX AND X64 AND HAVE_RSEQ AND NOT RISCV64 AND NOT ANDROID) # The rseq kernel feature is Linux-only. # TODO i#2350: Port the assembly in the test to 32-bit x86 and to ARM. # TODO i#3544: Port tests to RISC-V 64 @@ -6426,7 +6428,7 @@ if (BUILD_CLIENTS AND NOT ANDROID) code_api|tool.drcacheoff.simple PROPERTIES LABELS UBUNTU_22) endif () -if (LINUX AND X64 AND HAVE_RSEQ AND NOT RISCV64) # TODO i#3544: Port tests to RISC-V 64 +if (LINUX AND X64 AND HAVE_RSEQ AND NOT RISCV64 AND NOT ANDROID) # TODO i#3544: Port tests to RISC-V 64 set_tests_properties( code_api|api.rseq code_api|linux.rseq_disable From d0e2e31667bb10045990a07f1f3f78b787493cb5 Mon Sep 17 00:00:00 2001 From: Jack Gallagher Date: Wed, 22 Jan 2025 10:14:05 +0000 Subject: [PATCH 2/5] Remove --export-dynamic for _USES_DR_VERSION_ --- make/DynamoRIOConfig.cmake.in | 9 --------- 1 file changed, 9 deletions(-) diff --git a/make/DynamoRIOConfig.cmake.in b/make/DynamoRIOConfig.cmake.in index c9ab3cd098a..b0cfe13dd6a 100644 --- a/make/DynamoRIOConfig.cmake.in +++ b/make/DynamoRIOConfig.cmake.in @@ -1139,15 +1139,6 @@ function (configure_DynamoRIO_static target) endif () _DR_append_property_list(TARGET ${target} COMPILE_DEFINITIONS "${extra_defs}") - if (ANDROID) - # The Android linker is not exporting the weak symbol _USES_DR_VERSION_. - # We use --dynamic-list to do so. - file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/dynamic_symbol_list "{ _USES_DR_VERSION_; };") - # Actually the Linux linker is exporting the entire DR API symbol set: - # should we pass -Wl,--export-dynamic here to match it? - _DR_append_property_string(TARGET ${target} LINK_FLAGS - "-Wl,--dynamic-list=${CMAKE_CURRENT_BINARY_DIR}/dynamic_symbol_list") - endif () # We need libc before the ntdll_imports pulled in for DR. _DR_get_static_libc_list(static_libc) target_link_libraries(${target} ${static_libc}) From a715bb5c5f6347c653f22ad012b59f2e9610985a Mon Sep 17 00:00:00 2001 From: Jack Gallagher Date: Wed, 22 Jan 2025 10:28:51 +0000 Subject: [PATCH 3/5] Build linux.infloop --- suite/tests/CMakeLists.txt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/suite/tests/CMakeLists.txt b/suite/tests/CMakeLists.txt index b3a05a6ea24..367b204e639 100644 --- a/suite/tests/CMakeLists.txt +++ b/suite/tests/CMakeLists.txt @@ -1420,9 +1420,7 @@ function(torun test key source native standalone_dr dr_ops exe_ops added_out pas file(READ "${testpath}/${srcbase}.runall" runall) if (UNIX) # We always run infloop. - if (NOT ANDROID) - get_target_path_for_execution(app_path linux.infloop "${location_suffix}") - endif() + get_target_path_for_execution(app_path linux.infloop "${location_suffix}") if ("${runall}" MATCHES "") # Add a starting message with -v, and avoid mprotect for now (i#38: mprotect # is failing). @@ -5691,10 +5689,8 @@ if (UNIX) # this app is used in nudge tests # XXX: should all these infloop tests be made cross-platform? # or rely on runall tests that run calc covering this on Windows? - if (NOT ANDROID) # XXX i#1874: add support for running this on Android - add_exe(linux.infloop linux/infloop.c) - torunonly(linux.reset linux/infloop linux/reset.runall "-enable_reset" "-v") - endif () + add_exe(linux.infloop linux/infloop.c) + torunonly(linux.reset linux/infloop linux/reset.runall "-enable_reset" "-v") if (NOT X64 AND NOT ARM) # FIXME i#1551: add coarse-grain ARM support # XXX: 64-bit support not quite there yet torunonly(linux.freeze_FLAKY linux/infloop linux/freeze.runall From e2b8844fd40754d2ccff55beaedb9692664060dc Mon Sep 17 00:00:00 2001 From: Jack Gallagher Date: Wed, 22 Jan 2025 11:12:41 +0000 Subject: [PATCH 4/5] Copy run_in_bg tool to device --- tools/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 8eec2e9600e..af7dcdabb3f 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -32,6 +32,7 @@ include(../make/policies.cmake NO_POLICY_SCOPE) add_executable(run_in_bg run_in_bg.c) +copy_target_to_device(run_in_bg "${location_suffix}") if (UNIX) add_executable(runstats runstats.c) From 0762ef483bc5e0b345c327ff63306f688377d1bb Mon Sep 17 00:00:00 2001 From: Jack Gallagher Date: Wed, 22 Jan 2025 11:42:11 +0000 Subject: [PATCH 5/5] Add TODO comments --- suite/tests/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/suite/tests/CMakeLists.txt b/suite/tests/CMakeLists.txt index 367b204e639..3229ffafece 100644 --- a/suite/tests/CMakeLists.txt +++ b/suite/tests/CMakeLists.txt @@ -2129,7 +2129,7 @@ if (BUILD_CLIENTS) endif () endif () -if (AARCH64 AND UNIX AND ZLIB_FOUND AND NOT ANDROID) +if (AARCH64 AND UNIX AND ZLIB_FOUND AND NOT ANDROID) # TODO i#1874: Add drcachesim support on Android # Test TLB simulator with a virtual to physical v2p.textproto mapping. set(srcdir ${PROJECT_SOURCE_DIR}/clients/drcachesim/tests/drmemtrace.threadsig.aarch64.raw) @@ -5714,6 +5714,7 @@ if (UNIX) # The rseq kernel feature is Linux-only. # TODO i#2350: Port the assembly in the test to 32-bit x86 and to ARM. # TODO i#3544: Port tests to RISC-V 64 + # TODO i#1874: Build drmemtrace on Android (RSEQ_TEST_ATTACH depends on drmemtrace). set(linux.rseq_no_reg_compat) tobuild(linux.rseq linux/rseq.cpp) # Test the other sections. Unfortunately we need a separate binary for each. @@ -6425,6 +6426,7 @@ if (BUILD_CLIENTS AND NOT ANDROID) PROPERTIES LABELS UBUNTU_22) endif () if (LINUX AND X64 AND HAVE_RSEQ AND NOT RISCV64 AND NOT ANDROID) # TODO i#3544: Port tests to RISC-V 64 + # TODO i#1874: Build drmemtrace on Android (rseq tests depend on drmemtrace). set_tests_properties( code_api|api.rseq code_api|linux.rseq_disable