Skip to content

Commit 63a7786

Browse files
authored
[builtins] Fix divtc3.c etc. compilation on Solaris/SPARC with gcc (llvm#101662)
`compiler-rt/lib/builtins/divtc3.c` and `multc3.c` don't compile on Solaris/sparcv9 with `gcc -m32`: ``` FAILED: projects/compiler-rt/lib/builtins/CMakeFiles/clang_rt.builtins-sparc.dir/divtc3.c.o [...] compiler-rt/lib/builtins/divtc3.c: In function ‘__divtc3’: compiler-rt/lib/builtins/divtc3.c:22:18: error: implicit declaration of function ‘__compiler_rt_logbtf’ [-Wimplicit-function-declaration] 22 | fp_t __logbw = __compiler_rt_logbtf( | ^~~~~~~~~~~~~~~~~~~~ ``` and many more. It turns out that while the definition of `__divtc3` is guarded with `CRT_HAS_F128`, the `__compiler_rt_logbtf` and other declarations use `CRT_HAS_128BIT && CRT_HAS_F128` as guard. This only shows up with `gcc` since, as documented in Issue llvm#41838, `clang` violates the SPARC psABI in not using 128-bit `long double`, so this code path isn't used. Fixed by changing the guards to match. Tested on `sparcv9-sun-solaris2.11`.
1 parent 3a7861e commit 63a7786

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

compiler-rt/lib/builtins/divtc3.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define QUAD_PRECISION
1414
#include "fp_lib.h"
1515

16-
#if defined(CRT_HAS_F128)
16+
#if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128)
1717

1818
// Returns: the quotient of (a + ib) / (c + id)
1919

compiler-rt/lib/builtins/multc3.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "int_lib.h"
1616
#include "int_math.h"
1717

18-
#if defined(CRT_HAS_F128)
18+
#if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128)
1919

2020
// Returns: the product of a + ib and c + id
2121

0 commit comments

Comments
 (0)