Flang (Target: x86_64-unknown-linux-gnu) linking error with REAL16 types, missing __truncsfhf2
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Some programs with REAL(REAL16) types fail to link unless "-lclang_rt.builtins" is appended to the command line. Reproducer:
```fortran
Program exhibit_hp
Use iso_fortran_env, only:real16
Real(real16) x
Integer a
a = -12344
x = a
Print *,x
End Program
```
The missing references seen are __extendhfsf2 __extendhftf2 __truncdfhf2 __truncsfhf2 __trunctfhf2 .
In AddLibgcc of clang/lib/Driver/ToolChains/CommonArgs.cpp, we see the line
` if (D.IsFlangMode() && TC.getArch() == llvm::Triple::aarch64) {
`
which looks like it needs to be modified to include the x86_64 target.
Contributor guide
Research direction
Reproduce the REAL16 linking failure for Flang on x86_64-unknown-linux-gnu using the Fortran program and compare linking with and without -lclang_rt.builtins. Then inspect AddLibgcc in clang/lib/Driver/ToolChains/CommonArgs.cpp, focusing on the Flang architecture condition. Done means the reproduced program links without requiring the extra library.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, fortran, linux
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100