[libc-commits] [libc] [libc][test] Avoid getauxval dependency for bare-metal AArch64 (PR #215509)
via libc-commits
libc-commits at lists.llvm.org
Tue Aug 11 03:24:43 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Mark Murray (MarkMurrayARM)
<details>
<summary>Changes</summary>
Hermetic and integration test support provide a global __getauxval shim on AArch64 for compatibility with libgcc expectations. That shim forwards to libc's getauxval implementation.
Bare-metal targets do not provide sys/auxv/getauxval, and the hermetic test rules already avoid adding that dependency for bare-metal builds. Match the source guards and integration-test dependency to that policy so AArch64 bare-metal tests do not link an unresolved getauxval reference.
---
Full diff: https://github.com/llvm/llvm-project/pull/215509.diff
3 Files Affected:
- (modified) libc/test/IntegrationTest/CMakeLists.txt (+1-1)
- (modified) libc/test/IntegrationTest/test.cpp (+4-2)
- (modified) libc/test/UnitTest/HermeticTestUtils.cpp (+4-2)
``````````diff
diff --git a/libc/test/IntegrationTest/CMakeLists.txt b/libc/test/IntegrationTest/CMakeLists.txt
index 8bebe01ac679b..4b091e767974c 100644
--- a/libc/test/IntegrationTest/CMakeLists.txt
+++ b/libc/test/IntegrationTest/CMakeLists.txt
@@ -1,5 +1,5 @@
set(arch_specific_deps)
-if(LIBC_TARGET_ARCHITECTURE_IS_AARCH64)
+if(LIBC_TARGET_ARCHITECTURE_IS_AARCH64 AND NOT LIBC_TARGET_OS_IS_BAREMETAL)
set(arch_specific_deps libc.src.sys.auxv.getauxval)
endif()
add_object_library(
diff --git a/libc/test/IntegrationTest/test.cpp b/libc/test/IntegrationTest/test.cpp
index 0a9728f021e90..fba53df8d8572 100644
--- a/libc/test/IntegrationTest/test.cpp
+++ b/libc/test/IntegrationTest/test.cpp
@@ -11,7 +11,8 @@
#include "src/__support/macros/config.h"
#include <stddef.h>
-#ifdef LIBC_TARGET_ARCH_IS_AARCH64
+#if defined(LIBC_TARGET_ARCH_IS_AARCH64) && \
+ !defined(LIBC_TARGET_OS_IS_BAREMETAL)
#include "src/sys/auxv/getauxval.h"
#endif
@@ -91,7 +92,8 @@ void *realloc(void *ptr, size_t s) {
// __dso_handle when -nostdlib is used.
void *__dso_handle = nullptr;
-#ifdef LIBC_TARGET_ARCH_IS_AARCH64
+#if defined(LIBC_TARGET_ARCH_IS_AARCH64) && \
+ !defined(LIBC_TARGET_OS_IS_BAREMETAL)
// Due to historical reasons, libgcc on aarch64 may expect __getauxval to be
// defined. See also https://gcc.gnu.org/pipermail/gcc-cvs/2020-June/300635.html
unsigned long __getauxval(unsigned long id) {
diff --git a/libc/test/UnitTest/HermeticTestUtils.cpp b/libc/test/UnitTest/HermeticTestUtils.cpp
index 9b1987509e6b8..a9bbf13a1f190 100644
--- a/libc/test/UnitTest/HermeticTestUtils.cpp
+++ b/libc/test/UnitTest/HermeticTestUtils.cpp
@@ -11,7 +11,8 @@
#include "src/__support/macros/config.h"
#include <stddef.h>
-#ifdef LIBC_TARGET_ARCH_IS_AARCH64
+#if defined(LIBC_TARGET_ARCH_IS_AARCH64) && \
+ !defined(LIBC_TARGET_OS_IS_BAREMETAL)
#include "src/sys/auxv/getauxval.h"
#endif
@@ -113,7 +114,8 @@ void __cxa_pure_virtual() {
// __dso_handle when -nostdlib is used.
void *__dso_handle = nullptr;
-#ifdef LIBC_TARGET_ARCH_IS_AARCH64
+#if defined(LIBC_TARGET_ARCH_IS_AARCH64) && \
+ !defined(LIBC_TARGET_OS_IS_BAREMETAL)
// Due to historical reasons, libgcc on aarch64 may expect __getauxval to be
// defined. See also https://gcc.gnu.org/pipermail/gcc-cvs/2020-June/300635.html
unsigned long __getauxval(unsigned long id) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/215509
More information about the libc-commits
mailing list