[compiler-rt] [builtins] Avoid using long double in FreeBSD standalone environment (PR #76175)

Dimitry Andric via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 21 11:32:23 PST 2023


https://github.com/DimitryAndric created https://github.com/llvm/llvm-project/pull/76175

After 05a4212cc76d a number of long double related declarations are enabled in `int_types.h`, whenever the CPU architecture and platform support it. However, this does not work with FreeBSD's standalone environment, which disallows any use of floating point.

In add98b246290 this was made conditional with `CRT_HAS_FLOATING_POINT`, so use that macro to also determine whether `HAS_80_BIT_LONG_DOUBLE` can be turned on.


>From 9971e982fc16405c06fb37ff195620d6ed835936 Mon Sep 17 00:00:00 2001
From: Dimitry Andric <dimitry at andric.com>
Date: Thu, 21 Dec 2023 20:26:24 +0100
Subject: [PATCH] [builtins] Avoid using long double in FreeBSD standalone
 environment

After 05a4212cc76d a number of long double related declarations are
enabled in `int_types.h`, whenever the CPU architecture and platform
support it. However, this does not work with FreeBSD's standalone
environment, which disallows any use of floating point.

In add98b246290 this was made conditional with `CRT_HAS_FLOATING_POINT`,
so use that macro to also determine whether `HAS_80_BIT_LONG_DOUBLE` can
be turned on.
---
 compiler-rt/lib/builtins/int_types.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h
index 18bf0a7f3bf993..9b50268a419506 100644
--- a/compiler-rt/lib/builtins/int_types.h
+++ b/compiler-rt/lib/builtins/int_types.h
@@ -156,7 +156,9 @@ typedef struct {
 // still makes it 80 bits. Clang will match whatever compiler it is trying to
 // be compatible with. On 32-bit x86 Android, long double is 64 bits, while on
 // x86_64 Android, long double is 128 bits.
-#if (defined(__i386__) || defined(__x86_64__)) &&                              \
+#if !CRT_HAS_FLOATING_POINT
+#define HAS_80_BIT_LONG_DOUBLE 0
+#elif (defined(__i386__) || defined(__x86_64__)) &&                            \
     !(defined(_MSC_VER) || defined(__ANDROID__))
 #define HAS_80_BIT_LONG_DOUBLE 1
 #elif defined(__m68k__) || defined(__ia64__)



More information about the llvm-commits mailing list