[libc-commits] [libc] [libc][test] Avoid getauxval dependency for bare-metal AArch64 (PR #215509)
Mark Murray via libc-commits
libc-commits at lists.llvm.org
Tue Aug 11 03:21:07 PDT 2026
https://github.com/MarkMurrayARM created https://github.com/llvm/llvm-project/pull/215509
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.
>From 2dd3660af2c37cc85076fa616491e34fd873a696 Mon Sep 17 00:00:00 2001
From: Mark Murray <Mark.Murray at arm.com>
Date: Tue, 11 Aug 2026 10:09:41 +0100
Subject: [PATCH] [libc][test] Avoid getauxval dependency for bare-metal
AArch64
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.
---
libc/test/IntegrationTest/CMakeLists.txt | 2 +-
libc/test/IntegrationTest/test.cpp | 6 ++++--
libc/test/UnitTest/HermeticTestUtils.cpp | 6 ++++--
3 files changed, 9 insertions(+), 5 deletions(-)
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) {
More information about the libc-commits
mailing list