Yoe distribution-generated native clang-15 executable attempts to link to libclang_rt.builtins-x86_64.a and complains the file is missing. However, OpenBMC distribution-generated native clang-14 executable does not suffer from this issue. This issue is found for a pull request to meta-openembedded. A minimally working example noted in the pull request can be listed as follows:
$ cat a.cpp
#include <stdio.h>
int main() { printf("Hey!\n"); }
clang-15 in Yoe:
$ ~/yoe/build/tmp/work/x86_64-linux/clang-native/15.0.0-r0/build/bin/clang++ -nostdlib++ /tmp/a.cpp
/usr/bin/ld: cannot find /usr/lib/clang/15.0.0/lib/linux/libclang_rt.builtins-x86_64.a: No such file or directory
/usr/bin/ld: cannot find -lunwind
Yoe distro uses clang defaulting to llvm runtime which perhaps OpenBMC is not doing. Its still defaulting to GCC runtime, this works unintended in native case because runtime default is gcc on linux sysems but does not work for yoe native clang compiler due to different defaults.
meta-clang now has a class which should be inherited to use it as a native compiler
Perhaps this is something you can use if you are using native clang during compiling perfetto
Thanks for the speedy reply, I was able to build perfetto by setting the compiler command to ${BUILD_CXX} ${BUILD_LDFLAGS} in the recipe as well as inheriting the clang-native class.
I’ve updated the pull request as well.
It seems to achieve the same effect as specifying the compiler command to ${RECIPE_SYSROOT_NATIVE}/usr/bin/clang++ --rtlib=libgcc --unwindlib=libgcc and not inheriting from clang-native, but I guess inheriting from clang-native makes it clear to the user of the recipe that the recipe makes use of clang as a native compiler, and makes it easier for the recipe to pick up any improvements in the clang-native class as meta-clang gets updated.
This recipe (perfetto) is not clang-only, it has an is_clang switch that switches clang on or off.
Whether this recipe depends and inherits on clang-native depends on whether the user sets their Yocto toolchain to “clang”. (Yoe does this, but some other distributions like OpenBMC doesn’t.)
So I guess it probably doesn’t need to be marked as clang-only?