Skip to contentSkip to conversation

libcxx: Create packageconfig for cross unwinder support

PATCH New Khem Raj 1 participant 2 messages Aug 7, 2025

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/2 libcxx: Create packageconfig for cross unwinder support

cross-unwinding can pass exception across runtimes e.g. Multi-language applications ( nodejs native modules, python C extensions )

However, cross-unwinding is not default in libcxx for sometime [1] it requires special handling at runtime by apps who use it Switch recipe defaults to upstream defaults, which is to turn it off

This means native unwinding ( with in same runtime ) is build by default which is the most common case.

This also fixes libcxx/libunwind build errors
when enabling TC_CXX_RUNTIME = "llvm" on aarch64 particularly

[1] https://github.com/llvm/llvm-project/commit/85624c5de3e831ffa01fdc2d159e3d69c30de08d

---
 meta/recipes-devtools/clang/libcxx_git.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/clang/libcxx_git.bb +1 -1
index d6bacc33d6b..b0ee3925f43 100644
@@ -20,6 +20,7 @@ PACKAGECONFIG[exceptions] = "-DLIBCXXABI_ENABLE_EXCEPTIONS=ON -DLIBCXX_ENABLE_EX
 PACKAGECONFIG[no-atomics] = "-D_LIBCXXABI_HAS_ATOMIC_BUILTINS=OFF -DCMAKE_SHARED_LINKER_FLAGS='-latomic',,"
 PACKAGECONFIG[compiler-rt] = "-DLIBCXX_USE_COMPILER_RT=ON -DLIBCXXABI_USE_COMPILER_RT=ON -DLIBUNWIND_USE_COMPILER_RT=ON,,compiler-rt"
 PACKAGECONFIG[unwind-shared] = "-DLIBUNWIND_ENABLE_SHARED=ON,-DLIBUNWIND_ENABLE_SHARED=OFF,,"
+PACKAGECONFIG[unwind-cross] = "-DLIBUNWIND_ENABLE_CROSS_UNWINDING=ON,-DLIBUNWIND_ENABLE_CROSS_UNWINDING=OFF,,"
 
 DEPENDS:append:class-target = " virtual/cross-c++ ${MLPREFIX}clang-cross-${TARGET_ARCH} virtual/${MLPREFIX}libc virtual/${MLPREFIX}compilerlibs"
 DEPENDS:append:class-nativesdk = " virtual/cross-c++ clang-crosssdk-${SDK_SYS} nativesdk-compiler-rt"
@@ -64,7 +65,6 @@ EXTRA_OECMAKE += "\
                   -DCMAKE_CROSSCOMPILING=ON \
                   -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \
                   -DLLVM_ENABLE_RTTI=ON \
-                  -DLIBUNWIND_ENABLE_CROSS_UNWINDING=ON \
                   -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
                   -DLIBCXXABI_INCLUDE_TESTS=OFF \
                   -DLIBCXXABI_ENABLE_SHARED=ON \
author
#1 lore raw

PATCH 2/2 clang-cross: Create <cross>-clang binary copy instead of symlink

With clang cleanup in [1] we ended up removing this logic, which is still required.

This ensures that search path for subsequent tools e.g. linker assembler are searched in the same dir where <cross>-clang is installed. If its a symlink to ../clang then the reference installation dir is ../ and all cross-tools are not there so clang will fail to find assembler/linker from cross staging area and use /usr/bin/ld or /usr/bin/as which we do not want

[1] https://git.openembedded.org/openembedded-core/commit/meta/recipes-devtools/clang/clang-cross_git.bb?id=5d96ed55acf7b9a908241222097ad809355de7cf

---
 meta/recipes-devtools/clang/clang-cross_git.bb | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
meta/recipes-devtools/clang/clang-cross_git.bb +7 -1
index 33b01e42349..2ec15dd1dfc 100644
@@ -15,7 +15,7 @@ DEPENDS = "clang-native virtual/cross-binutils ${@bb.utils.contains('DISTRO_FEAT
 
 do_install() {
 	install -d ${D}${bindir}
-	for tool in clang clang++ clang-tidy lld ld.lld llvm-profdata \
+	for tool in clang-tidy lld ld.lld llvm-profdata \
             llvm-nm llvm-ar llvm-as llvm-ranlib llvm-strip llvm-objcopy llvm-objdump llvm-readelf \
             llvm-addr2line llvm-dwp llvm-size llvm-strings llvm-cov
 	do
@@ -23,4 +23,10 @@ do_install() {
 			ln -sf ../$tool ${D}${bindir}/${TARGET_PREFIX}$tool
 		fi
 	done
+	# GNU Linker and assembler is needed in same directory as clang binaries else
+	# it will fallback to host linker which is not desired
+	install -m 0755 ${STAGING_BINDIR_NATIVE}/clang ${D}${bindir}/${TARGET_PREFIX}clang
+	ln -sf ${TARGET_PREFIX}clang ${D}${bindir}/${TARGET_PREFIX}clang++
 }
+# clang driver being copied above is already stripped
+INHIBIT_SYSROOT_STRIP = "1"