[libc-commits] [libc] [libc][math] Guard f16 math headers to fix certain 32-bit ARM builds (PR #200715)

Christian Sigg via libc-commits libc-commits at lists.llvm.org
Mon Jun 1 01:06:16 PDT 2026


https://github.com/chsigg updated https://github.com/llvm/llvm-project/pull/200715

>From a758e60fb1a06623fef324affc5a70f0637d2644 Mon Sep 17 00:00:00 2001
From: Sonal Pinto <sonalpinto at google.com>
Date: Mon, 1 Jun 2026 04:51:04 +0000
Subject: [PATCH] [libc][math] Guard f16 math headers to fix certain 32-bit ARM
 builds

Wrap hypotf16.h and expxf16_utils.h in LIBC_TYPES_HAS_FLOAT16 macros like other flaot16 math headers.
This fixes build breaks on systems where float16 is unsupported (like some 32-bit ARM).
---
 libc/src/__support/math/expxf16_utils.h | 6 ++++++
 libc/src/__support/math/hypotf16.h      | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/libc/src/__support/math/expxf16_utils.h b/libc/src/__support/math/expxf16_utils.h
index 0375eaf179b9f..33f66a93df631 100644
--- a/libc/src/__support/math/expxf16_utils.h
+++ b/libc/src/__support/math/expxf16_utils.h
@@ -9,6 +9,10 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_EXPXF16_UTILS_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_EXPXF16_UTILS_H
 
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
 #include "hdr/stdint_proxy.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/FPUtil/cast.h"
@@ -238,4 +242,6 @@ LIBC_INLINE_VAR constexpr cpp::array<float, 32> ONE_OVER_F_F = {
 
 } // namespace LIBC_NAMESPACE_DECL
 
+#endif // LIBC_TYPES_HAS_FLOAT16
+
 #endif // LLVM_LIBC_SRC___SUPPORT_MATH_EXPXF16_UTILS_H
diff --git a/libc/src/__support/math/hypotf16.h b/libc/src/__support/math/hypotf16.h
index 07e8a0566b8ec..f93500977f0e7 100644
--- a/libc/src/__support/math/hypotf16.h
+++ b/libc/src/__support/math/hypotf16.h
@@ -9,6 +9,10 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_HYPOTF16_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_HYPOTF16_H
 
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/FPUtil/cast.h"
@@ -96,4 +100,6 @@ LIBC_INLINE float16 hypotf16(float16 x, float16 y) {
 
 } // namespace LIBC_NAMESPACE_DECL
 
+#endif // LIBC_TYPES_HAS_FLOAT16
+
 #endif // LLVM_LIBC_SRC___SUPPORT_MATH_HYPOTF16_H



More information about the libc-commits mailing list