llvm-project
llvm-project copied to clipboard
Profile Instrumentation and linker (gnu) garbage collection
| Bugzilla Link | 25286 |
| Version | unspecified |
| OS | Linux |
| CC | @vns-mn |
Extended Description
If you use the latest clang to build an instrumented executable or shared library with garbage collection turned on, you will get a linker error if the linker is gnu ld:
clang -fprofile-instr-generate -fdata-sections -ffunction-sections -Wl,--gc-sections t.c
The affected platform is Linux and FreeBSD. This is basically a gnu linker bug:
https://sourceware.org/bugzilla/show_bug.cgi?id=19161
It is possible to workaround this by changing clang driver, but the solution is hacky and temporary, so not desirable.
If you hit the problem, here are three solutions:
- update the gnu linker (when the fix is released)
- use gold linker:
-fuse-ld=gold - use the following linker script -- name it
prf_data.x
SECTIONS {
__llvm_prf_data : { KEEP(*(__llvm_prf_data)) }
}
and add the following link option: -Wl,-T,prf_data.x
Keep this bug open as a place holder to document the issue.