[Qbs] Linking with clang code coverage flags

Christian Kandeler christian.kandeler at qt.io
Fri Apr 27 15:16:28 CEST 2018


On Fri, 27 Apr 2018 15:04:59 +0200
<resurrection at centrum.cz> wrote:

> 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?

I believe you are looking for this:
https://doc.qt.io/qbs/qml-qbsmodules-cpp.html#driverFlags-prop


Christian



More information about the Qbs mailing list