| 1 | Upstream status: https://github.com/llvm/llvm-project/issues/187182, not released
|
| 2 |
|
| 3 | From 592eba5d448fa6f28657d364f6fdf877a38d7603 Mon Sep 17 00:00:00 2001
|
| 4 | From: Bernd Kuhls <[email protected]>
|
| 5 | Date: Mon, 9 Mar 2026 19:07:10 +0100
|
| 6 | Subject: [PATCH] [libc] Fix detection of cfloat128
|
| 7 |
|
| 8 | Building compiler-rt with aarch64-buildroot-linux-gnu-gcc 15.2 causes a
|
| 9 | build error:
|
| 10 |
|
| 11 | compiler-rt-22.1.0/cmake/Modules/../../libc/src/__support/CPP/type_traits/is_complex.h:44:31:
|
| 12 | error: 'cfloat128' was not declared in this scope; did you mean 'float128'? [-Wtemplate-body]
|
| 13 |
|
| 14 | According to https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/Floating-Types.html
|
| 15 | __float128 is not available on aarch64.
|
| 16 |
|
| 17 | Analyzing the gcc defines for aarch64 seems to prove it:
|
| 18 |
|
| 19 | $ aarch64-buildroot-linux-gnu-gcc -v
|
| 20 | Target: aarch64-buildroot-linux-gnu
|
| 21 | gcc version 15.2.0 (Buildroot 2026.02-114-gdadec9da56)
|
| 22 |
|
| 23 | $ echo | aarch64-buildroot-linux-gnu-gcc -dM -E - | grep __GCC_IEC_559_COMPLEX
|
| 24 | #define __GCC_IEC_559_COMPLEX 2
|
| 25 |
|
| 26 | $ echo | aarch64-buildroot-linux-gnu-gcc -dM -E - | grep __STDC_IEC_60559_COMPLEX__
|
| 27 | #define __STDC_IEC_60559_COMPLEX__ 201404L
|
| 28 |
|
| 29 | $ echo | aarch64-buildroot-linux-gnu-gcc -dM -E - | grep -i float128
|
| 30 | $
|
| 31 |
|
| 32 | In contrast gcc for x86_64:
|
| 33 |
|
| 34 | $ x86_64-buildroot-linux-gnu-gcc -v
|
| 35 | Target: x86_64-buildroot-linux-gnu
|
| 36 | gcc version 15.2.0 (Buildroot 2026.02-112-gd12ac02486)
|
| 37 |
|
| 38 | $ echo | x86_64-buildroot-linux-gnu-gcc -dM -E - | grep __GCC_IEC_559_COMPLEX
|
| 39 | #define __GCC_IEC_559_COMPLEX 2
|
| 40 |
|
| 41 | $ echo | x86_64-buildroot-linux-gnu-gcc -dM -E - | grep __STDC_IEC_60559_COMPLEX__
|
| 42 | #define __STDC_IEC_60559_COMPLEX__ 201404L
|
| 43 |
|
| 44 | $ echo | x86_64-buildroot-linux-gnu-gcc -dM -E - | grep -i float128
|
| 45 | #define __SIZEOF_FLOAT128__ 16
|
| 46 |
|
| 47 | This patch changes the or-condition to an and-condition for
|
| 48 | __STDC_IEC_60559_COMPLEX__ and __SIZEOF_FLOAT128__.
|
| 49 |
|
| 50 | Signed-off-by: Bernd Kuhls <[email protected]>
|
| 51 | ---
|
| 52 | libc/include/llvm-libc-macros/cfloat128-macros.h | 2 +-
|
| 53 | 1 file changed, 1 insertion(+), 1 deletion(-)
|
| 54 |
|
| 55 | diff --git a/libc/include/llvm-libc-macros/cfloat128-macros.h b/libc/include/llvm-libc-macros/cfloat128-macros.h
|
| 56 | index 5f28cfa21aaee..ff4aa530685de 100644
|
| 57 | |
| 58 | |
| 59 | @@ -27,7 +27,7 @@
|
| 60 | #define LIBC_TYPES_HAS_CFLOAT128
|
| 61 | #endif
|
| 62 | #elif defined(__GNUC__)
|
| 63 | -#if (defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)) && \
|
| 64 | +#if (defined(__STDC_IEC_60559_COMPLEX__) && defined(__SIZEOF_FLOAT128__)) && \
|
| 65 | (__GNUC__ >= 13 || (!defined(__cplusplus)))
|
| 66 | #define LIBC_TYPES_HAS_CFLOAT128
|
| 67 | #endif
|