Installation Issue with Coverage

Hello,

I am trying to install LLVM through source code using the following commands to get the source coverage of Clang:

$git clone https://github.com/llvm/llvm-project.git
$cd llvm-project
$mkdir build
$cd build
$cmake -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Debug -DLLVM_USE_SANITIZER=Address -DLLVM_ENABLE_ASSERTIONS=On -DLLVM_BUILD_INSTRUMENTED_COVERAGE=On ../llvm
$make

When I try to install with make, I get the following error messages:

[  0%] Generating VCSRevision.h
[  0%] Building CXX object lib/Demangle/CMakeFiles/LLVMDemangle.dir/Demangle.cpp.o
[  0%] Building C object lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3.c.o
[  0%] Building CXX object utils/TableGen/CMakeFiles/obj.LLVMTableGenCommon.dir/Attributes.cpp.o
c++: error: unrecognized command line option ‘-fprofile-instr-generate=__PATH_TO_llvm-project__/build/profiles/%4m.profraw’
c++: error: unrecognized command line option ‘-fprofile-instr-generate=__PATH_TO_llvm-project__/build/profiles/%4m.profraw’
cc: error: unrecognized command line option ‘-fprofile-instr-generate=__PATH_TO_llvm-project__/build/profiles/%4m.profraw’
c++: error: unrecognized command line option ‘-fcoverage-mapping’
make[2]: *** [lib/Demangle/CMakeFiles/LLVMDemangle.dir/build.make:76: lib/Demangle/CMakeFiles/LLVMDemangle.dir/Demangle.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:14085: lib/Demangle/CMakeFiles/LLVMDemangle.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
c++: error: unrecognized command line option ‘-fcoverage-mapping’
make[2]: *** [utils/TableGen/CMakeFiles/obj.LLVMTableGenCommon.dir/build.make:76: utils/TableGen/CMakeFiles/obj.LLVMTableGenCommon.dir/Attributes.cpp.o] Error 1
[  0%] Building C object lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_dispatch.c.o
make[1]: *** [CMakeFiles/Makefile2:14347: utils/TableGen/CMakeFiles/obj.LLVMTableGenCommon.dir/all] Error 2
cc: error: unrecognized command line option ‘-fcoverage-mapping’
make[2]: *** [lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/build.make:76: lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
cc: error: unrecognized command line option ‘-fprofile-instr-generate=__PATH_TO_llvm-project__/build/profiles/%4m.profraw’
[  0%] Building C object lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_portable.c.o
cc: error: unrecognized command line option ‘-fprofile-instr-generate=__PATH_TO_llvm-project__/build/profiles/%4m.profraw’
cc: error: unrecognized command line option ‘-fcoverage-mapping’
make[2]: *** [lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/build.make:90: lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_dispatch.c.o] Error 1
cc: error: unrecognized command line option ‘-fcoverage-mapping’
make[2]: *** [lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/build.make:104: lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_portable.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:14242: lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/all] Error 2
[  0%] Built target llvm_vcsrevision_h
make: *** [Makefile:156: all] Error 2

I can install (compile) LLVM+Clang without “-DLLVM_USE_SANITIZER=Address -DLLVM_ENABLE_ASSERTIONS=On -DLLVM_BUILD_INSTRUMENTED_COVERAGE=On” options for cmake. I would greatly appreciate it if anyone could give me an insight into what I am doing wrong.

Thank you!

It’s unclear what your host compiler is (possibly gcc), but it doesn’t support the needed command line options. You can either install Clang and use that as your host compiler or do a boostrapping build to build a regular Clang first and then use that Clang to build the instrumented Clang.

1 Like

Thank you for your reply @smeenai . My default compiler is GCC 9.4.0. I guess you are suggesting installing another version of Clang and using it as a compiler to compile the Clang version that I want to compile in a debug mode with coverage mode on by adding -DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++ to make?

Yup, that should work.

1 Like