I am trying to create code coverage files for a small C program compiled with clang on Debian Linux. Here is what I did:
neuron@debian :~/temp$ ls main.c test.c test.h neuron@debian :~/temp$ clang *.c neuron@debian :~/temp$ ./a.out 0
This is exactly as expected, I can compile and run. Now try turning on coverage.
neuron@debian :~/temp$ clang --coverage *.c /usr/bin/ld: cannot find /usr/bin/../lib/libprofile_rt.a: No such file or directory clang: error: linker command failed with exit code 1 (use -v to see invocation)
Trying to enable the library for linking.
neuron@debian :~/temp$ clang --coverage -lprofile_rt *.c /usr/bin/ld: cannot find -lprofile_rt clang: error: linker command failed with exit code 1 (use -v to see invocation)
Library Search:
neuron@debian :~/temp$ find / -name \*profile_rt\* 2>/dev/null /usr/lib/llvm-3.0/lib/libprofile_rt.so /usr/lib/llvm-3.0/lib/libprofile_rt.a neuron@debian :~/temp$ clang --coverage -lprofile_rt -L/usr/lib/llvm-3.0/lib *.c /usr/bin/ld: cannot find /usr/bin/../lib/libprofile_rt.a: No such file or directory clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here's a more detailed output from the last command: http://pastie.org/8468331 . What concerns me there:
- the linker uses tons of gcc libraries for communication (although this may be the result of llvm not having its own binouts);
- It
/usr/bin/../lib/libprofile_rt.a at the profiling library in /usr/bin/../lib/libprofile_rt.a instead of the path I provided.
If we pass arguments to the linker, the output will be the same:
neuron@debian :~/temp$ clang --coverage -Wl,-L/usr/lib/llvm-3.0/lib *.c -lprofile_rt /usr/bin/ld: cannot find /usr/bin/../lib/libprofile_rt.a: No such file or directory clang: error: linker command failed with exit code 1 (use -v to see invocation)
What am I doing wrong?
source share