Forwarding taiki-e/cargo-llvm-cov#254 (comment) here with a simple C reproducer.
Code:
#include <stdio.h>
int main(){
printf("Hello");
return 0;
}
- Running without
--gc-sections:
$ clang hello.c -fprofile-instr-generate -fcoverage-mapping
$ ./a.exe
Hello
$ llvm-profdata merge -sparse default.profraw -o hello.profdata
$ llvm-cov show a.exe -instr-profile=hello.profdata
1| |#include <stdio.h>
2| |
3| 1|int main(){
4| 1| printf("Hello");
5| 1| return 0;
6| 1|}
- Running the same commands with
--gc-sections:
$ clang hello.c -fprofile-instr-generate -fcoverage-mapping -Wl,--gc-sections
$ ./a.exe
Hello
$ llvm-profdata merge -sparse default.profraw -o hello.profdata
$ llvm-cov show a.exe -instr-profile=hello.profdata
(llvm-cov show prints nothing)
- Reusing .profdata and .profraw from step 2 and binary without sections GC:
$ clang hello.c -fprofile-instr-generate -fcoverage-mapping
$ llvm-cov show a.exe -instr-profile=hello.profdata
warning: a.exe: profile data may be out of date - object is newer
1| |#include <stdio.h>
2| |
3| 1|int main(){
4| 1| printf("Hello");
5| 1| return 0;
6| 1|}
Only 2nd step is missing coverage info, which leads me to believe llvm-cov is looking for a symbol or section removed by --gc-sections. Especially removal of .lcovfun section by section GC is suspicious.
Forwarding taiki-e/cargo-llvm-cov#254 (comment) here with a simple C reproducer.
Code:
--gc-sections:--gc-sections:(
llvm-cov showprints nothing)Only 2nd step is missing coverage info, which leads me to believe
llvm-covis looking for a symbol or section removed by--gc-sections. Especially removal of.lcovfunsection by section GC is suspicious.