[libc-commits] [libc] [libc][math] Fix arm-linux-gnueabihf target when building with gcc/g++. (PR #202090)
via libc-commits
libc-commits at lists.llvm.org
Sat Jun 6 15:18:18 PDT 2026
https://github.com/lntue created https://github.com/llvm/llvm-project/pull/202090
- Default arm-linux-gnueabihf-gcc defines fixed point macros (like `__FRACT_FBIT__`) but does not support `_Fract` and `_Accum` types by default. We just limit the fixed point support to clang for now.
- Specify the types for the sqrt instructions we use for ARM target.
Fixes https://github.com/llvm/llvm-project/issues/201678.
>From 6435acd82801bd8ea3e7f6a6a3931a1f4d600864 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Sat, 6 Jun 2026 22:12:35 +0000
Subject: [PATCH] [libc][math] Fix arm-linux-gnueabihf target when building
with gcc/g++.
---
libc/include/llvm-libc-macros/stdfix-macros.h | 2 +-
libc/src/__support/FPUtil/arm/sqrt.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/libc/include/llvm-libc-macros/stdfix-macros.h b/libc/include/llvm-libc-macros/stdfix-macros.h
index 04097e14e9747..20fa41e509e58 100644
--- a/libc/include/llvm-libc-macros/stdfix-macros.h
+++ b/libc/include/llvm-libc-macros/stdfix-macros.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_MACROS_STDFIX_MACROS_H
#define LLVM_LIBC_MACROS_STDFIX_MACROS_H
-#ifdef __FRACT_FBIT__
+#if defined(__FRACT_FBIT__) && defined(__clang__)
// _Fract and _Accum types are available
#define LIBC_COMPILER_HAS_FIXED_POINT
#endif // __FRACT_FBIT__
diff --git a/libc/src/__support/FPUtil/arm/sqrt.h b/libc/src/__support/FPUtil/arm/sqrt.h
index e6cb58c0be817..71803c2ad3156 100644
--- a/libc/src/__support/FPUtil/arm/sqrt.h
+++ b/libc/src/__support/FPUtil/arm/sqrt.h
@@ -26,7 +26,7 @@ namespace fputil {
#ifdef LIBC_TARGET_CPU_HAS_FPU_FLOAT
template <> LIBC_INLINE float sqrt<float>(float x) {
float y;
- asm("vsqrt %0, %1\n\t" : "=w"(y) : "w"(x));
+ asm("vsqrt.f32 %0, %1\n\t" : "=w"(y) : "w"(x));
return y;
}
#endif // LIBC_TARGET_CPU_HAS_FPU_FLOAT
@@ -34,7 +34,7 @@ template <> LIBC_INLINE float sqrt<float>(float x) {
#ifdef LIBC_TARGET_CPU_HAS_FPU_DOUBLE
template <> LIBC_INLINE double sqrt<double>(double x) {
double y;
- asm("vsqrt %0, %1\n\t" : "=w"(y) : "w"(x));
+ asm("vsqrt.f64 %P0, %P1\n\t" : "=w"(y) : "w"(x));
return y;
}
#endif // LIBC_TARGET_CPU_HAS_FPU_DOUBLE
More information about the libc-commits
mailing list