Compiling Poky with Clang and Clang Coverage Flags

Hope Sneddon <[email protected]>
Newsgroups org.yoctoproject.lists.poky
Message-ID <SL2P216MB127763AD758C2A81F525573499122@SL2P216MB1277.KORP216.PROD.OUTLOOK.COM>

Hi Poky Community,

I am trying to build a Yocto code base using Clang and LLVM as the default toolchain (i.e. nonclangables still compile with GCC) as per the “Using Clang Compiler with Yocto Project” presentation instructions<https://elinux.org/images/f/ff/Yps2021.11-clang.pdf>. The issue is I need to compile with code coverage via the Clang coverage flags which do not seem to work with Yocto/ Poky by default. I have simplified my application all the way back to a freshly cloned Poky repo with only the following changes to reproduce the error, proving it is not a problem caused by custom configurations/ use case development.

That is, to show the issue, in a fresh clone of Poky, the following lines are added to local.conf:
TOOLCHAIN = "clang"
TARGET_CPPFLAGS:prepend = "-fprofile-instr-generate -fcoverage-mapping "
RUNTIME = "llvm"
CLANGSDK = "1"

Simple Clang compilation of Poky works, however I need to compile with code coverage which doesn’t seem to currently work by default (i.e. add the Clang coverage flags in local.conf using TARGET_CPPFLAGS:prepend = "-fprofile-instr-generate -fcoverage-mapping ").

To demonstrate this I have implemented a simple “hello-world” recipe as hello-world_1.0.0.bb (extract below excludes recipe header lines):
S = "${WORKDIR}/${PN}-${PV}"

python do_hello_world(){
    print("Hello World\n")
}

addtask do_hello_world

Compiling this via the command bitbake hello-world fails.

Failure is caused by the do_compile step to failing due to oe_runmake failing:
ERROR: gcc-cross-x86_64-11.4.0-r0 do_compile: oe_runmake failed.

The log data from oe_runmake indicates the failure is induced at the following oe_runmake step (log output):
checking for suffix of object files... configure: error: in `/home/dev/poky/build/tmp/work/x86_64-linux/gcc-cross-x86_64/11.4.0-r0/gcc-11.4.0/build.x86_64-linux.x86_64-poky-linux/x86_64-poky-linux/libgcc':
| configure: error: cannot compute suffix of object files: cannot compile

The failure of gcc_cross does not seem to be representative of the actual root of the issue, so debugging this is proving difficult. Any guidance on how to get Clang coverage working would be greatly appreciated as my application requires the employment of a lot of the llvm-cov toolset (the motivation for substituting compiler in the first place).

Thank you,

Hope
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.