Re: [poky] Compiling Poky with Clang and Clang Coverage Flags

Khem Raj <[email protected]>
Newsgroups org.yoctoproject.lists.poky
Message-ID <CAMKF1sqzzdZyasyPqiM_P2-4yzSOxDkTuLA8iqEOvxCHmoF+QA@mail.gmail.com>
Can you try something like this

*TARGET_CPPFLAGS:prepend:class-target:toolchain-clang =
"-fprofile-instr-generate -fcoverage-mapping "*




On Mon, Apr 22, 2024 at 3:42 AM Hope Sneddon via lists.yoctoproject.org
<[email protected]> wrote:

> 
>
> 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
> <http://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
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#13327):
> https://lists.yoctoproject.org/g/poky/message/13327
> Mute This Topic: https://lists.yoctoproject.org/mt/105662464/1997914
> Group Owner: [email protected]
> Unsubscribe: https://lists.yoctoproject.org/g/poky/unsub [
> [email protected]]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
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.