[libc-commits] [libc] [libc][math] Guard f16 math headers to fix certain 32-bit ARM builds (PR #200715)
via libc-commits
libc-commits at lists.llvm.org
Sun May 31 22:23:47 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Sonal Pinto (SonalPinto)
<details>
<summary>Changes</summary>
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).
---
Full diff: https://github.com/llvm/llvm-project/pull/200715.diff
2 Files Affected:
- (modified) libc/src/__support/math/expxf16_utils.h (+6)
- (modified) libc/src/__support/math/hypotf16.h (+6)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/200715
More information about the libc-commits
mailing list