[Qbs] Linking with clang code coverage flags

resurrection at centrum.cz resurrection at centrum.cz
Fri Apr 27 15:04:59 CEST 2018

I ran into peculiar issue. Trying out the clang code coverage reporting using Source-base Code Coverage <https://clang.llvm.org/docs/SourceBasedCodeCoverage.html>. The command line examples works as expected. Adapting it to link with Qt and again from the command line it works as expected. However when running it from Qt Creator using Qbs the flags in question: -fprofile-instr-generate, -fcoverage-mapping are not passed to the linker because the compiling and linking are separated in two different commands. When specifying the cpp.linkerFlags in a Qbs Product however the error is printed:
/usr/bin/ld: -f may not be used without -shared
This is because the flags are being passed via -Wl instead of as flags to clang++. Of course when running it from command line the same error occurs. By specifying -shared as additional linker flag it will show some weird linking error so that is clearly not a way to do it.
The way to achieve this I believe is to specify *compiler* flags for *link* call. I am not aware if such a thing is possible in Qbs at the moment. Any ideas?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20180427/05a579b5/attachment.html>

More information about the Qbs mailing list