[ppc64le][flang-rt] flang-rt build defaults to IBM long double on IEEE long double systems
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
## Description
On ppc64le systems where the host GCC uses IEEE 754 quad precision as the default long double format (e.g. AlmaLinux 10, Fedora 36+), the just-built clang defaults to IBM double-double instead. This causes a long double ABI mismatch when linking runtimes (built by clang/IBM) against LLVMSupport (built by GCC/IEEE).
Verified this does not happen on Ubuntu 24.04, which uses IBM double-double.
## Steps to Reproduce
On a ppc64le system with IEEE quad long double (LDBL_MANT_DIG=113):
```
cmake -S llvm -B build -G Ninja \
-DLLVM_ENABLE_PROJECTS="clang;flang" \
-DLLVM_ENABLE_RUNTIMES="flang-rt" \
-DLLVM_TARGETS_TO_BUILD="PowerPC" \
-DCMAKE_BUILD_TYPE=Release \
-DFLANG_RUNTIME_F128_MATH_LIB=
ninja -C build check-flang-rt
```
## Error
flang-rt builds successfully, but the test executables fail to link:
```
/usr/bin/ld: libflang_rt.runtime.a(decimal-to-binary.cpp.o) uses IBM long double,
libLLVMSupport.a(APFloat.cpp.o) uses IEEE long double
/usr/bin/ld: failed to merge target specific data of file libLLVMSupport.a(APFloat.cpp.o)
clang++: error: linker command failed with exit code 1
```
## Suggested Fix
The LLVM runtimes build system should detect the host's long double format at configure time (e.g. by checking `LDBL_MANT_DIG` using the host compiler) and pass `-mabi=ieeelongdouble` to the just-built clang when building runtimes on IEEE quad ppc64le systems.
## Environment
- ppc64le (POWER10 in my case)
- Reproduces on: AlmaLinux 10.2 (GCC 14, IEEE quad long double)
- Does not reproduce on: Ubuntu 24.04 (GCC 13, IBM double-double)
Contributor guide
Research direction
Reproduce the failure with the provided CMake and Ninja commands on a ppc64le system reporting LDBL_MANT_DIG=113, then inspect the LLVM runtimes build configuration and flang-rt link path. Determine where the host long-double format is detected and where flags are passed to the just-built clang; done means check-flang-rt links successfully on IEEE-quad systems without regressing IBM double-double systems.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100