[libc-commits] [libc] a59059d - [libc][test] Avoid getauxval dependency for bare-metal AArch64 (#215509)
via libc-commits
libc-commits at lists.llvm.org
Thu Aug 13 01:51:46 PDT 2026
Author: Mark Murray
Date: 2026-08-13T09:51:41+01:00
New Revision: a59059d267144cf20fa7ad6c1329c8d4376ace5e
URL: https://github.com/llvm/llvm-project/commit/a59059d267144cf20fa7ad6c1329c8d4376ace5e
DIFF: https://github.com/llvm/llvm-project/commit/a59059d267144cf20fa7ad6c1329c8d4376ace5e.diff
LOG: [libc][test] Avoid getauxval dependency for bare-metal AArch64 (#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.
Added:
Modified:
libc/test/IntegrationTest/CMakeLists.txt
libc/test/IntegrationTest/test.cpp
libc/test/UnitTest/HermeticTestUtils.cpp
Removed:
################################################################################
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