[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
Thu Mar 26 16:54:37 PDT 2026
https://github.com/lntue created https://github.com/llvm/llvm-project/pull/188882
None
>From 50e8be32cd22fcd97bedc3fc877aae966bef831c 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] [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/CMakeLists.txt | 5 +++--
libc/src/__support/FPUtil/generic/sqrt.h | 7 ++++++-
libc/src/__support/time/CMakeLists.txt | 3 ++-
libc/src/unistd/CMakeLists.txt | 4 ++++
libc/test/shared/shared_math_test.cpp | 2 ++
9 files changed, 41 insertions(+), 4 deletions(-)
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/CMakeLists.txt b/libc/src/__support/CMakeLists.txt
index 19b3a1d554f1c..7da446d7d00de 100644
--- a/libc/src/__support/CMakeLists.txt
+++ b/libc/src/__support/CMakeLists.txt
@@ -368,11 +368,12 @@ add_header_library(
libc.src.__support.macros.properties.types
)
-add_header_library(
+# TODO: Migrate the logic from `add_proxy_header_library` to `add_header_library`.
+add_proxy_header_library(
libc_assert
HDRS
libc_assert.h
- DEPENDS
+ FULL_BUILD_DEPENDS
.integer_to_string
libc.src.__support.OSUtil.osutil
libc.src.__support.macros.optimization
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/src/__support/time/CMakeLists.txt b/libc/src/__support/time/CMakeLists.txt
index 3cc3fd873220a..88dfe7baa6390 100644
--- a/libc/src/__support/time/CMakeLists.txt
+++ b/libc/src/__support/time/CMakeLists.txt
@@ -7,7 +7,8 @@ add_header_library(
libc.hdr.types.time_t
)
-if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS}
+ AND TARGET libc.src.__support.OSUtil.osutil)
add_subdirectory(${LIBC_TARGET_OS})
else()
return()
diff --git a/libc/src/unistd/CMakeLists.txt b/libc/src/unistd/CMakeLists.txt
index 4d78b4a7fbc84..915b860c762a0 100644
--- a/libc/src/unistd/CMakeLists.txt
+++ b/libc/src/unistd/CMakeLists.txt
@@ -1,3 +1,7 @@
+if(NOT TARGET libc.src.__support.OSUtil.osutil)
+ return()
+endif()
+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
endif()
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 5afb982dd57ed..4b085bea8cbb4 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -298,6 +298,7 @@ TEST(LlvmLibcSharedMathTest, AllDouble) {
EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::nextafter(0.0, 0.0));
}
+#ifndef LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
TEST(LlvmLibcSharedMathTest, AllLongDouble) {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<long double>;
EXPECT_FP_EQ(0x0p+0L,
@@ -339,6 +340,7 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::nexttowardl(0.0L, 0.0L));
EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::nextafterl(0.0L, 0.0L));
}
+#endif // !LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
#ifdef LIBC_TYPES_HAS_FLOAT128
More information about the libc-commits
mailing list