]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
meta: Enable clang as default native compiler kraj/clang-as-hostcc
authorKhem Raj <raj.khem@gmail.com>
Wed, 22 Oct 2025 06:07:26 +0000 (23:07 -0700)
committerKhem Raj <raj.khem@gmail.com>
Fri, 31 Oct 2025 18:57:23 +0000 (11:57 -0700)
Fix few packages which do not yet build with clang
There is one issue to tackle, when using clang for cross compiler
it also installs native clang which is then picked by the build system
if a package's build system has pieces to build for native build host
There are only handful of such packages but there are few e.g.
gmp, nettle which check for CC_FOR_BUILD during configure and it ends
up using clang from own build and does not find right libraries in
native sysroot, maybe we should add libcxx-native and compiler-rt-native
to DEFAULT_DEPENDENCIES list when llvm runtime is used.

gobject-introspection uses gcc for native builds

Its fails when built with clang

FileNotFoundError: [Errno 2] No such file or directory: 'ldd'
...

| FAILED: [code=1] gir/GLib-2.0.gir

Signed-off-by: Khem Raj <raj.khem@gmail.com>
meta/classes/toolchain/clang-native.bbclass
meta/conf/bitbake.conf
meta/recipes-devtools/clang/common-clang.inc
meta/recipes-gnome/gobject-introspection/gobject-introspection_1.84.0.bb
meta/recipes-support/gmp/gmp_6.3.0.bb
meta/recipes-support/nettle/nettle_3.10.2.bb

index 006be9fadd6d897edde46a9ec08b81379f86ff61..941a5fd6e4692c01558ad7a345d2012085475a32 100644 (file)
@@ -13,6 +13,5 @@ BUILD_OBJDUMP = "${BUILD_PREFIX}llvm-objdump"
 BUILD_NM = "${BUILD_PREFIX}llvm-nm"
 BUILD_READELF = "${BUILD_PREFIX}llvm-readelf"
 
-DEPENDS += "clang-native libcxx-native compiler-rt-native"
-
-BUILD_LDFLAGS += " --rtlib=libgcc --unwindlib=libgcc"
+BUILD_LDFLAGS += "-rtlib=libgcc -unwindlib=libgcc -stdlib=libc++"
+BUILD_CXXFLAGS += "-stdlib=libc++"
index 5406e542db64ddf22515e0e8e7eb1f5822ba910c..6a77a4461fb94ddce320851ce057891145897da2 100644 (file)
@@ -516,10 +516,12 @@ HOSTTOOLS_DIR = "${TMPDIR}/hosttools"
 
 # Tools needed to run builds with OE-Core
 HOSTTOOLS += " \
-    [ ar as awk basename bash bunzip2 bzip2 cat chgrp chmod chown chrpath cmp comm cp cpio \
+    [ ar as awk basename bash bunzip2 bzip2 cat chgrp chmod chown chrpath clang clang++ cmp comm cp cpio \
     cpp cut date dd diff diffstat dirname du echo egrep env expand expr false \
     fgrep file find flock g++ gawk gcc getconf getopt git grep gunzip gzip \
-    head hostname iconv id install ld ldd ln ls make md5sum mkdir mkfifo mknod \
+    head hostname iconv id install ld ld.lld lld llvm-ar llvm-as llvm-config llvm-nm \
+    llvm-objcopy llvm-objdump llvm-nm llvm-ranlib llvm-readelf llvm-strip llvm-config \
+    ln ls make md5sum mkdir mkfifo mknod \
     mktemp mv nm objcopy objdump od patch perl pr printf pwd \
     python3 pzstd ranlib readelf readlink realpath rm rmdir rpcgen sed seq sh \
     sha1sum sha224sum sha256sum sha384sum sha512sum \
index 416258c5d3553ce9023f311bbc3ee4be423b5f3a..351e7afa3ef324d563a39a091660cc1f783cfda8 100644 (file)
@@ -56,4 +56,7 @@ EXTRA_OECMAKE += "-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON"
 # will include the git server URL.
 EXTRA_OECMAKE += "-DLLVM_APPEND_VC_REV=OFF"
 
+# Enable linking with libc++ when its the distro default C++ runtime
+EXTRA_OECMAKE += "${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', '-DLLVM_ENABLE_LIBCXX=ON', '', d)}"
+
 require common.inc
index f6797cd2e5e6d7524ce506da3864407e65d3b390..07fc284fb3a70c62df6a804ec5098565b8ca7b24 100644 (file)
@@ -22,6 +22,8 @@ SRC_URI:append:class-native = " file://0001-Relocate-the-repository-directory-fo
 
 inherit meson pkgconfig gtk-doc python3targetconfig qemu gobject-introspection-data upstream-version-is-even multilib_script
 
+TOOLCHAIN_NATIVE = "gcc"
+
 GTKDOC_MESON_OPTION = "gtk_doc"
 
 MULTILIB_SCRIPTS = "${PN}-tools:${bindir}/g-ir-annotation-tool ${PN}-tools:${bindir}/g-ir-scanner"
index 8f18bdca1b53effe147fa8607637971bab10fb8b..d3bd36f4e0e1fe671e55802f7d8a03222087121a 100644 (file)
@@ -22,6 +22,8 @@ SRC_URI[sha256sum] = "ac28211a7cfb609bae2e2c8d6058d66c8fe96434f740cf6fe2e47b000d
 EXTRA_OECONF += " --enable-cxx=detect"
 EXTRA_OECONF:append:mipsarchr6 = " --disable-assembly"
 
+TOOLCHAIN_NATIVE:class-target = "gcc"
+
 PACKAGES =+ "libgmpxx"
 FILES:libgmpxx = "${libdir}/libgmpxx${SOLIBS}"
 
index e651f68cb949129dc9827b192a5304fdfff7690c..e6c21f976b999b8880e7d216a9d1015980d312f1 100644 (file)
@@ -14,6 +14,8 @@ LIC_FILES_CHKSUM = "file://COPYING.LESSERv3;md5=6a6a8e020838b23406c81b19c1d46df6
 
 DEPENDS += "gmp"
 
+TOOLCHAIN_NATIVE:class-target = "gcc"
+
 SRC_URI = "${GNU_MIRROR}/${BPN}/${BP}.tar.gz \
            file://Add-target-to-only-build-tests-not-run-them.patch \
            file://run-ptest \