diff options
author | Schrodinger ZHU Yifan <yifanzhu@rochester.edu> | 2024-06-13 20:34:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-13 20:34:32 -0700 |
commit | 2efe3d7fc0e7f9594d91e73bef11d33e0796aa65 (patch) | |
tree | 2380d5b2040af65de4e4ea954bf5b4dc81b3fdc7 /libc/test | |
parent | 43bd7ae65af40ff3378d5a0395a058ba834ad8dd (diff) | |
download | llvm-2efe3d7fc0e7f9594d91e73bef11d33e0796aa65.zip llvm-2efe3d7fc0e7f9594d91e73bef11d33e0796aa65.tar.gz llvm-2efe3d7fc0e7f9594d91e73bef11d33e0796aa65.tar.bz2 |
Reland "[libc] fix aarch64 linux full build (#95358)" (#95423)
Reverts llvm/llvm-project#95419 and Reland #95358.
This PR is full of temporal fixes. After a discussion with @lntue, it is
better to avoid further changes to the cmake infrastructure for now as a
rework to the cmake utilities will be landed in the future.
Diffstat (limited to 'libc/test')
-rw-r--r-- | libc/test/IntegrationTest/CMakeLists.txt | 5 | ||||
-rw-r--r-- | libc/test/IntegrationTest/test.cpp | 10 | ||||
-rw-r--r-- | libc/test/UnitTest/CMakeLists.txt | 2 | ||||
-rw-r--r-- | libc/test/UnitTest/HermeticTestUtils.cpp | 16 |
4 files changed, 32 insertions, 1 deletions
diff --git a/libc/test/IntegrationTest/CMakeLists.txt b/libc/test/IntegrationTest/CMakeLists.txt index 4f31f10..4a99940 100644 --- a/libc/test/IntegrationTest/CMakeLists.txt +++ b/libc/test/IntegrationTest/CMakeLists.txt @@ -1,3 +1,7 @@ +set(arch_specific_deps) +if(LIBC_TARGET_ARCHITECTURE_IS_AARCH64) + set(arch_specific_deps libc.src.sys.auxv.getauxval) +endif() add_object_library( test SRCS @@ -8,4 +12,5 @@ add_object_library( test.h DEPENDS libc.src.__support.OSUtil.osutil + ${arch_specific_deps} ) diff --git a/libc/test/IntegrationTest/test.cpp b/libc/test/IntegrationTest/test.cpp index 3bdbe89..a8b2f29 100644 --- a/libc/test/IntegrationTest/test.cpp +++ b/libc/test/IntegrationTest/test.cpp @@ -6,6 +6,8 @@ // //===----------------------------------------------------------------------===// +#include "src/__support/common.h" +#include "src/sys/auxv/getauxval.h" #include <stddef.h> #include <stdint.h> @@ -79,4 +81,12 @@ void *realloc(void *ptr, size_t s) { // Integration tests are linked with -nostdlib. BFD linker expects // __dso_handle when -nostdlib is used. void *__dso_handle = nullptr; + +#ifdef LIBC_TARGET_ARCH_IS_AARCH64 +// 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) { + return LIBC_NAMESPACE::getauxval(id); +} +#endif } // extern "C" diff --git a/libc/test/UnitTest/CMakeLists.txt b/libc/test/UnitTest/CMakeLists.txt index 302af30..4adc2f5 100644 --- a/libc/test/UnitTest/CMakeLists.txt +++ b/libc/test/UnitTest/CMakeLists.txt @@ -41,7 +41,7 @@ function(add_unittest_framework_library name) target_compile_options(${name}.hermetic PRIVATE ${compile_options}) if(TEST_LIB_DEPENDS) - foreach(dep IN LISTS ${TEST_LIB_DEPENDS}) + foreach(dep IN ITEMS ${TEST_LIB_DEPENDS}) if(TARGET ${dep}.unit) add_dependencies(${name}.unit ${dep}.unit) else() diff --git a/libc/test/UnitTest/HermeticTestUtils.cpp b/libc/test/UnitTest/HermeticTestUtils.cpp index 349c182..6e815e6 100644 --- a/libc/test/UnitTest/HermeticTestUtils.cpp +++ b/libc/test/UnitTest/HermeticTestUtils.cpp @@ -6,6 +6,8 @@ // //===----------------------------------------------------------------------===// +#include "src/__support/common.h" +#include "src/sys/auxv/getauxval.h" #include <stddef.h> #include <stdint.h> @@ -19,6 +21,12 @@ 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(unsigned long id) { return 0; } + } // namespace LIBC_NAMESPACE namespace { @@ -102,6 +110,14 @@ void __cxa_pure_virtual() { // __dso_handle when -nostdlib is used. void *__dso_handle = nullptr; +#ifdef LIBC_TARGET_ARCH_IS_AARCH64 +// 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) { + return LIBC_NAMESPACE::getauxval(id); +} +#endif + } // extern "C" void *operator new(unsigned long size, void *ptr) { return ptr; } |