[libc-commits] [libc] 1e58c9d - [libc] Fix math tests for macos arm64. (#100060)
via libc-commits
libc-commits at lists.llvm.org
Tue Jul 23 09:23:04 PDT 2024
Author: lntue
Date: 2024-07-23T12:23:00-04:00
New Revision: 1e58c9de75d39ba5fa3d8373c6a631685f926014
URL: https://github.com/llvm/llvm-project/commit/1e58c9de75d39ba5fa3d8373c6a631685f926014
DIFF: https://github.com/llvm/llvm-project/commit/1e58c9de75d39ba5fa3d8373c6a631685f926014.diff
LOG: [libc] Fix math tests for macos arm64. (#100060)
Some problem with current build on macos:
- no libatomic.
- death tests do not work yet.
Added:
Modified:
libc/src/stdlib/CMakeLists.txt
libc/test/src/CMakeLists.txt
libc/test/src/math/smoke/nan_test.cpp
libc/test/src/math/smoke/nanf128_test.cpp
libc/test/src/math/smoke/nanf16_test.cpp
libc/test/src/math/smoke/nanf_test.cpp
libc/test/src/math/smoke/nanl_test.cpp
Removed:
################################################################################
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index b9b10bd2b4f71..03d8c48751840 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -331,7 +331,12 @@ if(NOT LIBC_TARGET_OS_IS_GPU)
include(${LIBC_SOURCE_DIR}/../compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake)
# scudo distinguishes riscv32 and riscv64, so we need to translate the architecture
- set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})
+ # set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})
+ if (LIBC_TARGET_OS_IS_DARWIN AND (LIBC_TARGET_ARCHITECTURE STREQUAL "arm"))
+ set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO arm64)
+ else()
+ set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})
+ endif()
if(LIBC_TARGET_ARCHITECTURE_IS_RISCV64)
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv64)
elseif(LIBC_TARGET_ARCHITECTURE_IS_RISCV32)
diff --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt
index b9a50a47af75d..60ea7e6a90d71 100644
--- a/libc/test/src/CMakeLists.txt
+++ b/libc/test/src/CMakeLists.txt
@@ -24,7 +24,11 @@ function(add_fp_unittest name)
message(FATAL_ERROR "Hermetic math test cannot require MPFR.")
endif()
set(test_type UNIT_TEST_ONLY)
- list(APPEND MATH_UNITTEST_LINK_LIBRARIES libcMPFRWrapper -lmpfr -lgmp -latomic)
+ list(APPEND MATH_UNITTEST_LINK_LIBRARIES libcMPFRWrapper -lmpfr -lgmp)
+ if(NOT(LIBC_TARGET_OS_IS_DARWIN))
+ # macOS does not have libatomic.
+ list(APPEND MATH_UNITTEST_LINK_LIBRARIES -latomic)
+ endif()
endif()
list(APPEND MATH_UNITTEST_LINK_LIBRARIES LibcFPTestHelpers)
diff --git a/libc/test/src/math/smoke/nan_test.cpp b/libc/test/src/math/smoke/nan_test.cpp
index 2ddef58325671..44ea1f7115aeb 100644
--- a/libc/test/src/math/smoke/nan_test.cpp
+++ b/libc/test/src/math/smoke/nan_test.cpp
@@ -43,7 +43,7 @@ TEST_F(LlvmLibcNanTest, RandomString) {
run_test("123 ", 0x7ff8000000000000);
}
-#ifndef LIBC_HAVE_ADDRESS_SANITIZER
+#if defined(LIBC_HAVE_ADDRESS_SANITIZER) && defined(LIBC_TARGET_OS_IS_LINUX)
TEST_F(LlvmLibcNanTest, InvalidInput) {
EXPECT_DEATH([] { LIBC_NAMESPACE::nan(nullptr); }, WITH_SIGNAL(SIGSEGV));
}
diff --git a/libc/test/src/math/smoke/nanf128_test.cpp b/libc/test/src/math/smoke/nanf128_test.cpp
index 8c15c532ebcf4..62c0292886bcd 100644
--- a/libc/test/src/math/smoke/nanf128_test.cpp
+++ b/libc/test/src/math/smoke/nanf128_test.cpp
@@ -53,7 +53,7 @@ TEST_F(LlvmLibcNanf128Test, RandomString) {
QUIET_NAN);
}
-#ifndef LIBC_HAVE_ADDRESS_SANITIZER
+#if defined(LIBC_HAVE_ADDRESS_SANITIZER) && defined(LIBC_TARGET_OS_IS_LINUX)
#include <signal.h>
TEST_F(LlvmLibcNanf128Test, InvalidInput) {
EXPECT_DEATH([] { LIBC_NAMESPACE::nanf128(nullptr); }, WITH_SIGNAL(SIGSEGV));
diff --git a/libc/test/src/math/smoke/nanf16_test.cpp b/libc/test/src/math/smoke/nanf16_test.cpp
index ec17a73d881aa..6993f209b4e00 100644
--- a/libc/test/src/math/smoke/nanf16_test.cpp
+++ b/libc/test/src/math/smoke/nanf16_test.cpp
@@ -44,7 +44,7 @@ TEST_F(LlvmLibcNanf16Test, RandomString) {
run_test("123 ", 0x7e00);
}
-#ifndef LIBC_HAVE_ADDRESS_SANITIZER
+#if defined(LIBC_HAVE_ADDRESS_SANITIZER) && defined(LIBC_TARGET_OS_IS_LINUX)
TEST_F(LlvmLibcNanf16Test, InvalidInput) {
EXPECT_DEATH([] { LIBC_NAMESPACE::nanf16(nullptr); }, WITH_SIGNAL(SIGSEGV));
}
diff --git a/libc/test/src/math/smoke/nanf_test.cpp b/libc/test/src/math/smoke/nanf_test.cpp
index 71f888c610aaf..3da1ec09967bd 100644
--- a/libc/test/src/math/smoke/nanf_test.cpp
+++ b/libc/test/src/math/smoke/nanf_test.cpp
@@ -42,7 +42,7 @@ TEST_F(LlvmLibcNanfTest, RandomString) {
run_test("123 ", 0x7fc00000);
}
-#ifndef LIBC_HAVE_ADDRESS_SANITIZER
+#if defined(LIBC_HAVE_ADDRESS_SANITIZER) && defined(LIBC_TARGET_OS_IS_LINUX)
TEST_F(LlvmLibcNanfTest, InvalidInput) {
EXPECT_DEATH([] { LIBC_NAMESPACE::nanf(nullptr); }, WITH_SIGNAL(SIGSEGV));
}
diff --git a/libc/test/src/math/smoke/nanl_test.cpp b/libc/test/src/math/smoke/nanl_test.cpp
index 7fff20b1e7be3..6a3c11466f353 100644
--- a/libc/test/src/math/smoke/nanl_test.cpp
+++ b/libc/test/src/math/smoke/nanl_test.cpp
@@ -70,7 +70,7 @@ TEST_F(LlvmLibcNanlTest, RandomString) {
run_test("123 ", expected);
}
-#ifndef LIBC_HAVE_ADDRESS_SANITIZER
+#if defined(LIBC_HAVE_ADDRESS_SANITIZER) && defined(LIBC_TARGET_OS_IS_LINUX)
TEST_F(LlvmLibcNanlTest, InvalidInput) {
EXPECT_DEATH([] { LIBC_NAMESPACE::nanl(nullptr); }, WITH_SIGNAL(SIGSEGV));
}
More information about the libc-commits
mailing list