[libc-commits] [libc] [libc] Initial support so that libc-shared-tests can be built with pp64le (PR #188882)
via libc-commits
libc-commits at lists.llvm.org
Wed Apr 1 17:04:44 PDT 2026
https://github.com/lntue updated https://github.com/llvm/llvm-project/pull/188882
>From 6a55e2319d07e3fbab6a51c8b9db7b43915ebed2 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Thu, 26 Mar 2026 23:51:03 +0000
Subject: [PATCH 1/3] [libc] Initial support so that libc-shared-tests can be
built with ppc64le.
---
libc/cmake/modules/LLVMLibCArchitectures.cmake | 2 ++
libc/config/linux/power/config.json | 7 +++++++
libc/config/linux/power/entrypoints.txt | 14 ++++++++++++++
libc/config/linux/power/headers.txt | 1 +
libc/src/__support/FPUtil/generic/sqrt.h | 7 ++++++-
libc/test/shared/shared_math_test.cpp | 1 +
6 files changed, 31 insertions(+), 1 deletion(-)
create mode 100644 libc/config/linux/power/config.json
create mode 100644 libc/config/linux/power/entrypoints.txt
create mode 100644 libc/config/linux/power/headers.txt
diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake
index b24ea353df484..921057706c5e9 100644
--- a/libc/cmake/modules/LLVMLibCArchitectures.cmake
+++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake
@@ -184,6 +184,8 @@ elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "nvptx")
set(LIBC_TARGET_ARCHITECTURE_IS_NVPTX TRUE)
elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "spirv")
set(LIBC_TARGET_ARCHITECTURE_IS_SPIRV TRUE)
+elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "power")
+ set(LIBC_TARGET_ARCHITECTURE_IS_POWERPC TRUE)
else()
message(FATAL_ERROR
"Unsupported libc target architecture ${LIBC_TARGET_ARCHITECTURE}")
diff --git a/libc/config/linux/power/config.json b/libc/config/linux/power/config.json
new file mode 100644
index 0000000000000..22e47df31bb6e
--- /dev/null
+++ b/libc/config/linux/power/config.json
@@ -0,0 +1,7 @@
+{
+ "string": {
+ "LIBC_CONF_STRING_LENGTH_IMPL": {
+ "value": "element"
+ }
+ }
+}
diff --git a/libc/config/linux/power/entrypoints.txt b/libc/config/linux/power/entrypoints.txt
new file mode 100644
index 0000000000000..f133d4f0d20cf
--- /dev/null
+++ b/libc/config/linux/power/entrypoints.txt
@@ -0,0 +1,14 @@
+
+set(TARGET_LIBC_ENTRYPOINTS
+ libc.src.errno.errno
+)
+
+set(TARGET_LIBM_ENTRYPOINTS)
+
+set(TARGET_LIBMVEC_ENTRYPOINTS)
+
+set(TARGET_LLVMLIBC_ENTRYPOINTS
+ ${TARGET_LIBC_ENTRYPOINTS}
+ ${TARGET_LIBM_ENTRYPOINTS}
+ ${TARGET_LIBMVEC_ENTRYPOINTS}
+)
diff --git a/libc/config/linux/power/headers.txt b/libc/config/linux/power/headers.txt
new file mode 100644
index 0000000000000..8b96869309bfa
--- /dev/null
+++ b/libc/config/linux/power/headers.txt
@@ -0,0 +1 @@
+set(TARGET_PUBLIC_HEADERS)
diff --git a/libc/src/__support/FPUtil/generic/sqrt.h b/libc/src/__support/FPUtil/generic/sqrt.h
index 2295fdf85a114..e885fded2e1aa 100644
--- a/libc/src/__support/FPUtil/generic/sqrt.h
+++ b/libc/src/__support/FPUtil/generic/sqrt.h
@@ -9,7 +9,6 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_GENERIC_SQRT_H
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_GENERIC_SQRT_H
-#include "sqrt_80_bit_long_double.h"
#include "src/__support/CPP/bit.h" // countl_zero
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/FEnvImpl.h"
@@ -22,6 +21,10 @@
#include "hdr/fenv_macros.h"
+#ifdef LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
+#include "sqrt_80_bit_long_double.h"
+#endif // !LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
+
namespace LIBC_NAMESPACE_DECL {
namespace fputil {
@@ -76,8 +79,10 @@ LIBC_INLINE static constexpr cpp::enable_if_t<
sqrt(InType x) {
if constexpr (internal::SpecialLongDouble<OutType>::VALUE &&
internal::SpecialLongDouble<InType>::VALUE) {
+#ifdef LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
// Special 80-bit long double.
return x86::sqrt(x);
+#endif // !LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
} else {
// IEEE floating points formats.
using OutFPBits = FPBits<OutType>;
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 941d5a167ee85..4a0aacc0b4819 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -344,6 +344,7 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
EXPECT_FP_EQ(10.0f16, LIBC_NAMESPACE::shared::f16fmal(2.0L, 3.0L, 4.0L));
#endif // LIBC_TYPES_HAS_FLOAT16
}
+#endif // !LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
#endif // LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
>From 86d0dbd01901e0684c997e690f52669642addc09 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Wed, 1 Apr 2026 23:33:00 +0000
Subject: [PATCH 2/3] Fix sqrt/normalize.
---
libc/src/__support/FPUtil/generic/sqrt.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/src/__support/FPUtil/generic/sqrt.h b/libc/src/__support/FPUtil/generic/sqrt.h
index e885fded2e1aa..4e452a87050b1 100644
--- a/libc/src/__support/FPUtil/generic/sqrt.h
+++ b/libc/src/__support/FPUtil/generic/sqrt.h
@@ -55,7 +55,7 @@ template <>
LIBC_INLINE void normalize<long double>(int &exponent, uint64_t &mantissa) {
normalize<double>(exponent, mantissa);
}
-#elif !defined(LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80)
+#elif defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128)
template <>
LIBC_INLINE void normalize<long double>(int &exponent, UInt128 &mantissa) {
const uint64_t hi_bits = static_cast<uint64_t>(mantissa >> 64);
>From a9eebb678d88ad3ca9d84d0dbda3d52f8826169b Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Thu, 2 Apr 2026 00:04:26 +0000
Subject: [PATCH 3/3] Fix merge issue.
---
libc/test/shared/shared_math_test.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 4a0aacc0b4819..941d5a167ee85 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -344,7 +344,6 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
EXPECT_FP_EQ(10.0f16, LIBC_NAMESPACE::shared::f16fmal(2.0L, 3.0L, 4.0L));
#endif // LIBC_TYPES_HAS_FLOAT16
}
-#endif // !LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
#endif // LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
More information about the libc-commits
mailing list