[libc-commits] [libc] [libc][cmake] Check C++ mangling in the fixed-point probe (PR #239341)
Prabhu Rajasekaran via libc-commits
libc-commits at lists.llvm.org
Fri Nov 13 10:48:34 PST 2026
https://github.com/Prabhuk updated https://github.com/llvm/llvm-project/pull/239341
>From 32a7e0642b7cbdca38a644cb86530ef01dd52130 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Sat, 17 Oct 2026 01:01:52 -0700
Subject: [PATCH 1/3] [libc][uefi] Disable fixed point types for UEFI
Report the fixed point compiler feature as unavailable on UEFI. The
Microsoft C++ ABI that UEFI uses cannot mangle fixed point types yet, so
any entrypoint that instantiates a template with one fails to compile.
Assisted-by: Claude
---
libc/cmake/modules/CheckCompilerFeatures.cmake | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/libc/cmake/modules/CheckCompilerFeatures.cmake b/libc/cmake/modules/CheckCompilerFeatures.cmake
index eaf702710b1cc..af3423024e594 100644
--- a/libc/cmake/modules/CheckCompilerFeatures.cmake
+++ b/libc/cmake/modules/CheckCompilerFeatures.cmake
@@ -62,6 +62,14 @@ endfunction()
set(AVAILABLE_COMPILER_FEATURES "")
+# Compiler features that are unavailable on UEFI targets. UEFI uses the
+# Microsoft C++ ABI, whose name mangler does not support fixed point types yet,
+# so any template instantiated with a fixed point type fails to compile.
+set(
+ UEFI_UNAVAILABLE_COMPILER_FEATURES
+ "fixed_point"
+)
+
# Try compile a C file to check if flag is supported.
foreach(feature IN LISTS ALL_COMPILER_FEATURES)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
@@ -103,6 +111,9 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES)
else()
set(has_feature TRUE)
endif()
+ elseif(LIBC_TARGET_OS_IS_UEFI AND
+ feature IN_LIST UEFI_UNAVAILABLE_COMPILER_FEATURES)
+ set(has_feature FALSE)
else()
try_compile(
has_feature
>From a710ce0ece795619b3433d4317312ea2ddcebe45 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Thu, 5 Nov 2026 19:08:32 +0000
Subject: [PATCH 2/3] [libc][uefi] Fix CMake formatting
Format the UEFI compiler feature check the way the libc CMake formatter
expects.
Assisted-by: Claude
---
libc/cmake/modules/CheckCompilerFeatures.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/cmake/modules/CheckCompilerFeatures.cmake b/libc/cmake/modules/CheckCompilerFeatures.cmake
index af3423024e594..970a7dc456f10 100644
--- a/libc/cmake/modules/CheckCompilerFeatures.cmake
+++ b/libc/cmake/modules/CheckCompilerFeatures.cmake
@@ -112,7 +112,7 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES)
set(has_feature TRUE)
endif()
elseif(LIBC_TARGET_OS_IS_UEFI AND
- feature IN_LIST UEFI_UNAVAILABLE_COMPILER_FEATURES)
+ feature IN_LIST UEFI_UNAVAILABLE_COMPILER_FEATURES)
set(has_feature FALSE)
else()
try_compile(
>From 352bfff742c15a08bedd8145c0a9d9b72d851eb0 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Fri, 13 Nov 2026 18:44:02 +0000
Subject: [PATCH 3/3] [libc][cmake] Check C++ mangling in the fixed-point probe
Pass the default target compile options during compiler feature detection and instantiate a template over a fixed-point type in the fixed-point probe so that targets whose C++ ABI cannot mangle fixed-point types do not enable them.
Assisted-by: Claude
---
libc/cmake/modules/CheckCompilerFeatures.cmake | 13 +------------
.../modules/compiler_features/check_fixed_point.cpp | 3 +++
2 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/libc/cmake/modules/CheckCompilerFeatures.cmake b/libc/cmake/modules/CheckCompilerFeatures.cmake
index 970a7dc456f10..f1901bf2cbf3f 100644
--- a/libc/cmake/modules/CheckCompilerFeatures.cmake
+++ b/libc/cmake/modules/CheckCompilerFeatures.cmake
@@ -62,18 +62,10 @@ endfunction()
set(AVAILABLE_COMPILER_FEATURES "")
-# Compiler features that are unavailable on UEFI targets. UEFI uses the
-# Microsoft C++ ABI, whose name mangler does not support fixed point types yet,
-# so any template instantiated with a fixed point type fails to compile.
-set(
- UEFI_UNAVAILABLE_COMPILER_FEATURES
- "fixed_point"
-)
-
# Try compile a C file to check if flag is supported.
foreach(feature IN LISTS ALL_COMPILER_FEATURES)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
- set(compile_options ${LIBC_COMPILE_OPTIONS_NATIVE})
+ set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT} ${LIBC_COMPILE_OPTIONS_NATIVE})
set(link_options "")
if(${feature} STREQUAL "fixed_point")
list(APPEND compile_options "-ffixed-point")
@@ -111,9 +103,6 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES)
else()
set(has_feature TRUE)
endif()
- elseif(LIBC_TARGET_OS_IS_UEFI AND
- feature IN_LIST UEFI_UNAVAILABLE_COMPILER_FEATURES)
- set(has_feature FALSE)
else()
try_compile(
has_feature
diff --git a/libc/cmake/modules/compiler_features/check_fixed_point.cpp b/libc/cmake/modules/compiler_features/check_fixed_point.cpp
index a5192697d43f7..855fe129cb8f9 100644
--- a/libc/cmake/modules/compiler_features/check_fixed_point.cpp
+++ b/libc/cmake/modules/compiler_features/check_fixed_point.cpp
@@ -3,3 +3,6 @@
#ifndef LIBC_COMPILER_HAS_FIXED_POINT
#error unsupported
#endif
+
+template <typename T> void check_fixed_point_mangling(T) {}
+template void check_fixed_point_mangling(unsigned short fract);
More information about the libc-commits
mailing list