From: Christian Eggers <ceggers@arri.de>
To: Khem Raj <raj.khem@gmail.com>
Cc: <openembedded-devel@lists.openembedded.org>
Subject: Re: [oe] [meta-oe][RFC PATCH] include-what-you-use: new recipe
Date: Fri, 19 Jul 2024 16:10:07 +0200 [thread overview]
Message-ID: <3479754.LZWGnKmheA@n9w6sw14> (raw)
In-Reply-To: <CAMKF1srofvxUUgGQqXBCxvLpTSkbK2puFamrL_U7Vmvb+BC6Dw@mail.gmail.com>
Hi Khem,
sorry for the delay.
On Tuesday, 16 July 2024, 17:42:33 CEST, Khem Raj wrote:
> On Tue, Jul 16, 2024 at 7:57 AM Christian Eggers <ceggers@arri.de> wrote:
> >
> > Hi Khem,
> >
> >
> > On Tuesday, 16 July 2024, 15:45:54 CEST, Khem Raj wrote:
> > > On Tue, Jul 16, 2024 at 1:08 AM Christian Eggers <ceggers@arri.de> wrote:
> > >
> > > > On Monday, 15 July 2024, 16:18:14 CEST, Khem Raj wrote:
> > > > > On Mon, Jul 15, 2024 at 5:18 AM Christian Eggers via
> > > > lists.openembedded.org
> > > > > <ceggers=arri.de@lists.openembedded.org> wrote:
> > > > >
> > > > > > Based on proposal send previously here:
> > > > > > https://lists.yoctoproject.org/g/yocto/topic/recipe_for/83279588
> > > > > >
> > > > > > This recipe depends on meta-clang, so should it be added to that layer?
> > > > > >
> > > > > > Unfortunately the 'include-what-you-use' (iwyu) tool doesn't work yet.
> > > > > > Although I have installed nativesdk-clang (via CLANGSDK = "1") and
> > > > > > nativesdk-include-what-you-use packages, the C++ standard headers are
> > > > > > not found:
> > > > > >
> > > > > > include-what-you-use
> > > > > >
> > > > --sysroot=/opt/poky/5.0.2/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-musleabi
> > > > > > impl/Fdt.cpp
> > > > > > impl/Fdt.cpp:9:10: fatal error: 'cerrno' file not found
> > > > > > 9 | #include <cerrno>
> > > > > > | ^~~~~~~~
> > > > > >
> > > > > > As iwyu uses Clang and I have no experience working with it, this is
> > > > > > probably only a beginner mistake. Can Clang use the C++ headers
> > > > provided
> > > > > > by libstdc++, or do I need to install further packages?
> > > > > >
> > > > >
> > > > > It can but it seems your SDK install might be missing any c++ runtime so
> > > > > check a simple program that includes say <iostream> header and try
> > > > > compiling it
> > > > My SDK definitely contains std:: C++ headers for target and nativesdk. But
> > > > the
> > > > libstdc++ C++ headers are installed in GCC specific locations:
> > > >
> > > > /opt/poky/5.0.2/sysroots/x86_64-pokysdk-linux/usr/include/c++/13.3.0/
> > > >
> > > > /opt/poky/5.0.2/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-musleabi/usr/include/c++/13.3.0
> > > >
> > > > How can Clang know that the C++ headers are located in the (GCC specific)
> > > > c++/13.3.0
> > > > sub directory?
> > >
> > >
> > > Try adding -stdlib=libstdc++ on clang cmdline
> >
> > The following seems to work:
> > include-what-you-use \
> > -target arm-poky-linux-musleabi \
> > --sysroot /opt/poky/5.0.2/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-musleabi \
> > -stdlib++-isystem /opt/poky/5.0.2/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-musleabi/usr/include/c++/13.3.0/arm-poky-linux-musleabi \
> > -stdlib++-isystem /opt/poky/5.0.2/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-musleabi/usr/include/c++/13.3.0 \
> > File.cpp
> >
> > Is there a way to make this a little bit handier? I would like to avoid hard coding this into my CMake toolchain file.
> >
>
> Hmm so -stdlib=libstdc++ does not work ?
I cannot reproduce what exactly went wrong, but now the following works fine:
include-what-you-use -target arm-poky-linux-musleabi --sysroot /opt/poky/5.0.2/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-musleabi test.cpp
include-what-you-use -target x86_64-pokysdk-linux --sysroot /opt/orbiter-tiny/5.0.2/sysroots/x86_64-pokysdk-linux test.cpp
So neither '-stdlib=libstdc++' nor '-stdlib++-isystem' is required anymore.
I was also able to integrate this into a CMake project (built with the SDK) by adding the following to my toolchain file:
set(CMAKE_C_INCLUDE_WHAT_YOU_USE include-what-you-use;-target;arm-poky-linux-musleabi;--sysroot;$ENV{SDKTARGETSYSROOT})
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE include-what-you-use;-target;arm-poky-linux-musleabi;--sysroot;$ENV{SDKTARGETSYSROOT})
The IWYU tool states itself as "experimental software", so the output
better should be interpreted by a human. I've tested with an existing
code base and got many valuable hints for missing/superfluous
#include statements. The results are quite good for std:: C/C++
headers, but other libraries like Boost need further improvements.
Can this recipe be added to meta-clang (due to it's dependencies to libclang/libllvm)?
next prev parent reply other threads:[~2024-07-19 14:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-15 12:17 [meta-oe][RFC PATCH] include-what-you-use: new recipe Christian Eggers
2024-07-15 14:18 ` [oe] " Khem Raj
2024-07-16 8:08 ` Christian Eggers
2024-07-16 13:45 ` Khem Raj
2024-07-16 14:57 ` Christian Eggers
2024-07-16 15:42 ` Khem Raj
2024-07-19 14:10 ` Christian Eggers [this message]
2024-07-19 15:57 ` Khem Raj
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3479754.LZWGnKmheA@n9w6sw14 \
--to=ceggers@arri.de \
--cc=openembedded-devel@lists.openembedded.org \
--cc=raj.khem@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.