[libc-commits] [libc] [libc] Make getauxval test hermetic (PR #210706)
Pavel Labath via libc-commits
libc-commits at lists.llvm.org
Mon Jul 20 06:04:20 PDT 2026
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/210706
>From ccf86f5eb50bc2894b00e7f5ab698712e5be1fdd Mon Sep 17 00:00:00 2001
From: Pavel Labath <pavel at labath.sk>
Date: Mon, 20 Jul 2026 12:49:57 +0000
Subject: [PATCH] [libc] Make getauxval test hermetic
---
libc/cmake/modules/LLVMLibCTestRules.cmake | 12 +++---------
libc/test/UnitTest/HermeticTestUtils.cpp | 8 --------
libc/test/src/sys/auxv/linux/CMakeLists.txt | 2 +-
3 files changed, 4 insertions(+), 18 deletions(-)
diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index fdc7764c65177..332ec1084413e 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -793,6 +793,9 @@ function(add_libc_hermetic test_name)
libc.src.unistd.fork
libc.src.unistd.pipe
)
+ if (LIBC_TARGET_ARCHITECTURE_IS_AARCH64 AND NOT(LIBC_TARGET_OS_IS_BAREMETAL))
+ list(APPEND fq_deps_list libc.src.sys.auxv.getauxval)
+ endif()
if(libc.src.compiler.__stack_chk_fail IN_LIST TARGET_LLVMLIBC_ENTRYPOINTS)
# __stack_chk_fail should always be included if supported to allow building
@@ -920,15 +923,6 @@ function(add_libc_hermetic test_name)
LibcTest.hermetic
libc.test.UnitTest.ErrnoSetterMatcher
${fq_deps_list})
- # TODO: currently the dependency chain is broken such that getauxval cannot properly
- # propagate to hermetic tests. This is a temporary workaround.
- if (LIBC_TARGET_ARCHITECTURE_IS_AARCH64 AND NOT(LIBC_TARGET_OS_IS_BAREMETAL))
- target_link_libraries(
- ${fq_build_target_name}
- PRIVATE
- libc.src.sys.auxv.getauxval
- )
- endif()
if(NOT HERMETIC_TEST_NO_RUN_POSTBUILD)
if (LIBC_TEST_CMD)
diff --git a/libc/test/UnitTest/HermeticTestUtils.cpp b/libc/test/UnitTest/HermeticTestUtils.cpp
index 5ce661b2202c0..f7fc52e87ecc8 100644
--- a/libc/test/UnitTest/HermeticTestUtils.cpp
+++ b/libc/test/UnitTest/HermeticTestUtils.cpp
@@ -25,14 +25,6 @@ void *memmove(void *dst, const void *src, size_t count);
void *memset(void *ptr, int value, size_t count);
int atexit(void (*func)(void));
-// TODO: It seems that some old test frameworks does not use
-// add_libc_hermetic_test properly. Such that they won't get correct linkage
-// against the object containing this function. We create a dummy function that
-// always returns 0 to indicate a failure.
-[[gnu::weak]] unsigned long getauxval([[maybe_unused]] unsigned long id) {
- return 0;
-}
-
} // namespace LIBC_NAMESPACE_DECL
constexpr uint64_t ALIGNMENT = alignof(uintptr_t);
diff --git a/libc/test/src/sys/auxv/linux/CMakeLists.txt b/libc/test/src/sys/auxv/linux/CMakeLists.txt
index e4c3b782cd326..92617049401a2 100644
--- a/libc/test/src/sys/auxv/linux/CMakeLists.txt
+++ b/libc/test/src/sys/auxv/linux/CMakeLists.txt
@@ -1,5 +1,5 @@
add_custom_target(libc_sys_auxv_unittests)
-add_libc_unittest(
+add_libc_test(
getauxval_test
SUITE
libc_sys_auxv_unittests
More information about the libc-commits
mailing list