meta-clang
meta-clang copied to clipboard
folder /usr/lib/clang/14.0.3/lib missing in nativesdk
Hi, while trying to update our project from dunfell to kirkstone I am currently stumbling across the error that a CMake build using the nativesdk is failing with the following error message:
CMake command: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="[project-repo]/build/debug/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="[project-repo]/build/debug/package" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Debug" "[project-repo]"
-- Using Conan toolchain: [project-repo]/build/debug/conan_toolchain.cmake
-- The C compiler identification is Clang 14.0.3
-- The CXX compiler identification is Clang 14.0.3
-- Check for working C compiler: /opt/[project-name]/0.1/sysroots/x86_64-pokysdk-linux/usr/bin/clang
-- Check for working C compiler: /opt/[project-name]/0.1/sysroots/x86_64-pokysdk-linux/usr/bin/clang -- broken
CMake Error at /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"/opt/[project-name]/0.1/sysroots/x86_64-pokysdk-linux/usr/bin/clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: [project-repo]/build/debug/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_0ec2d/fast && /usr/bin/make -f CMakeFiles/cmTC_0ec2d.dir/build.make CMakeFiles/cmTC_0ec2d.dir/build
make[1]: Entering directory '[project-repo]/build/debug/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_0ec2d.dir/testCCompiler.c.o
/opt/[project-name]/0.1/sysroots/x86_64-pokysdk-linux/usr/bin/clang -m64 -o CMakeFiles/cmTC_0ec2d.dir/testCCompiler.c.o -c [project-repo]/build/debug/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_0ec2d
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_0ec2d.dir/link.txt --verbose=1
/opt/[project-name]/0.1/sysroots/x86_64-pokysdk-linux/usr/bin/clang -m64 -m64 -pie -fuse-ld=lld -stdlib=libc++ -L/usr/lib/llvm-12/lib/ -Wl,-rpath,/usr/lib/llvm-12/lib/ -Wl,--export-dynamic -Bsymbolic CMakeFiles/cmTC_0ec2d.dir/testCCompiler.c.o -o cmTC_0ec2d
ld.lld: error: cannot open /usr/lib/clang/14.0.3/lib/linux/libclang_rt.builtins-x86_64.a: No such file or directory
ld.lld: error: unable to find library -l:libunwind.so
ld.lld: error: cannot open /usr/lib/clang/14.0.3/lib/linux/libclang_rt.builtins-x86_64.a: No such file or directory
ld.lld: error: unable to find library -l:libunwind.so
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [CMakeFiles/cmTC_0ec2d.dir/build.make:87: cmTC_0ec2d] Error 1
make[1]: Leaving directory '[project-repo]/build/debug/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_0ec2d/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "[project-repo]/build/debug/CMakeFiles/CMakeOutput.log".
See also "[project-repo]/build/debug/CMakeFiles/CMakeError.log".
I suspect that is because libclang_rt.builtins-x86_64.a is not present in the SDK. After adding this line
TOOLCHAIN_HOST_TASK:append = " nativesdk-cmake nativesdk-clang nativesdk-compiler-rt-staticdev nativesdk-compiler-rt-dev"
to my conf the file at least shows up in the build folder:
$ find build -name "libclang_rt.builtins-x86_64.a"
build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-compiler-rt/14.0.3-r0/packages-split/nativesdk-compiler-rt-staticdev/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/usr/lib/clang/14.0.3/lib/linux/libclang_rt.builtins-x86_64.a
build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-compiler-rt/14.0.3-r0/image/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/usr/lib/clang/14.0.3/lib/linux/libclang_rt.builtins-x86_64.a
build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-compiler-rt/14.0.3-r0/package/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/usr/lib/clang/14.0.3/lib/linux/libclang_rt.builtins-x86_64.a
build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-compiler-rt/14.0.3-r0/build/lib/clang/14.0.3/lib/linux/libclang_rt.builtins-x86_64.a
But these folders apparently do not get copied into the nativesdk:
$ ls /opt/[project-name]/0.1/sysroots/x86_64-pokysdk-linux/usr/lib/clang/14.0.3
include
I am new to working with yocto in general, so sorry if this is the incorrect place to post this, but to me it seems like a meta-clang-specific problem.
The layer-repositories have all been set to their respective kirkstone-branches:

you need to add then to target package list. So have you set
CLANGSDK = "1"
in local.conf ? if not try that out. Secondly you can try adding something like below
TOOLCHAIN_TARGET_TASK:append = " libcxx-dev libcxx-staticdev compiler-rt-dev compiler-rt-staticdev"