[LTO] Symbols referenced only by llvm.reloc.none are dropped
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
See Godbolt here: https://godbolt.org/z/a7bTPacre
Both clang and gcc work fine, but `clang -flto` fails.
This bug is found via compiling llvm-libc with `-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON` on a baremetal RV32 target. See the code below:
https://github.com/llvm/llvm-project/blob/036ef9736e2be6732c63853d1fb00ca0544eba96/libc/src/stdio/baremetal/printf.cpp#L29-L34
In this case `__printf_float` becomes undefined.
Contributor guide
Research direction
Start with the Godbolt reproducer and the referenced lib/llvm-libc/src/stdio/baremetal/printf.cpp lines 29-34, using the baremetal RV32 LTO configuration described in the issue. Trace how llvm.reloc.none references are handled during LTO and verify that __printf_float is retained rather than becoming undefined. Done means the reproducer and the llvm-libc configuration link successfully with -flto.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100