Skip to contentSkip to conversation

clang: Add clang C/C++ toolchain

PATCH Superseded Khem Raj 5 participants 51 messages May 21, 2025 – Jun 5, 2025

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

v2 cover clang: Add clang C/C++ toolchain

Clang also provided a full fledged C/C++ cross compiler which is capable of building any C/C++ components.

A mechanism is added to select the toolchain using

TOOLCHAIN = "clang"

in config metadata. This will also add an entry into OVERRIDES 'toolchain-<COMPILER>', e.g. toolchain-clang which can be used to define clang-specific aspects in metadata.

All packages are not full buildable with clang, e.g. glibc which rely on some extentions which are only available in gcc. Such exceptions are made in config metadata using a global file called

meta/conf/distro/include/default-toolchain.inc

This file can be added in every layer to define these details themselves bitbake will include all such files auotmaticlally.

Defaults are kept as it is, nothing is expected to change if its not enabled

World builds for qemuarm/qemuarm64/qemuppc/qemumips/qemux86_64 are successful with some exceptions

vulkan-samples - qemuarm64/qemux86-64
bluez - qemuppc
compiler-rt-sanitizers - qemumips

---
Changes in v2:
- Move the changed from default-toolchains.inc file into respective recipes
- Drop adding libomp as toolchain-clang dependency for rpm, it will be
needed when clang is used for rpm, as of now it does not
- Fix musl world builds for qemuarm/qemuarm64/qemuriscv64/qemuriscv32
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Khem Raj (28):
toolchain: Provide abstraction for choosing per-recipe toolchain clang.bbclass: Specify ldso when using usermerge
vte: Disable gi data generation when using clang on arm
clang: Add compiler-rt to default deps when using clang compiler
gnu-efi: Use objcopy from GNU binutils with clang
tcf-agent: Fix ranlib call when using llvm-ranlib
pulseaudio: Treat -Wunused-command-line-argument as error
libjpeg-turbo: Fix build on mips/clang
pixman: Fix build with mips/clang
systemd-boot: Remove -mfpmath=sse option from cflags
vulkan-samples: Disable overriding-option as error
openssl: Link with libatomic on x86/clang
qemu: Link with libatomic on x86/clang
bluez: Disable invalid-pp-token warning with clang
gcc: Always use GCC toolchain
glibc: Always use GCC toolchain
grub,grub-efi: Pin to using gcc on aarch64
valgrind: Use gcc to compile on riscv64
syslinux: Pin to using GCC toolchain
systemtap: Pin to build with GCC
webkitgtk: Use gcc to compile for arm target
pseudo: Pin to using GCC compiler
rpm: Always use gcc compiler
pulseaudio: Pin to use GCC compiler
seatd: Disable sign-compare warning as error on clang
busybox: Fix build on architectures without SYS_settimeofday
systemd-boot: Use gcc on musl/arm
perf: Do not treat maybe-uninitialized warnings as errors

 meta/classes-global/base.bbclass                   |  5 +++
 meta/classes-recipe/cross-canadian.bbclass         |  2 +
 meta/classes-recipe/cross.bbclass                  |  2 +
 meta/classes-recipe/crosssdk.bbclass               |  2 +
 meta/classes-recipe/native.bbclass                 |  2 +
 meta/classes-recipe/nativesdk.bbclass              |  2 +
 meta/classes/clang-native.bbclass                  | 28 ++++++++++++
 .../toolchain/clang.inc => classes/clang.bbclass}  | 17 +++++--
 .../build-gcc.inc => classes/gcc-native.bbclass}   |  1 -
 .../toolchain/gcc.inc => classes/gcc.bbclass}      |  1 +
 meta/conf/bitbake.conf                             |  7 ++-
 meta/recipes-bsp/gnu-efi/gnu-efi_4.0.0.bb          |  4 ++
 meta/recipes-bsp/grub/grub2.inc                    |  4 ++
 meta/recipes-connectivity/bluez5/bluez5.inc        |  1 +
 meta/recipes-connectivity/openssl/openssl_3.5.0.bb |  3 ++
 ...ck-for-SYS_settimeofday-before-calling-sy.patch | 52 ++++++++++++++++++++++
 meta/recipes-core/busybox/busybox_1.37.0.bb        |  1 +
 meta/recipes-core/glibc/glibc-common.inc           |  2 +
 meta/recipes-core/seatd/seatd_0.9.1.bb             |  8 ++++
 meta/recipes-core/systemd/systemd-boot_257.5.bb    |  8 ++++
 meta/recipes-devtools/gcc/gcc-15.1.inc             |  2 +
 meta/recipes-devtools/pseudo/pseudo_git.bb         |  7 +++
 meta/recipes-devtools/qemu/qemu_10.0.0.bb          |  1 +
 meta/recipes-devtools/rpm/rpm_4.20.0.bb            |  4 ++
 .../syslinux/syslinux_6.04-pre2.bb                 |  5 +++
 meta/recipes-devtools/tcf-agent/tcf-agent_git.bb   |  5 +++
 meta/recipes-devtools/valgrind/valgrind_3.25.0.bb  |  8 ++++
 meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.0.bb  |  6 +++
 meta/recipes-graphics/vulkan/vulkan-samples_git.bb |  4 ++
 meta/recipes-graphics/xorg-lib/pixman_0.46.0.bb    |  3 ++
 meta/recipes-kernel/perf/perf.bb                   | 10 +++++
 meta/recipes-kernel/systemtap/systemtap_git.bb     |  4 ++
 meta/recipes-multimedia/pulseaudio/pulseaudio.inc  |  8 ++++
 meta/recipes-sato/webkit/webkitgtk_2.48.1.bb       |  2 +
 meta/recipes-support/vte/vte_0.78.2.bb             |  4 ++
 35 files changed, 216 insertions(+), 9 deletions(-)

---
base-commit: e3402fe00ca5602dbcfd151ab3fd4bfb3371f76c
change-id: 20250518-clang-toolchain-f9a8a0572306

Best regards,

Signature · 1 line
Khem Raj <[email protected]>
author
#1 lore raw

PATCH v2 1/28 toolchain: Provide abstraction for choosing per-recipe toolchain

This implements a toolchain selection mechanism with existing defaults unchanged.

It introduces a variable called TOOLCHAIN, which denotes the familiar name for toolchain e.g. "gcc" which selects GNU compiler + binutils as default C/C++ toolchain or "clang" which will use LLVM/Clang Compiler

Additionally build-gcc is used for selecting native compiler

TOOLCHAIN variable has a global fallback to "gcc" in configuration metadata. A distro can switch to using say "clang" as default system compiler by defining

TOOLCHAIN ?= "clang"

In local.conf or other distro specific global configuration metadata

It is also selectable at recipe scope, since not all packages are buildable with either clang or gcc, a recipe can explicitly demand a given toolchain e.g. glibc can not be built with clang therefore glibc recipe sets.

TOOLCHAIN = "gcc"

TCOVERRIDE is defined to toolchain-TOOLCHAIN and its added to OVERRIDES that a recipe can see and it can use "toolchain-gcc" or "toolchain-clang" to set specific metadata based upon global toolchain policy in distro.

toolchain: Use TOOLCHAIN_NATIVE for defining native compiler

This helps in selecting gcc or clang for native compiler irrespective of cross-compiler selection via TOOLCHAIN variable

---
 meta/classes-global/base.bbclass                   |  5 ++++
 meta/classes-recipe/cross-canadian.bbclass         |  2 ++
 meta/classes-recipe/cross.bbclass                  |  2 ++
 meta/classes-recipe/crosssdk.bbclass               |  2 ++
 meta/classes-recipe/native.bbclass                 |  2 ++
 meta/classes-recipe/nativesdk.bbclass              |  2 ++
 meta/classes/clang-native.bbclass                  | 28 ++++++++++++++++++++++
 .../toolchain/clang.inc => classes/clang.bbclass}  | 10 ++++----
 .../build-gcc.inc => classes/gcc-native.bbclass}   |  1 -
 .../toolchain/gcc.inc => classes/gcc.bbclass}      |  1 +
 meta/conf/bitbake.conf                             |  7 +++---
 11 files changed, 53 insertions(+), 9 deletions(-)
meta/classes-global/base.bbclass +5 -0
index 8215969c7bb37c1a1b91e260cd31714fee2db87c..ab2f0686b7b09e004ba8d5bb609e81b19da67e38 100644
@@ -6,6 +6,7 @@
 
 BB_DEFAULT_TASK ?= "build"
 CLASSOVERRIDE ?= "class-target"
+TCOVERRIDE ?= "toolchain-gcc"
 
 inherit patch
 inherit staging
@@ -19,6 +20,10 @@ PACKAGECONFIG_CONFARGS ??= ""
 
 inherit metadata_scm
 
+inherit gcc-native
+inherit gcc
+inherit_defer ${@oe.utils.ifelse(d.getVar('TOOLCHAIN') == 'clang', 'clang', '')}
+
 def lsb_distro_identifier(d):
     adjust = d.getVar('LSB_DISTRO_ADJUST')
     adjust_func = None
meta/classes-recipe/cross-canadian.bbclass +2 -0
index 059d9aa95f57dd77a0ab5172c4c15c13ed3bc43e..a9dc6aa9bac7d5cc27331a505ed213aa9d402d4d 100644
@@ -14,6 +14,8 @@
 EXCLUDE_FROM_WORLD = "1"
 NATIVESDKLIBC ?= "libc-glibc"
 LIBCOVERRIDE = ":${NATIVESDKLIBC}"
+TCOVERRIDE = ""
+TOOLCHAIN = ""
 CLASSOVERRIDE = "class-cross-canadian"
 STAGING_BINDIR_TOOLCHAIN = "${STAGING_DIR_NATIVE}${bindir_native}/${SDK_ARCH}${SDK_VENDOR}-${SDK_OS}:${STAGING_DIR_NATIVE}${bindir_native}/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"
 
meta/classes-recipe/cross.bbclass +2 -0
index 93de9a527446554b93c1e323c7458cc7aacef799..7ebf37760ca1fcad8cd1a2ee41ef32a29cca9b92 100644
@@ -10,6 +10,8 @@ inherit relocatable
 # no need for them to be a direct target of 'world'
 EXCLUDE_FROM_WORLD = "1"
 
+TCOVERRIDE = ""
+TOOLCHAIN = ""
 CLASSOVERRIDE = "class-cross"
 PACKAGES = ""
 PACKAGES_DYNAMIC = ""
meta/classes-recipe/crosssdk.bbclass +2 -0
index 824b1bcff47bcd36a70aa1d7b8724b6cf07131ff..0c0144b26829d3b76d034a89133ee94cf760b86d 100644
@@ -7,6 +7,8 @@
 inherit cross
 
 CLASSOVERRIDE = "class-crosssdk"
+TCOVERRIDE = ""
+TOOLCHAIN = ""
 NATIVESDKLIBC ?= "libc-glibc"
 LIBCOVERRIDE = ":${NATIVESDKLIBC}"
 MACHINEOVERRIDES = ""
meta/classes-recipe/native.bbclass +2 -0
index 625975a69429389a5b231a19b17e8ed7a12d80ad..cbdace9b7021e90a4df2684d9eacda36112b46c6 100644
@@ -108,6 +108,8 @@ PKG_CONFIG_SYSTEM_INCLUDE_PATH[unexport] = "1"
 
 # we dont want libc-*libc to kick in for native recipes
 LIBCOVERRIDE = ""
+TCOVERRIDE = ""
+TOOLCHAIN = ""
 CLASSOVERRIDE = "class-native"
 MACHINEOVERRIDES = ""
 MACHINE_FEATURES = ""
meta/classes-recipe/nativesdk.bbclass +2 -0
index 7ecb4c12c1f0f2b9cc48da215006a153679facf8..440bc3a5c5434152dfe5c9c19db1c2be857cd794 100644
@@ -13,6 +13,8 @@ STAGING_BINDIR_TOOLCHAIN = "${STAGING_DIR_NATIVE}${bindir_native}/${SDK_ARCH}${S
 # libc for the SDK can be different to that of the target
 NATIVESDKLIBC ?= "libc-glibc"
 LIBCOVERRIDE = ":${NATIVESDKLIBC}"
+TCOVERRIDE = ""
+TOOLCHAIN = ""
 CLASSOVERRIDE = "class-nativesdk"
 MACHINEOVERRIDES = ""
 
meta/classes/clang-native.bbclass new file +28 -0
new file mode 100644
index 0000000000000000000000000000000000000000..bf395eade73eaad18bf15f35d03bc0aec2223090
@@ -0,0 +1,28 @@
+# inherit this class if you would like to use clang to compile the native
+# version of your recipes instead of system compiler ( which is normally gcc )
+# on build machines
+# to use it add
+#
+# inherit clang-native
+#
+# to the concerned recipe via a bbappend or directly to recipe file
+#
+BUILD_CC = "${CCACHE}${BUILD_PREFIX}clang ${BUILD_CC_ARCH} -isysroot=${STAGING_DIR_NATIVE}"
+BUILD_CXX = "${CCACHE}${BUILD_PREFIX}clang++ ${BUILD_CC_ARCH} -isysroot=${STAGING_DIR_NATIVE}"
+BUILD_FC = "${BUILD_PREFIX}gfortran ${BUILD_CC_ARCH} -isysroot=${STAGING_DIR_NATIVE}"
+BUILD_CPP = "${BUILD_PREFIX}clang ${BUILD_CC_ARCH} -isysroot=${STAGING_DIR_NATIVE} -E"
+BUILD_LD = "${BUILD_PREFIX}ld ${BUILD_LD_ARCH}"
+BUILD_CCLD = "${BUILD_PREFIX}clang ${BUILD_CC_ARCH}"
+BUILD_AR = "${BUILD_PREFIX}llvm-ar"
+BUILD_AS = "${BUILD_PREFIX}as ${BUILD_AS_ARCH}"
+BUILD_RANLIB = "${BUILD_PREFIX}llvm-ranlib -D"
+BUILD_STRIP = "${BUILD_PREFIX}llvm-strip"
+BUILD_OBJCOPY = "${BUILD_PREFIX}llvm-objcopy"
+BUILD_OBJDUMP = "${BUILD_PREFIX}llvm-objdump"
+BUILD_NM = "${BUILD_PREFIX}llvn-nm"
+BUILD_READELF = "${BUILD_PREFIX}readelf"
+DEPENDS:append = " clang-native compiler-rt-native libcxx-native"
+# Use libcxx headers for native parts
+CXXFLAGS:append = " -stdlib=libc++"
+LDFLAGS:append = " -stdlib=libc++ -rtlib=libgcc -unwindlib=libgcc"
+BUILD_LDFLAGS:append = " -stdlib=libc++ -rtlib=libgcc -unwindlib=libgcc"
meta/classes/clang.bbclass renamed from meta/conf/toolchain/clang.inc +6 -4
similarity index 76%
rename from meta/conf/toolchain/clang.inc
rename to meta/classes/clang.bbclass
index 0e5f0769f85a8373c58d4b54dbe2bb1cf7dbd50b..be8b888918d1b4b4ae1d245df2c9da013cdc826e 100644
@@ -17,9 +17,11 @@ READELF = "${HOST_PREFIX}llvm-readelf"
 PREFERRED_PROVIDER_virtual/cross-cc = "${MLPREFIX}clang-cross-${TARGET_ARCH}"
 PREFERRED_PROVIDER_virtual/cross-c++ = "${MLPREFIX}clang-cross-${TARGET_ARCH}"
 PREFERRED_PROVIDER_virtual/compilerlibs = "gcc-runtime"
-PREFERRED_PROVIDER_virtual/cross-cc:class-nativesdk = "gcc-crosssdk-${SDK_SYS}"
-PREFERRED_PROVIDER_virtual/cross-c++:class-nativesdk = "gcc-crosssdk-${SDK_SYS}"
+PREFERRED_PROVIDER_virtual/cross-cc:class-nativesdk = "clang-crosssdk-${SDK_SYS}"
+PREFERRED_PROVIDER_virtual/cross-c++:class-nativesdk = "clang-crosssdk-${SDK_SYS}"
 
-PREFERRED_PROVIDER_virtual/nativesdk-cross-cc = "gcc-crosssdk-${SDK_SYS}"
-PREFERRED_PROVIDER_virtual/nativesdk-cross-c++ = "gcc-crosssdk-${SDK_SYS}"
+PREFERRED_PROVIDER_virtual/nativesdk-cross-cc = "clang-crosssdk-${SDK_SYS}"
+PREFERRED_PROVIDER_virtual/nativesdk-cross-c++ = "clang-crosssdk-${SDK_SYS}"
 PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs = "nativesdk-gcc-runtime"
+
+TCOVERRIDE = "toolchain-clang"
meta/classes/gcc-native.bbclass renamed from meta/conf/toolchain/build-gcc.inc +0 -1
similarity index 99%
rename from meta/conf/toolchain/build-gcc.inc
rename to meta/classes/gcc-native.bbclass
index a708bd0389a123504301fd151fb9ebdb677926be..1e1d68b027806b94e8229d4efef025cc1c038ad3 100644
@@ -12,4 +12,3 @@ BUILD_OBJCOPY = "${BUILD_PREFIX}objcopy"
 BUILD_OBJDUMP = "${BUILD_PREFIX}objdump"
 BUILD_NM = "${BUILD_PREFIX}nm"
 BUILD_READELF = "${BUILD_PREFIX}readelf"
-
meta/classes/gcc.bbclass renamed from meta/conf/toolchain/gcc.inc +1 -0
similarity index 97%
rename from meta/conf/toolchain/gcc.inc
rename to meta/classes/gcc.bbclass
index 36d33f5d6d0bfbf0f36158f389c4112ce20d806b..75f9abe999a297c7b17e64e693ffd8f441bb16b1 100644
@@ -24,3 +24,4 @@ PREFERRED_PROVIDER_virtual/nativesdk-cross-cc = "gcc-crosssdk-${SDK_SYS}"
 PREFERRED_PROVIDER_virtual/nativesdk-cross-c++ = "gcc-crosssdk-${SDK_SYS}"
 PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs = "nativesdk-gcc-runtime"
 
+TCOVERRIDE = "toolchain-gcc"
meta/conf/bitbake.conf +3 -4
index e5037c6277841908df333b16adbe4e6cce55f814..cfd70498b246fa1bf03e4730ecd5bf5be759ed44 100644
@@ -13,6 +13,8 @@ BASELIB = "lib"
 BASELIB:libc-glibc:powerpc64 = "lib64"
 BASELIB:libc-glibc:powerpc64le = "lib64"
 
+TOOLCHAIN ??= "gcc"
+
 # Path prefixes
 export base_prefix = ""
 export prefix = "/usr"
@@ -801,7 +803,7 @@ DISTRO_NAME ??= "OpenEmbedded"
 # And finally '<foo>:forcevariable' overrides any standard variable, with the highest priority.
 # This works for functions as well, they are really just variables.
 #
-OVERRIDES = "${TARGET_OS}:${TRANSLATED_TARGET_ARCH}:pn-${PN}:layer-${FILE_LAYERNAME}:${MACHINEOVERRIDES}:${DISTROOVERRIDES}:${CLASSOVERRIDE}${LIBCOVERRIDE}:forcevariable"
+OVERRIDES = "${TARGET_OS}:${TRANSLATED_TARGET_ARCH}:pn-${PN}:layer-${FILE_LAYERNAME}:${MACHINEOVERRIDES}:${DISTROOVERRIDES}:${CLASSOVERRIDE}:${TCOVERRIDE}${LIBCOVERRIDE}:forcevariable"
 FILE_LAYERNAME ??= "config"
 LIBCOVERRIDE ?= ""
 CLASSOVERRIDE ?= "class-target"
@@ -834,9 +836,6 @@ include conf/licenses.conf
 require conf/sanity.conf
 include conf/bblock.conf
 
-require toolchain/gcc.inc
-require toolchain/build-gcc.inc
-
 ##################################################################
 # Weak variables (usually to retain backwards compatibility)
 ##################################################################
Signature · 1 line
2.49.0
#2 lore raw

Re: [OE-core] [PATCH v2 01/28] toolchain: Provide abstraction for choosing per-recipe toolchain

Quoted 46 lines · Khem Raj via lists.openembedded.org

This implements a toolchain selection mechanism with existing defaults unchanged.

It introduces a variable called TOOLCHAIN, which denotes the familiar name for toolchain e.g. "gcc" which selects GNU compiler + binutils as default C/C++ toolchain or "clang" which will use LLVM/Clang Compiler

Additionally build-gcc is used for selecting native compiler

TOOLCHAIN variable has a global fallback to "gcc" in configuration metadata. A distro can switch to using say "clang" as default system compiler by defining

TOOLCHAIN ?= "clang"

In local.conf or other distro specific global configuration metadata

It is also selectable at recipe scope, since not all packages are buildable with either clang or gcc, a recipe can explicitly demand a given toolchain e.g. glibc can not be built with clang therefore glibc recipe sets.

TOOLCHAIN = "gcc"

TCOVERRIDE is defined to toolchain-TOOLCHAIN and its added to OVERRIDES that a recipe can see and it can use "toolchain-gcc" or "toolchain-clang" to set specific metadata based upon global toolchain policy in distro.

toolchain: Use TOOLCHAIN_NATIVE for defining native compiler

This helps in selecting gcc or clang for native compiler irrespective of cross-compiler selection via TOOLCHAIN variable

---
 meta/classes-global/base.bbclass                   |  5 ++++ meta/classes-recipe/cross-canadian.bbclass         |  2 ++ meta/classes-recipe/cross.bbclass                  |  2 ++ meta/classes-recipe/crosssdk.bbclass               |  2 ++ meta/classes-recipe/native.bbclass                 |  2 ++ meta/classes-recipe/nativesdk.bbclass              |  2 ++ meta/classes/clang-native.bbclass                  | 28 ++++++++++++++++++++++ .../toolchain/clang.inc => classes/clang.bbclass}  | 10 ++++---- .../build-gcc.inc => classes/gcc-native.bbclass}   |  1 - .../toolchain/gcc.inc => classes/gcc.bbclass}      |  1 + meta/conf/bitbake.conf                             |  7 +++---

Quoted 1 line
 11 files changed, 53 insertions(+), 9 deletions(-)

This is definitely getting there, thanks for working through it.

I think we're ready to agree that we should support toolchain selection with the TOOLCHAIN variable and we should support toolchain overrides. There are therefore some patches in this series which can merge as we agree on that.

One of the concerns I have left is the class naming as I think "gcc.bbclass" is confusing in its own right. I'm wondering if we put these classes into a toolchain directory to make it clearer.

I do also conceptually prefer the idea of an inc file so I'm wondering if we should see if some kind of require_defer syntax could work?

Quoted 16 lines
meta/classes-global/base.bbclass +0 -0
index 8215969c7bb37c1a1b91e260cd31714fee2db87c..ab2f0686b7b09e004ba8d5bb609e81b19da67e38 100644
@@ -6,6 +6,7 @@


 BB_DEFAULT_TASK ?= "build"
 CLASSOVERRIDE ?= "class-target"
+TCOVERRIDE ?= "toolchain-gcc"

 inherit patch
 inherit staging

meta/classes-global/base.bbclass +0 -0
@@ -19,6 +20,10 @@ PACKAGECONFIG_CONFARGS ??= ""


 inherit metadata_scm

meta/classes-global/base.bbclass PACKAGECONFIG_CONFARGS ??= "" · line 25

Quoted 3 lines
meta/classes-global/base.bbclass +3 -0
+inherit gcc-native
+inherit gcc
+inherit_defer ${@oe.utils.ifelse(d.getVar('TOOLCHAIN') == 'clang', 'clang', '')}

I'm a bit puzzled on why we can't defer the gcc inherit here too? I guess that didn't work for some reason?

Quoted 27 lines

+
 def lsb_distro_identifier(d):
     adjust = d.getVar('LSB_DISTRO_ADJUST')
     adjust_func = None

meta/classes-recipe/cross-canadian.bbclass +0 -0
index 059d9aa95f57dd77a0ab5172c4c15c13ed3bc43e..a9dc6aa9bac7d5cc27331a505ed213aa9d402d4d 100644
@@ -14,6 +14,8 @@

 EXCLUDE_FROM_WORLD = "1"
 NATIVESDKLIBC ?= "libc-glibc"
 LIBCOVERRIDE = ":${NATIVESDKLIBC}"

meta/classes-recipe/cross-canadian.bbclass +2 -0
+TCOVERRIDE = ""
+TOOLCHAIN = ""

 CLASSOVERRIDE = "class-cross-canadian"
 STAGING_BINDIR_TOOLCHAIN = "${STAGING_DIR_NATIVE}${bindir_native}/${SDK_ARCH}${SDK_VENDOR}-${SDK_OS}:${STAGING_DIR_NATIVE}${bindir_native}/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"

meta/classes-recipe/cross.bbclass +0 -0
index 93de9a527446554b93c1e323c7458cc7aacef799..7ebf37760ca1fcad8cd1a2ee41ef32a29cca9b92 100644
@@ -10,6 +10,8 @@ inherit relocatable
  # no need for them to be a direct target of 'world'

 EXCLUDE_FROM_WORLD = "1"

meta/classes-recipe/cross.bbclass +2 -0
+TCOVERRIDE = ""
+TOOLCHAIN = ""
Quoted 3 lines

 CLASSOVERRIDE = "class-cross"
 PACKAGES = ""
 PACKAGES_DYNAMIC = ""

Wouldn't the recipes that include this class set TOOLCHAIN correctly anyway?

Quoted 10 lines
meta/classes-recipe/crosssdk.bbclass +0 -0
index 824b1bcff47bcd36a70aa1d7b8724b6cf07131ff..0c0144b26829d3b76d034a89133ee94cf760b86d 100644
@@ -7,6 +7,8 @@

 inherit cross

 CLASSOVERRIDE = "class-crosssdk"

meta/classes-recipe/crosssdk.bbclass +2 -0
+TCOVERRIDE = ""
+TOOLCHAIN = ""
Quoted 3 lines

 NATIVESDKLIBC ?= "libc-glibc"
 LIBCOVERRIDE = ":${NATIVESDKLIBC}"
 MACHINEOVERRIDES = ""

Same question here.

Quoted 10 lines
meta/classes-recipe/native.bbclass +0 -0
index 625975a69429389a5b231a19b17e8ed7a12d80ad..cbdace9b7021e90a4df2684d9eacda36112b46c6 100644
@@ -108,6 +108,8 @@ PKG_CONFIG_SYSTEM_INCLUDE_PATH[unexport] = "1"

 # we dont want libc-*libc to kick in for native recipes
 LIBCOVERRIDE = ""
meta/classes-recipe/native.bbclass +2 -0
+TCOVERRIDE = ""
+TOOLCHAIN = ""
Quoted 3 lines

 CLASSOVERRIDE = "class-native"
 MACHINEOVERRIDES = ""
 MACHINE_FEATURES = ""

This, I can understand although I know there was "clang-native" support in places. I guess that is deferred for now?

Quoted 10 lines
meta/classes-recipe/nativesdk.bbclass +0 -0
index 7ecb4c12c1f0f2b9cc48da215006a153679facf8..440bc3a5c5434152dfe5c9c19db1c2be857cd794 100644
@@ -13,6 +13,8 @@ STAGING_BINDIR_TOOLCHAIN = "${STAGING_DIR_NATIVE}${bindir_native}/${SDK_ARCH}${S
  # libc for the SDK can be different to that of the target

 NATIVESDKLIBC ?= "libc-glibc"
 LIBCOVERRIDE = ":${NATIVESDKLIBC}"

meta/classes-recipe/nativesdk.bbclass +2 -0
+TCOVERRIDE = ""
+TOOLCHAIN = ""
Quoted 2 lines

 CLASSOVERRIDE = "class-nativesdk"
 MACHINEOVERRIDES = ""

Do you have any plans to support building the SDK with clang? I'm just wondering on the code direction here in the future.

Quoted 24 lines
meta/classes/clang-native.bbclass new file +18 -0
new file mode 100644
index 0000000000000000000000000000000000000000..bf395eade73eaad18bf15f35d03bc0aec2223090
@@ -0,0 +1,28 @@
+# inherit this class if you would like to use clang to compile the native
+# version of your recipes instead of system compiler ( which is normally gcc )
+# on build machines
+# to use it add
+#
+# inherit clang-native
+#
+# to the concerned recipe via a bbappend or directly to recipe file
+#
+BUILD_CC = "${CCACHE}${BUILD_PREFIX}clang ${BUILD_CC_ARCH} -isysroot=${STAGING_DIR_NATIVE}"
+BUILD_CXX = "${CCACHE}${BUILD_PREFIX}clang++ ${BUILD_CC_ARCH} -isysroot=${STAGING_DIR_NATIVE}"
+BUILD_FC = "${BUILD_PREFIX}gfortran ${BUILD_CC_ARCH} -isysroot=${STAGING_DIR_NATIVE}"
+BUILD_CPP = "${BUILD_PREFIX}clang ${BUILD_CC_ARCH} -isysroot=${STAGING_DIR_NATIVE} -E"
+BUILD_LD = "${BUILD_PREFIX}ld ${BUILD_LD_ARCH}"
+BUILD_CCLD = "${BUILD_PREFIX}clang ${BUILD_CC_ARCH}"
+BUILD_AR = "${BUILD_PREFIX}llvm-ar"
+BUILD_AS = "${BUILD_PREFIX}as ${BUILD_AS_ARCH}"
+BUILD_RANLIB = "${BUILD_PREFIX}llvm-ranlib -D"

meta/classes/clang-native.bbclass line 28

Quoted 10 lines
meta/classes/clang-native.bbclass new file +10 -0
+BUILD_STRIP = "${BUILD_PREFIX}llvm-strip"
+BUILD_OBJCOPY = "${BUILD_PREFIX}llvm-objcopy"
+BUILD_OBJDUMP = "${BUILD_PREFIX}llvm-objdump"
+BUILD_NM = "${BUILD_PREFIX}llvn-nm"
+BUILD_READELF = "${BUILD_PREFIX}readelf"
+DEPENDS:append = " clang-native compiler-rt-native libcxx-native"
+# Use libcxx headers for native parts
+CXXFLAGS:append = " -stdlib=libc++"
+LDFLAGS:append = " -stdlib=libc++ -rtlib=libgcc -unwindlib=libgcc"
+BUILD_LDFLAGS:append = " -stdlib=libc++ -rtlib=libgcc -unwindlib=libgcc"

Where/how does this get used?

Quoted 21 lines
meta/classes/clang.bbclass renamed from meta/conf/toolchain/clang.inc +0 -0
similarity index 76%
rename from meta/conf/toolchain/clang.inc
rename to meta/classes/clang.bbclass
index 0e5f0769f85a8373c58d4b54dbe2bb1cf7dbd50b..be8b888918d1b4b4ae1d245df2c9da013cdc826e 100644
@@ -17,9 +17,11 @@ READELF = "${HOST_PREFIX}llvm-readelf"

 PREFERRED_PROVIDER_virtual/cross-cc = "${MLPREFIX}clang-cross-${TARGET_ARCH}" PREFERRED_PROVIDER_virtual/cross-c++ = "${MLPREFIX}clang-cross-${TARGET_ARCH}" PREFERRED_PROVIDER_virtual/compilerlibs = "gcc-runtime"

meta/classes/clang.bbclass renamed from meta/conf/toolchain/clang.inc +2 -2
-PREFERRED_PROVIDER_virtual/cross-cc:class-nativesdk = "gcc-crosssdk-${SDK_SYS}"
-PREFERRED_PROVIDER_virtual/cross-c++:class-nativesdk = "gcc-crosssdk-${SDK_SYS}"
+PREFERRED_PROVIDER_virtual/cross-cc:class-nativesdk = "clang-crosssdk-${SDK_SYS}"
+PREFERRED_PROVIDER_virtual/cross-c++:class-nativesdk = "clang-crosssdk-${SDK_SYS}"

meta/classes/clang.bbclass renamed from meta/conf/toolchain/clang.inc +2 -2
-PREFERRED_PROVIDER_virtual/nativesdk-cross-cc = "gcc-crosssdk-${SDK_SYS}"
-PREFERRED_PROVIDER_virtual/nativesdk-cross-c++ = "gcc-crosssdk-${SDK_SYS}"
+PREFERRED_PROVIDER_virtual/nativesdk-cross-cc = "clang-crosssdk-${SDK_SYS}"
+PREFERRED_PROVIDER_virtual/nativesdk-cross-c++ = "clang-crosssdk-${SDK_SYS}"

 PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs = "nativesdk-gcc-runtime"

meta/classes/clang.bbclass READELF = "${HOST_PREFIX}llvm-readelf" · line 27

Quoted 2 lines
meta/classes/clang.bbclass renamed from meta/conf/toolchain/clang.inc +2 -0
+
+TCOVERRIDE = "toolchain-clang"

This can probably be split into a separate patch and merged sooner.

Quoted 20 lines
meta/classes/gcc-native.bbclass renamed from meta/conf/toolchain/build-gcc.inc +0 -0
similarity index 99%
rename from meta/conf/toolchain/build-gcc.inc
rename to meta/classes/gcc-native.bbclass
index a708bd0389a123504301fd151fb9ebdb677926be..1e1d68b027806b94e8229d4efef025cc1c038ad3 100644
@@ -12,4 +12,3 @@ BUILD_OBJCOPY = "${BUILD_PREFIX}objcopy"

 BUILD_OBJDUMP = "${BUILD_PREFIX}objdump"
 BUILD_NM = "${BUILD_PREFIX}nm"
 BUILD_READELF = "${BUILD_PREFIX}readelf"

meta/classes/gcc-native.bbclass renamed from meta/conf/toolchain/build-gcc.inc +0 -1
-
meta/classes/gcc.bbclass renamed from meta/conf/toolchain/gcc.inc +0 -0
similarity index 97%
rename from meta/conf/toolchain/gcc.inc
rename to meta/classes/gcc.bbclass
index 36d33f5d6d0bfbf0f36158f389c4112ce20d806b..75f9abe999a297c7b17e64e693ffd8f441bb16b1 100644
@@ -24,3 +24,4 @@ PREFERRED_PROVIDER_virtual/nativesdk-cross-cc = "gcc-crosssdk-${SDK_SYS}"
Quoted 4 lines

 PREFERRED_PROVIDER_virtual/nativesdk-cross-c++ = "gcc-crosssdk-${SDK_SYS}" PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs = "nativesdk-gcc-runtime"
+TCOVERRIDE = "toolchain-gcc"

The TCOVERRIDE pieces could also be a separate patch to move things forward until we resolve the inherit_defer/require/naming discussion?

Quoted 14 lines
meta/conf/bitbake.conf +0 -0
index e5037c6277841908df333b16adbe4e6cce55f814..cfd70498b246fa1bf03e4730ecd5bf5be759ed44 100644
@@ -13,6 +13,8 @@ BASELIB = "lib"

 BASELIB:libc-glibc:powerpc64 = "lib64"
 BASELIB:libc-glibc:powerpc64le = "lib64"

meta/conf/bitbake.conf +2 -0
+TOOLCHAIN ??= "gcc"
+

 # Path prefixes
 export base_prefix = ""
 export prefix = "/usr"

meta/conf/bitbake.conf DISTRO_NAME ??= "OpenEmbedded" · line 806

Quoted 5 lines
meta/conf/bitbake.conf +1 -1
@@ -801,7 +803,7 @@ DISTRO_NAME ??= "OpenEmbedded"
  # And finally '<foo>:forcevariable' overrides any standard variable, with the highest priority.
  # This works for functions as well, they are really just variables.
  #
-OVERRIDES = "${TARGET_OS}:${TRANSLATED_TARGET_ARCH}:pn-${PN}:layer-${FILE_LAYERNAME}:${MACHINEOVERRIDES}:${DISTROOVERRIDES}:${CLASSOVERRIDE}${LIBCOVERRIDE}:forcevariable"
+OVERRIDES = "${TARGET_OS}:${TRANSLATED_TARGET_ARCH}:pn-${PN}:layer-${FILE_LAYERNAME}:${MACHINEOVERRIDES}:${DISTROOVERRIDES}:${CLASSOVERRIDE}:${TCOVERRIDE}${LIBCOVERRIDE}:forcevariable"

Lets pull the overrides bit into a separate patch.

Cheers,

Richard

author
#3 lore raw

Re: [OE-core] [PATCH v2 01/28] toolchain: Provide abstraction for choosing per-recipe toolchain

Quoted 51 lines · Richard Purdie
Quoted 34 lines · Khem Raj via lists.openembedded.org

This implements a toolchain selection mechanism with existing defaults unchanged.

It introduces a variable called TOOLCHAIN, which denotes the familiar name for toolchain e.g. "gcc" which selects GNU compiler + binutils as default C/C++ toolchain or "clang" which will use LLVM/Clang Compiler

Additionally build-gcc is used for selecting native compiler

TOOLCHAIN variable has a global fallback to "gcc" in configuration metadata. A distro can switch to using say "clang" as default system compiler by defining

TOOLCHAIN ?= "clang"

In local.conf or other distro specific global configuration metadata

It is also selectable at recipe scope, since not all packages are buildable with either clang or gcc, a recipe can explicitly demand a given toolchain e.g. glibc can not be built with clang therefore glibc recipe sets.

TOOLCHAIN = "gcc"

TCOVERRIDE is defined to toolchain-TOOLCHAIN and its added to OVERRIDES that a recipe can see and it can use "toolchain-gcc" or "toolchain-clang" to set specific metadata based upon global toolchain policy in distro.

toolchain: Use TOOLCHAIN_NATIVE for defining native compiler

This helps in selecting gcc or clang for native compiler irrespective of cross-compiler selection via TOOLCHAIN variable

Quoted 13 lines
---
  meta/classes-global/base.bbclass                   |  5 ++++
  meta/classes-recipe/cross-canadian.bbclass         |  2 ++
  meta/classes-recipe/cross.bbclass                  |  2 ++
  meta/classes-recipe/crosssdk.bbclass               |  2 ++
  meta/classes-recipe/native.bbclass                 |  2 ++
  meta/classes-recipe/nativesdk.bbclass              |  2 ++
  meta/classes/clang-native.bbclass                  | 28 ++++++++++++++++++++++
  .../toolchain/clang.inc => classes/clang.bbclass}  | 10 ++++----
  .../build-gcc.inc => classes/gcc-native.bbclass}   |  1 -
  .../toolchain/gcc.inc => classes/gcc.bbclass}      |  1 +
  meta/conf/bitbake.conf                             |  7 +++---
  11 files changed, 53 insertions(+), 9 deletions(-)

This is definitely getting there, thanks for working through it.

Quoted 8 lines

I think we're ready to agree that we should support toolchain selection with the TOOLCHAIN variable and we should support toolchain overrides. There are therefore some patches in this series which can merge as we agree on that.

One of the concerns I have left is the class naming as I think "gcc.bbclass" is confusing in its own right. I'm wondering if we put these classes into a toolchain directory to make it clearer.

thats a good idea, perhaps I will move them into classes-toolchain/ folder.

Quoted 4 lines

I do also conceptually prefer the idea of an inc file so I'm wondering if we should see if some kind of require_defer syntax could work?

We will always have exceptions where packages are not buildable with one toolchain or other and I found that doing it in class + override is quite good and extensible to other toolchains in future with a global fallback.

Quoted 14 lines
Quoted 14 lines
meta/classes-global/base.bbclass +1 -0
index 8215969c7bb37c1a1b91e260cd31714fee2db87c..ab2f0686b7b09e004ba8d5bb609e81b19da67e38 100644
@@ -6,6 +6,7 @@
 
  BB_DEFAULT_TASK ?= "build"
  CLASSOVERRIDE ?= "class-target"
+TCOVERRIDE ?= "toolchain-gcc"
 
  inherit patch
  inherit staging
@@ -19,6 +20,10 @@ PACKAGECONFIG_CONFARGS ??= ""
 
Quoted 9 lines

meta/classes-global/base.bbclass PACKAGECONFIG_CONFARGS ??= "" · line 25

Quoted 5 lines
meta/classes-global/base.bbclass +3 -0
  inherit metadata_scm
 
+inherit gcc-native
+inherit gcc
+inherit_defer ${@oe.utils.ifelse(d.getVar('TOOLCHAIN') == 'clang', 'clang', '')}

I'm a bit puzzled on why we can't defer the gcc inherit here too? I guess that didn't work for some reason?

TOOLCHAIN variable is processed later for bbclassextend'ed recipes and competes with nativesdk's quest to be last in line of inherits, then having a default fallback toolchain to be gcc is a reasonable choice since we can not _yet_ use non-gcc toolchains to build complete set of
recipes. Its getting there though.

Quoted 68 lines
Quoted 22 lines
meta/classes-global/base.bbclass +1 -0
+
  def lsb_distro_identifier(d):
      adjust = d.getVar('LSB_DISTRO_ADJUST')
      adjust_func = None
meta/classes-recipe/cross-canadian.bbclass +2 -0
index 059d9aa95f57dd77a0ab5172c4c15c13ed3bc43e..a9dc6aa9bac7d5cc27331a505ed213aa9d402d4d 100644
@@ -14,6 +14,8 @@
  EXCLUDE_FROM_WORLD = "1"
  NATIVESDKLIBC ?= "libc-glibc"
  LIBCOVERRIDE = ":${NATIVESDKLIBC}"
+TCOVERRIDE = ""
+TOOLCHAIN = ""
  CLASSOVERRIDE = "class-cross-canadian"
  STAGING_BINDIR_TOOLCHAIN = "${STAGING_DIR_NATIVE}${bindir_native}/${SDK_ARCH}${SDK_VENDOR}-${SDK_OS}:${STAGING_DIR_NATIVE}${bindir_native}/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"
 
meta/classes-recipe/cross.bbclass +0 -0
index 93de9a527446554b93c1e323c7458cc7aacef799..7ebf37760ca1fcad8cd1a2ee41ef32a29cca9b92 100644

meta/classes-recipe/cross.bbclass inherit relocatable · line 17

Quoted 8 lines
meta/classes-recipe/cross.bbclass +2 -0
@@ -10,6 +10,8 @@ inherit relocatable
  # no need for them to be a direct target of 'world'
  EXCLUDE_FROM_WORLD = "1"
 
+TCOVERRIDE = ""
+TOOLCHAIN = ""
  CLASSOVERRIDE = "class-cross"
  PACKAGES = ""
  PACKAGES_DYNAMIC = ""

Wouldn't the recipes that include this class set TOOLCHAIN correctly anyway?

meta/classes-recipe/crosssdk.bbclass line 14

Quoted 13 lines
meta/classes-recipe/crosssdk.bbclass +2 -0
index 824b1bcff47bcd36a70aa1d7b8724b6cf07131ff..0c0144b26829d3b76d034a89133ee94cf760b86d 100644
@@ -7,6 +7,8 @@
  inherit cross
 
  CLASSOVERRIDE = "class-crosssdk"
+TCOVERRIDE = ""
+TOOLCHAIN = ""
  NATIVESDKLIBC ?= "libc-glibc"
  LIBCOVERRIDE = ":${NATIVESDKLIBC}"
  MACHINEOVERRIDES = ""

Same question here.

meta/classes-recipe/native.bbclass PKG_CONFIG_SYSTEM_INCLUDE_PATH[unexport] = "1" · line 115

Quoted 13 lines
meta/classes-recipe/native.bbclass +2 -0
index 625975a69429389a5b231a19b17e8ed7a12d80ad..cbdace9b7021e90a4df2684d9eacda36112b46c6 100644
@@ -108,6 +108,8 @@ PKG_CONFIG_SYSTEM_INCLUDE_PATH[unexport] = "1"
 
  # we dont want libc-*libc to kick in for native recipes
  LIBCOVERRIDE = ""
+TCOVERRIDE = ""
+TOOLCHAIN = ""
  CLASSOVERRIDE = "class-native"
  MACHINEOVERRIDES = ""
  MACHINE_FEATURES = ""

This, I can understand although I know there was "clang-native" support in places. I guess that is deferred for now?

Quoted 16 lines

meta/classes-recipe/nativesdk.bbclass STAGING_BINDIR_TOOLCHAIN = "${STAGING_DIR_NATIVE}${bindir_native}/${SDK_ARCH}${S · line 19

Quoted 12 lines
meta/classes-recipe/nativesdk.bbclass +2 -0
index 7ecb4c12c1f0f2b9cc48da215006a153679facf8..440bc3a5c5434152dfe5c9c19db1c2be857cd794 100644
@@ -13,6 +13,8 @@ STAGING_BINDIR_TOOLCHAIN = "${STAGING_DIR_NATIVE}${bindir_native}/${SDK_ARCH}${S
  # libc for the SDK can be different to that of the target
  NATIVESDKLIBC ?= "libc-glibc"
  LIBCOVERRIDE = ":${NATIVESDKLIBC}"
+TCOVERRIDE = ""
+TOOLCHAIN = ""
  CLASSOVERRIDE = "class-nativesdk"
  MACHINEOVERRIDES = ""

Do you have any plans to support building the SDK with clang? I'm just wondering on the code direction here in the future.

yes precisely the reason, we can today create SDKs with both gcc and clang compiler toolchains in it.

Quoted 29 lines
Quoted 29 lines
meta/classes/clang-native.bbclass new file +22 -0
new file mode 100644
index 0000000000000000000000000000000000000000..bf395eade73eaad18bf15f35d03bc0aec2223090
@@ -0,0 +1,28 @@
+# inherit this class if you would like to use clang to compile the native
+# version of your recipes instead of system compiler ( which is normally gcc )
+# on build machines
+# to use it add
+#
+# inherit clang-native
+#
+# to the concerned recipe via a bbappend or directly to recipe file
+#
+BUILD_CC = "${CCACHE}${BUILD_PREFIX}clang ${BUILD_CC_ARCH} -isysroot=${STAGING_DIR_NATIVE}"
+BUILD_CXX = "${CCACHE}${BUILD_PREFIX}clang++ ${BUILD_CC_ARCH} -isysroot=${STAGING_DIR_NATIVE}"
+BUILD_FC = "${BUILD_PREFIX}gfortran ${BUILD_CC_ARCH} -isysroot=${STAGING_DIR_NATIVE}"
+BUILD_CPP = "${BUILD_PREFIX}clang ${BUILD_CC_ARCH} -isysroot=${STAGING_DIR_NATIVE} -E"
+BUILD_LD = "${BUILD_PREFIX}ld ${BUILD_LD_ARCH}"
+BUILD_CCLD = "${BUILD_PREFIX}clang ${BUILD_CC_ARCH}"
+BUILD_AR = "${BUILD_PREFIX}llvm-ar"
+BUILD_AS = "${BUILD_PREFIX}as ${BUILD_AS_ARCH}"
+BUILD_RANLIB = "${BUILD_PREFIX}llvm-ranlib -D"
+BUILD_STRIP = "${BUILD_PREFIX}llvm-strip"
+BUILD_OBJCOPY = "${BUILD_PREFIX}llvm-objcopy"
+BUILD_OBJDUMP = "${BUILD_PREFIX}llvm-objdump"
+BUILD_NM = "${BUILD_PREFIX}llvn-nm"
Quoted 8 lines

meta/classes/clang-native.bbclass line 28

Quoted 6 lines
meta/classes/clang-native.bbclass new file +6 -0
+BUILD_READELF = "${BUILD_PREFIX}readelf"
+DEPENDS:append = " clang-native compiler-rt-native libcxx-native"
+# Use libcxx headers for native parts
+CXXFLAGS:append = " -stdlib=libc++"
+LDFLAGS:append = " -stdlib=libc++ -rtlib=libgcc -unwindlib=libgcc"
+BUILD_LDFLAGS:append = " -stdlib=libc++ -rtlib=libgcc -unwindlib=libgcc"

Where/how does this get used?

This is used when using clang-native to build native portions ( want to override native gcc ) e.g. chromium which requires it, there are other packages which can optionally use it when using clang toolchains qtwebengine, rust-llvm, rust to name a few. It makes it easy to use clang as native compiler.

Quoted 18 lines
Quoted 18 lines
meta/classes/clang.bbclass renamed from meta/conf/toolchain/clang.inc +2 -2
similarity index 76%
rename from meta/conf/toolchain/clang.inc
rename to meta/classes/clang.bbclass
index 0e5f0769f85a8373c58d4b54dbe2bb1cf7dbd50b..be8b888918d1b4b4ae1d245df2c9da013cdc826e 100644
@@ -17,9 +17,11 @@ READELF = "${HOST_PREFIX}llvm-readelf"
  PREFERRED_PROVIDER_virtual/cross-cc = "${MLPREFIX}clang-cross-${TARGET_ARCH}"
  PREFERRED_PROVIDER_virtual/cross-c++ = "${MLPREFIX}clang-cross-${TARGET_ARCH}"
  PREFERRED_PROVIDER_virtual/compilerlibs = "gcc-runtime"
-PREFERRED_PROVIDER_virtual/cross-cc:class-nativesdk = "gcc-crosssdk-${SDK_SYS}"
-PREFERRED_PROVIDER_virtual/cross-c++:class-nativesdk = "gcc-crosssdk-${SDK_SYS}"
+PREFERRED_PROVIDER_virtual/cross-cc:class-nativesdk = "clang-crosssdk-${SDK_SYS}"
+PREFERRED_PROVIDER_virtual/cross-c++:class-nativesdk = "clang-crosssdk-${SDK_SYS}"
 
Quoted 10 lines

meta/classes/clang.bbclass READELF = "${HOST_PREFIX}llvm-readelf" · line 27

Quoted 7 lines
meta/classes/clang.bbclass renamed from meta/conf/toolchain/clang.inc +4 -2
-PREFERRED_PROVIDER_virtual/nativesdk-cross-cc = "gcc-crosssdk-${SDK_SYS}"
-PREFERRED_PROVIDER_virtual/nativesdk-cross-c++ = "gcc-crosssdk-${SDK_SYS}"
+PREFERRED_PROVIDER_virtual/nativesdk-cross-cc = "clang-crosssdk-${SDK_SYS}"
+PREFERRED_PROVIDER_virtual/nativesdk-cross-c++ = "clang-crosssdk-${SDK_SYS}"
  PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs = "nativesdk-gcc-runtime"
+
+TCOVERRIDE = "toolchain-clang"

This can probably be split into a separate patch and merged sooner.

I kept this together for keep things building atomically across bisects etc. But I think I can separate adding the TCOVERRIDE logic to patch of its own.

Quoted 56 lines
Quoted 21 lines
meta/classes/gcc-native.bbclass renamed from meta/conf/toolchain/build-gcc.inc +0 -1
similarity index 99%
rename from meta/conf/toolchain/build-gcc.inc
rename to meta/classes/gcc-native.bbclass
index a708bd0389a123504301fd151fb9ebdb677926be..1e1d68b027806b94e8229d4efef025cc1c038ad3 100644
@@ -12,4 +12,3 @@ BUILD_OBJCOPY = "${BUILD_PREFIX}objcopy"
  BUILD_OBJDUMP = "${BUILD_PREFIX}objdump"
  BUILD_NM = "${BUILD_PREFIX}nm"
  BUILD_READELF = "${BUILD_PREFIX}readelf"
-
meta/classes/gcc.bbclass renamed from meta/conf/toolchain/gcc.inc +0 -0
similarity index 97%
rename from meta/conf/toolchain/gcc.inc
rename to meta/classes/gcc.bbclass
index 36d33f5d6d0bfbf0f36158f389c4112ce20d806b..75f9abe999a297c7b17e64e693ffd8f441bb16b1 100644

meta/classes/gcc.bbclass PREFERRED_PROVIDER_virtual/nativesdk-cross-cc = "gcc-crosssdk-${SDK_SYS}" · line 27

Quoted 4 lines
meta/classes/gcc.bbclass renamed from meta/conf/toolchain/gcc.inc +1 -0
@@ -24,3 +24,4 @@ PREFERRED_PROVIDER_virtual/nativesdk-cross-cc = "gcc-crosssdk-${SDK_SYS}"
  PREFERRED_PROVIDER_virtual/nativesdk-cross-c++ = "gcc-crosssdk-${SDK_SYS}"
  PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs = "nativesdk-gcc-runtime"
 
+TCOVERRIDE = "toolchain-gcc"

The TCOVERRIDE pieces could also be a separate patch to move things forward until we resolve the inherit_defer/require/naming discussion?

Quoted 14 lines
meta/conf/bitbake.conf +2 -0
index e5037c6277841908df333b16adbe4e6cce55f814..cfd70498b246fa1bf03e4730ecd5bf5be759ed44 100644
@@ -13,6 +13,8 @@ BASELIB = "lib"
  BASELIB:libc-glibc:powerpc64 = "lib64"
  BASELIB:libc-glibc:powerpc64le = "lib64"
 
+TOOLCHAIN ??= "gcc"
+
  # Path prefixes
  export base_prefix = ""
  export prefix = "/usr"

meta/conf/bitbake.conf DISTRO_NAME ??= "OpenEmbedded" · line 806

Quoted 5 lines
meta/conf/bitbake.conf +1 -1
@@ -801,7 +803,7 @@ DISTRO_NAME ??= "OpenEmbedded"
  # And finally '<foo>:forcevariable' overrides any standard variable, with the highest priority.
  # This works for functions as well, they are really just variables.
  #
-OVERRIDES = "${TARGET_OS}:${TRANSLATED_TARGET_ARCH}:pn-${PN}:layer-${FILE_LAYERNAME}:${MACHINEOVERRIDES}:${DISTROOVERRIDES}:${CLASSOVERRIDE}${LIBCOVERRIDE}:forcevariable"
+OVERRIDES = "${TARGET_OS}:${TRANSLATED_TARGET_ARCH}:pn-${PN}:layer-${FILE_LAYERNAME}:${MACHINEOVERRIDES}:${DISTROOVERRIDES}:${CLASSOVERRIDE}:${TCOVERRIDE}${LIBCOVERRIDE}:forcevariable"

Lets pull the overrides bit into a separate patch.

Cheers,

Richard

author
#4 lore raw

PATCH v2 2/28 clang.bbclass: Specify ldso when using usermerge

In reply to Khem Raj

This matches the expectations of distro setups and clang's understanding of what the ldso should look like

---
 meta/classes/clang.bbclass | 5 +++++
 1 file changed, 5 insertions(+)
meta/classes/clang.bbclass +5 -0
index be8b888918d1b4b4ae1d245df2c9da013cdc826e..ddf8f350f951744940893698188a1e6056edf7cc 100644
@@ -25,3 +25,8 @@ PREFERRED_PROVIDER_virtual/nativesdk-cross-c++ = "clang-crosssdk-${SDK_SYS}"
 PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs = "nativesdk-gcc-runtime"
 
 TCOVERRIDE = "toolchain-clang"
+
+TUNE_CCARGS += "${@bb.utils.contains("DISTRO_FEATURES", "usrmerge", " --dyld-prefix=/usr", "", d)}"
+
+LDFLAGS:append:class-nativesdk:x86-64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-x86-64.so.2"
+LDFLAGS:append:class-nativesdk:aarch64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-aarch64.so.1"
Signature · 1 line
2.49.0
author
#5 lore raw

PATCH v2 3/28 vte: Disable gi data generation when using clang on arm

In reply to Khem Raj

Fixes Qemu usermode crashes

---
 meta/recipes-support/vte/vte_0.78.2.bb | 4 ++++
 1 file changed, 4 insertions(+)
meta/recipes-support/vte/vte_0.78.2.bb +4 -0
index 0593d16cd8678d010c240581138caf22f2908659..e37d59833cf3313bdb369f4e0957dfc5e3cb3ace 100644
@@ -26,6 +26,10 @@ SRC_URI[archive.sha256sum] = "35d7bcde07356846b4a12881c8e016705b70a9004a9082285e
 
 ANY_OF_DISTRO_FEATURES = "${GTK3DISTROFEATURES}"
 
+# qemu usermode crashes when using clang as system compiler but works with gcc
+# see https://patchwork.yoctoproject.org/project/oe-core/patch/[email protected]/
+GI_DATA_ENABLED:pn-vte:toolchain-clang:armv7ve = "False"
+
 EXTRA_OEMESON += "${@bb.utils.contains('GI_DATA_ENABLED', 'True', '-Dvapi=true', '-Dvapi=false', d)}"
 EXTRA_OEMESON:append = " ${@bb.utils.contains('GI_DATA_ENABLED', 'False', '-Ddocs=false', '', d)}"
 
Signature · 1 line
2.49.0
#6 lore raw

Re: [OE-core] [PATCH v2 03/28] vte: Disable gi data generation when using clang on arm

meta/recipes-support/vte/vte_0.78.2.bb SRC_URI[archive.sha256sum] = "35d7bcde07356846b4a12881c8e016705b70a9004a9082285e · line 31

Quoted 6 lines · Khem Raj via lists.openembedded.org
meta/recipes-support/vte/vte_0.78.2.bb +3 -0
+# qemu usermode crashes when using clang as system compiler but works with gcc
+# see https://patchwork.yoctoproject.org/project/oe-core/patch/[email protected]/
+GI_DATA_ENABLED:pn-vte:toolchain-clang:armv7ve = "False"

No need for :pn-vte:

Ross

#7 lore raw

Re: [OE-core] [PATCH v2 03/28] vte: Disable gi data generation when using clang on arm

In reply to Khem Raj

meta/recipes-support/vte/vte_0.78.2.bb SRC_URI[archive.sha256sum] = "35d7bcde07356846b4a12881c8e016705b70a9004a9082285e · line 31

Quoted 3 lines · Khem Raj via lists.openembedded.org
meta/recipes-support/vte/vte_0.78.2.bb +3 -0
+# qemu usermode crashes when using clang as system compiler but works with gcc
+# see https://patchwork.yoctoproject.org/project/oe-core/patch/[email protected]/
+GI_DATA_ENABLED:pn-vte:toolchain-clang:armv7ve = "False"

Was this failure replicated with current master? I’m concerned as to why vte fails but nothing else using G-I.

Ross

author
#8 lore raw

Re: [OE-core] [PATCH v2 03/28] vte: Disable gi data generation when using clang on arm

Quoted 8 lines · Ross Burton

meta/recipes-support/vte/vte_0.78.2.bb SRC_URI[archive.sha256sum] = "35d7bcde07356846b4a12881c8e016705b70a9004a9082285e · line 31

Quoted 3 lines · Khem Raj via lists.openembedded.org
meta/recipes-support/vte/vte_0.78.2.bb +3 -0
+# qemu usermode crashes when using clang as system compiler but works with gcc
+# see https://patchwork.yoctoproject.org/project/oe-core/patch/[email protected]/
+GI_DATA_ENABLED:pn-vte:toolchain-clang:armv7ve = "False"

Was this failure replicated with current master? I’m concerned as to why vte fails but nothing else using G-I.

Yes it still happens.
qemu in usermode crashes during gi data generation with binaries built with clang, I did not have time to go look
why qemu is crashing if someone can it would help.

Quoted 1 line

Ross

#9 lore raw

Re: [OE-core] [PATCH v2 03/28] vte: Disable gi data generation when using clang on arm

In reply to Khem Raj
Quoted 19 lines · Khem Raj via lists.openembedded.org

Fixes Qemu usermode crashes

---
 meta/recipes-support/vte/vte_0.78.2.bb | 4 ++++

 1 file changed, 4 insertions(+)
meta/recipes-support/vte/vte_0.78.2.bb +0 -0
index 0593d16cd8678d010c240581138caf22f2908659..e37d59833cf3313bdb369f4e0957dfc5e3cb3ace 100644
@@ -26,6 +26,10 @@ SRC_URI[archive.sha256sum] = "35d7bcde07356846b4a12881c8e016705b70a9004a9082285e


 ANY_OF_DISTRO_FEATURES = "${GTK3DISTROFEATURES}"

meta/recipes-support/vte/vte_0.78.2.bb +4 -0
+# qemu usermode crashes when using clang as system compiler but works with gcc
+# see https://patchwork.yoctoproject.org/project/oe-core/patch/[email protected]/
+GI_DATA_ENABLED:pn-vte:toolchain-clang:armv7ve = "False"
+
Quoted 2 lines

 EXTRA_OEMESON += "${@bb.utils.contains('GI_DATA_ENABLED', 'True', '-Dvapi=true', '-Dvapi=false', d)}" EXTRA_OEMESON:append = " ${@bb.utils.contains('GI_DATA_ENABLED', 'False', '-Ddocs=false', '', d)}"

I don't really want to regress a feature like like this in a very specific target as it is just going to confuse people. We should probably just force gcc until this gets resolved.

I'm also puzzled why some people can replicate and some can't. We need therefore better data on this too.

As such I'm reluctant to merge due to the difference in features it creates.

Cheers,

Richard

author
#10 lore raw

PATCH v2 4/28 clang: Add compiler-rt to default deps when using clang compiler

In reply to Khem Raj

This provides needed built-ins which clang uses along with libgcc its not yet a full replacement for libgcc

---
 meta/classes/clang.bbclass | 2 ++
 1 file changed, 2 insertions(+)
meta/classes/clang.bbclass +2 -0
index ddf8f350f951744940893698188a1e6056edf7cc..f9cc74142438f1a85a55517c2846f1a72b9af9bf 100644
@@ -24,6 +24,8 @@ PREFERRED_PROVIDER_virtual/nativesdk-cross-cc = "clang-crosssdk-${SDK_SYS}"
 PREFERRED_PROVIDER_virtual/nativesdk-cross-c++ = "clang-crosssdk-${SDK_SYS}"
 PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs = "nativesdk-gcc-runtime"
 
+BASE_DEFAULT_DEPS:append:class-target = " compiler-rt"
+
 TCOVERRIDE = "toolchain-clang"
 
 TUNE_CCARGS += "${@bb.utils.contains("DISTRO_FEATURES", "usrmerge", " --dyld-prefix=/usr", "", d)}"
Signature · 1 line
2.49.0
author
#11 lore raw

PATCH v2 5/28 gnu-efi: Use objcopy from GNU binutils with clang

In reply to Khem Raj

llvm-objcopy reports errors which needs further investigations but stick to binutils provided objcopy meanwhile

---
 meta/recipes-bsp/gnu-efi/gnu-efi_4.0.0.bb | 4 ++++
 1 file changed, 4 insertions(+)
meta/recipes-bsp/gnu-efi/gnu-efi_4.0.0.bb +4 -0
index 29d9e695a9213d63d10ca62b6e77eab291615331..cee320a510a117be0b1f4c554a9954341a065d71 100644
@@ -22,6 +22,10 @@ SRCREV = "5ea320f0f01c8de8f9dd4e4e38a245608f0287dd"
 
 S = "${WORKDIR}/git"
 
+# llvm-objcopy fails
+# arm-poky-linux-gnueabi-llvm-objcopy: error: 't8.so': section '.dynstr' cannot be removed because it is referenced by the section '.dynamic'
+OBJCOPY:toolchain-clang = "${HOST_PREFIX}objcopy"
+
 inherit github-releases
 
 do_configure:linux-gnux32:prepend() {
Signature · 1 line
2.49.0
author
#12 lore raw

PATCH v2 6/28 tcf-agent: Fix ranlib call when using llvm-ranlib

In reply to Khem Raj

This ensures that binutils-ranlib or llvm-ranlib
behaves same as gcc-ranlib

---
 meta/recipes-devtools/tcf-agent/tcf-agent_git.bb | 5 +++++
 1 file changed, 5 insertions(+)
meta/recipes-devtools/tcf-agent/tcf-agent_git.bb +5 -0
index 235936288ba792c86af4dd1899b2f6585328141f..41706f4b60f1f25233ff91c8f112b8122a5c6c30 100644
@@ -51,6 +51,11 @@ CFLAGS:append:riscv64 = " ${LCL_STOP_SERVICES}"
 CFLAGS:append:riscv32 = " ${LCL_STOP_SERVICES}"
 CFLAGS:append:loongarch64 = " ${LCL_STOP_SERVICES}"
 
+# This works with gcc-ranlib wrapper only which expands $@ shell array,
+# but it will fail if RANLIB was set to <cross>-ranlib or
+# <cross>-llvm-ranlib has same behaviour
+RANLIB:append:toolchain-clang = " $@"
+
 do_install() {
 	oe_runmake install INSTALLROOT=${D}
 	install -d ${D}${sysconfdir}/init.d/
Signature · 1 line
2.49.0
author
#13 lore raw

PATCH v2 7/28 pulseaudio: Treat -Wunused-command-line-argument as error

In reply to Khem Raj

This ensures that it does not enble SSE when -msse flag is passed, clang warns about unused option on non-x86 targets but it must be flagged as error for configure to notice and fail the check to enable SSE on non-x86 machines

---
 meta/recipes-multimedia/pulseaudio/pulseaudio.inc | 3 +++
 1 file changed, 3 insertions(+)
meta/recipes-multimedia/pulseaudio/pulseaudio.inc +3 -0
index 18c12ede630766bb9204bb1d5efb7cea8695dd1e..3c65aaee6e02cf417e3165c194353883c453aa00 100644
@@ -71,6 +71,9 @@ inherit bash-completion meson pkgconfig useradd gettext perlnative systemd manpa
 # if using --disable-nls
 USE_NLS = "yes"
 
+# Helps tests for -msse fail on non-SSE architectures which is all non-x86
+TUNE_CCARGS:append:toolchain-clang = " -Werror=unused-command-line-argument"
+
 EXTRA_OEMESON = "\
 		-Dhal-compat=false \
 		-Dorc=disabled \
Signature · 1 line
2.49.0
author
#14 lore raw

PATCH v2 8/28 libjpeg-turbo: Fix build on mips/clang

In reply to Khem Raj
---
 meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.0.bb | 6 ++++++
 1 file changed, 6 insertions(+)
meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.0.bb +6 -0
index 8533bd8525311e783572cbafb6fccf240db9e0e8..90aa2ef43956f0a1e64f8e08e47d953bf5773e19 100644
@@ -47,6 +47,12 @@ EXTRA_OECMAKE:append:class-target:powerpc64le = " ${@bb.utils.contains("TUNE_FEA
 DEBUG_OPTIMIZATION:append:armv4 = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
 DEBUG_OPTIMIZATION:append:armv5 = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
 
+# libjpeg-turbo-2.0.2/simd/mips/jsimd_dspr2.S
+# <instantiation>:13:5: error: invalid token in expression
+# .if $17 != 0
+# ^
+CFLAGS:append:toolchain-clang:mipsarch = " -no-integrated-as"
+
 PACKAGES =+ "jpeg-tools libturbojpeg"
 
 DESCRIPTION:jpeg-tools = "The jpeg-tools package includes client programs to access libjpeg functionality.  These tools allow for the compression, decompression, transformation and display of JPEG files and benchmarking of the libjpeg library."
Signature · 1 line
2.49.0
#15 lore raw

Re: [OE-core] [PATCH v2 08/28] libjpeg-turbo: Fix build on mips/clang

Quoted 14 lines · Khem Raj via lists.openembedded.org

---
meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.0.bb | 6 ++++++

1 file changed, 6 insertions(+)
meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.0.bb +0 -0
index 8533bd8525311e783572cbafb6fccf240db9e0e8..90aa2ef43956f0a1e64f8e08e47d953bf5773e19 100644
@@ -47,6 +47,12 @@ EXTRA_OECMAKE:append:class-target:powerpc64le = " ${@bb.utils.contains("TUNE_FEA

DEBUG_OPTIMIZATION:append:armv4 = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}" DEBUG_OPTIMIZATION:append:armv5 = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"

meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.0.bb EXTRA_OECMAKE:append:class-target:powerpc64le = " ${@bb.utils.contains("TUNE_FEA · line 54

Quoted 5 lines
meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.0.bb +5 -0
+# libjpeg-turbo-2.0.2/simd/mips/jsimd_dspr2.S
+# <instantiation>:13:5: error: invalid token in expression
+# .if $17 != 0
+# ^
+CFLAGS:append:toolchain-clang:mipsarch = " -no-integrated-as"

The log is from 2.0.2, did you replicate this with 3.1.0 before moving from meta-clang?

Ross

author
#16 lore raw

Re: [OE-core] [PATCH v2 08/28] libjpeg-turbo: Fix build on mips/clang

Quoted 16 lines · Ross Burton
Quoted 14 lines · Khem Raj via lists.openembedded.org

---
meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.0.bb | 6 ++++++

1 file changed, 6 insertions(+)
meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.0.bb +0 -0
index 8533bd8525311e783572cbafb6fccf240db9e0e8..90aa2ef43956f0a1e64f8e08e47d953bf5773e19 100644
@@ -47,6 +47,12 @@ EXTRA_OECMAKE:append:class-target:powerpc64le = " ${@bb.utils.contains("TUNE_FEA

DEBUG_OPTIMIZATION:append:armv4 = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}" DEBUG_OPTIMIZATION:append:armv5 = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"

Quoted 7 lines

meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.0.bb EXTRA_OECMAKE:append:class-target:powerpc64le = " ${@bb.utils.contains("TUNE_FEA · line 54

Quoted 5 lines
meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.0.bb +5 -0
+# libjpeg-turbo-2.0.2/simd/mips/jsimd_dspr2.S
+# <instantiation>:13:5: error: invalid token in expression
+# .if $17 != 0
+# ^
+CFLAGS:append:toolchain-clang:mipsarch = " -no-integrated-as"

The log is from 2.0.2, did you replicate this with 3.1.0 before moving from meta-clang?

Yes, I have started with vanilla poky and waded through world builds for all qemu machines, bringing only the changes which were still failing and not fixable differently. If this helps.

Quoted 3 lines

Ross

author
#17 lore raw

PATCH v2 9/28 pixman: Fix build with mips/clang

In reply to Khem Raj
---
 meta/recipes-graphics/xorg-lib/pixman_0.46.0.bb | 3 +++
 1 file changed, 3 insertions(+)
meta/recipes-graphics/xorg-lib/pixman_0.46.0.bb +3 -0
index c1c71fd42023fbd8c82d49ff623a981139f5ac7e..0c779ac3b4e6d035d9105c98aea0560a71d57ba3 100644
@@ -6,6 +6,7 @@ including trapezoids, triangles, and rectangles."
 HOMEPAGE = "http://www.pixman.org"
 SECTION = "x11/libs"
 DEPENDS = "zlib"
+DEPENDS:append:toolchain-clang:mipsarch = " openmp"
 
 SRC_URI = "https://www.cairographics.org/releases/${BP}.tar.gz"
 SRC_URI[sha256sum] = "02d9ff7b8458ef61731c3d355f854bbf461fd0a4d3563c51f1c1c7b00638050d"
@@ -38,6 +39,8 @@ EXTRA_OEMESON:append:armv7ve = "${@bb.utils.contains("TUNE_FEATURES","neon","","
 
 EXTRA_OEMESON:append:class-native = " -Dopenmp=disabled"
 
+CFLAGS:append:toolchain-clang:mipsarch = " -fno-integrated-as"
+
 BBCLASSEXTEND = "native nativesdk"
 
 CVE_STATUS[CVE-2023-37769] = "not-applicable-config: stress-test is an uninstalled test"
Signature · 1 line
2.49.0
author
#18 lore raw

PATCH v2 10/28 systemd-boot: Remove -mfpmath=sse option from cflags

In reply to Khem Raj

EFI sources in systemd uses -mgeneral-regs-only which conflicts with -mfpmath=sse specified by OE via tune arguments. It needs to be removed, clang errors about it and fails the build

Fixes
error: the 'sse' unit is not supported with this instruction set

---
 meta/recipes-core/systemd/systemd-boot_257.5.bb | 5 +++++
 1 file changed, 5 insertions(+)
meta/recipes-core/systemd/systemd-boot_257.5.bb +5 -0
index 6a50ac05aa9915982dca4649f7bda610cfbfa14b..151e4a953735b524ed14a5ef5459dd037efdcdaf 100644
@@ -47,6 +47,11 @@ FILES:${PN} = "${EFI_FILES_PATH}/${SYSTEMD_BOOT_IMAGE}"
 
 RDEPENDS:${PN} += "virtual-systemd-bootconf"
 
+# efi portions use -mgeneral-regs-only option which conflicts with SSE
+# especially clang throws errors about it
+# error: the 'sse' unit is not supported with this instruction set
+TUNE_CCARGS:remove = "-mfpmath=sse"
+
 CFLAGS:append:libc-musl = " -D__DEFINED_wchar_t"
 
 COMPATIBLE_HOST = "(aarch64.*|arm.*|x86_64.*|i.86.*|riscv.*)-linux"
Signature · 1 line
2.49.0
author
#19 lore raw

PATCH v2 11/28 vulkan-samples: Disable overriding-option as error

In reply to Khem Raj

Clang complains/warns about mixing -ffp-contract=fast and -ffp-model=precise lower this to warning only, this does not impact code generation, we still get the diagnostic messge but wont break the build

---
 meta/recipes-graphics/vulkan/vulkan-samples_git.bb | 4 ++++
 1 file changed, 4 insertions(+)
meta/recipes-graphics/vulkan/vulkan-samples_git.bb +4 -0
index 554e6eb29022e763de755dd550464cbd986de61e..505b6ab2f2865fec26339c9f1c4aa10c6735355b 100644
@@ -33,4 +33,8 @@ EXTRA_OECMAKE += "-DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON"
 # This needs to be specified explicitly to avoid xcb/xlib dependencies
 EXTRA_OECMAKE += "-DVKB_WSI_SELECTION=D2D"
 
+# Clang is fussy about incompatible options on aarch64/x86_64
+# x86_64-poky-linux-clang++: error: overriding '-ffp-model=precise' option with '-ffp-contract=fast' [-Werror,-Woverriding-option]
+CXXFLAGS:append:toolchain-clang = " -Wno-error=overriding-option"
+
 COMPATIBLE_HOST = "(aarch64|x86_64).*-linux"
Signature · 1 line
2.49.0
#20 lore raw

Re: [OE-core] [PATCH v2 11/28] vulkan-samples: Disable overriding-option as error

meta/recipes-graphics/vulkan/vulkan-samples_git.bb EXTRA_OECMAKE += "-DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON" · line 38

Quoted 6 lines · Khem Raj via lists.openembedded.org
meta/recipes-graphics/vulkan/vulkan-samples_git.bb +3 -0
+# Clang is fussy about incompatible options on aarch64/x86_64
+# x86_64-poky-linux-clang++: error: overriding '-ffp-model=precise' option with '-ffp-contract=fast' [-Werror,-Woverriding-option]
+CXXFLAGS:append:toolchain-clang = " -Wno-error=overriding-option"

Where are these conflicting flags coming from? Feels like we should be fixing the upstream Makefiles instead?

Ross

author
#21 lore raw

Re: [OE-core] [PATCH v2 11/28] vulkan-samples: Disable overriding-option as error

Quoted 9 lines · Ross Burton

meta/recipes-graphics/vulkan/vulkan-samples_git.bb EXTRA_OECMAKE += "-DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON" · line 38

Quoted 7 lines · Khem Raj via lists.openembedded.org
meta/recipes-graphics/vulkan/vulkan-samples_git.bb +3 -0
+# Clang is fussy about incompatible options on aarch64/x86_64
+# x86_64-poky-linux-clang++: error: overriding '-ffp-model=precise' option with '-ffp-contract=fast' [-Werror,-Woverriding-option]
+CXXFLAGS:append:toolchain-clang = " -Wno-error=overriding-option"

Where are these conflicting flags coming from? Feels like we should be fixing the upstream Makefiles instead?

Maybe, the end effect is that the last option wins and that is correct here so I did not see a need to fix it. If someone wants to that is appreciated,

Quoted 2 lines

Ross

author
#22 lore raw

PATCH v2 12/28 openssl: Link with libatomic on x86/clang

In reply to Khem Raj

Fixes

threads_pthread.c:(.text+0x372): undefined reference to `__atomic_is_lock_free'

---
 meta/recipes-connectivity/openssl/openssl_3.5.0.bb | 3 +++
 1 file changed, 3 insertions(+)
meta/recipes-connectivity/openssl/openssl_3.5.0.bb +3 -0
index fddc4dbc813cd06333d72c38852db14ef39d25c1..0f5c28dafa314e52c3497a2e571b572475806e04 100644
@@ -53,6 +53,9 @@ EXTRA_OECONF:append:class-nativesdk = " --with-rand-seed=os,devrandom"
 EXTRA_OEMAKE:append:task-compile:class-native = ' OPENSSLDIR="/not/builtin" ENGINESDIR="/not/builtin" MODULESDIR="/not/builtin"'
 EXTRA_OEMAKE:append:task-compile:class-nativesdk = ' OPENSSLDIR="/not/builtin" ENGINESDIR="/not/builtin" MODULESDIR="/not/builtin"'
 
+#| threads_pthread.c:(.text+0x372): undefined reference to `__atomic_is_lock_free'
+EXTRA_OECONF:append:toolchain-clang:x86 = " -latomic"
+
 # This allows disabling deprecated or undesirable crypto algorithms.
 # The default is to trust upstream choices.
 DEPRECATED_CRYPTO_FLAGS ?= ""
Signature · 1 line
2.49.0
#23 lore raw

Re: [OE-core] [PATCH v2 12/28] openssl: Link with libatomic on x86/clang

Quoted 3 lines · Khem Raj via lists.openembedded.org

Fixes

threads_pthread.c:(.text+0x372): undefined reference to `__atomic_is_lock_free'

Khem,

These changes make sense to enable clang builds. (Yay and wow!)

There are a couple of cases where we need to add -latomic, here for openssl and also for qemu.

Is that an upstream <pkg> or clang/lld issue?
Is there a bug reported or should Sunil do that?

In general, how do you want to handle the exceptions?

I'm tempted to ignore the arm32 issue but I expect that some people will not be happy with that for several years if every. Right Ross?

 Thanks,

../Randy

Quoted 30 lines
---
  meta/recipes-connectivity/openssl/openssl_3.5.0.bb | 3 +++
  1 file changed, 3 insertions(+)
meta/recipes-connectivity/openssl/openssl_3.5.0.bb +3 -1
index fddc4dbc813cd06333d72c38852db14ef39d25c1..0f5c28dafa314e52c3497a2e571b572475806e04 100644
@@ -53,6 +53,9 @@ EXTRA_OECONF:append:class-nativesdk = " --with-rand-seed=os,devrandom"
  EXTRA_OEMAKE:append:task-compile:class-native = ' OPENSSLDIR="/not/builtin" ENGINESDIR="/not/builtin" MODULESDIR="/not/builtin"'
  EXTRA_OEMAKE:append:task-compile:class-nativesdk = ' OPENSSLDIR="/not/builtin" ENGINESDIR="/not/builtin" MODULESDIR="/not/builtin"'
 
+#| threads_pthread.c:(.text+0x372): undefined reference to `__atomic_is_lock_free'
+EXTRA_OECONF:append:toolchain-clang:x86 = " -latomic"
+
  # This allows disabling deprecated or undesirable crypto algorithms.
  # The default is to trust upstream choices.
  DEPRECATED_CRYPTO_FLAGS ?= ""
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#216980):https://lists.openembedded.org/g/openembedded-core/message/216980 Mute This Topic:https://lists.openembedded.org/mt/113225023/3616765
Group Owner:[email protected] Unsubscribe:https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 2 lines
# Randy MacLeod
# Wind River Linux
author
#24 lore raw

PATCH v2 13/28 qemu: Link with libatomic on x86/clang

In reply to Khem Raj

Clang does need libatomic to provide 64bit atomic
builtins on 32bit x86

---
 meta/recipes-devtools/qemu/qemu_10.0.0.bb | 1 +
 1 file changed, 1 insertion(+)
meta/recipes-devtools/qemu/qemu_10.0.0.bb +1 -0
index dc1352232ef58c7f64660871488ce8cd67f7cacb..5d544d8d132ff228fe9aa9a5f5e567a3937406df 100644
@@ -7,6 +7,7 @@ DEPENDS += "glib-2.0 zlib pixman"
 DEPENDS:append:libc-musl = " libucontext"
 
 CFLAGS += "${@bb.utils.contains('DISTRO_FEATURES', 'x11', '', '-DEGL_NO_X11=1', d)}"
+LDFLAGS:append:toolchain-clang:x86 = " -latomic"
 
 RDEPENDS:${PN}-common:class-target += "bash"
 
Signature · 1 line
2.49.0
author
#25 lore raw

PATCH v2 14/28 bluez: Disable invalid-pp-token warning with clang

In reply to Khem Raj

We add FIRMWARE_DIR via CFLAGS using escapes for string and clang option parser flags it

<command line>:4:23: warning: missing terminating '"' character [-Winvalid-pp-token]
4 | #define FIRMWARE_DIR \"/usr/lib/firmware\"
| ^

emitting this warning during configure means some tests fail wrongly. e.g. test for enable -fPIC -DPIC, which results in textrels in libbbluetooth.so

This warning can be disabled, the string is correctly passed to sources in the end, so its spurious

---
 meta/recipes-connectivity/bluez5/bluez5.inc | 1 +
 1 file changed, 1 insertion(+)
meta/recipes-connectivity/bluez5/bluez5.inc +1 -0
index 7bae968094f2a272c4deff7416dbd1208549e6ce..5835662f7a63a23915ec4af94597ec4a614a4640 100644
@@ -84,6 +84,7 @@ EXTRA_OECONF = "\
 "
 
 CFLAGS += "-DFIRMWARE_DIR=\\"${nonarch_base_libdir}/firmware\\""
+CFLAGS:append:toolchain-clang = " -Wno-invalid-pp-token"
 
 # bluez5 builds a large number of useful utilities but does not
 # install them.  Specify which ones we want put into ${PN}-noinst-tools.
Signature · 1 line
2.49.0
#26 lore raw

Re: [OE-core] [PATCH v2 14/28] bluez: Disable invalid-pp-token warning with clang

Quoted 29 lines · Khem Raj via lists.openembedded.org

We add FIRMWARE_DIR via CFLAGS using escapes for string and clang option parser flags it

<command line>:4:23: warning: missing terminating '"' character [-Winvalid-pp-token]
4 | #define FIRMWARE_DIR \"/usr/lib/firmware\"
| ^

emitting this warning during configure means some tests fail wrongly. e.g. test for enable -fPIC -DPIC, which results in textrels in libbbluetooth.so

This warning can be disabled, the string is correctly passed to sources in the end, so its spurious

---
meta/recipes-connectivity/bluez5/bluez5.inc | 1 +

1 file changed, 1 insertion(+)
meta/recipes-connectivity/bluez5/bluez5.inc +0 -0
index 7bae968094f2a272c4deff7416dbd1208549e6ce..5835662f7a63a23915ec4af94597ec4a614a4640 100644
@@ -84,6 +84,7 @@ EXTRA_OECONF = "\

"

Quoted 2 lines

CFLAGS += "-DFIRMWARE_DIR=\\"${nonarch_base_libdir}/firmware\\"" +CFLAGS:append:toolchain-clang = " -Wno-invalid-pp-token”

Wouldn’t it be neater to change the line above to:

CFLAGS += "-DFIRMWARE_DIR="${nonarch_base_libdir}/firmware”"

Bitbake’s parser is crazy and stuff like that works.

Ross

author
#27 lore raw

Re: [OE-core] [PATCH v2 14/28] bluez: Disable invalid-pp-token warning with clang

Quoted 29 lines · Ross Burton
Quoted 29 lines · Khem Raj via lists.openembedded.org

We add FIRMWARE_DIR via CFLAGS using escapes for string and clang option parser flags it

<command line>:4:23: warning: missing terminating '"' character [-Winvalid-pp-token]
4 | #define FIRMWARE_DIR \"/usr/lib/firmware\"
| ^

emitting this warning during configure means some tests fail wrongly. e.g. test for enable -fPIC -DPIC, which results in textrels in libbbluetooth.so

This warning can be disabled, the string is correctly passed to sources in the end, so its spurious

---
meta/recipes-connectivity/bluez5/bluez5.inc | 1 +

1 file changed, 1 insertion(+)
meta/recipes-connectivity/bluez5/bluez5.inc +0 -0
index 7bae968094f2a272c4deff7416dbd1208549e6ce..5835662f7a63a23915ec4af94597ec4a614a4640 100644
@@ -84,6 +84,7 @@ EXTRA_OECONF = "\

"

Quoted 8 lines
Quoted 2 lines

CFLAGS += "-DFIRMWARE_DIR=\\"${nonarch_base_libdir}/firmware\\"" +CFLAGS:append:toolchain-clang = " -Wno-invalid-pp-token”

Wouldn’t it be neater to change the line above to:

CFLAGS += "-DFIRMWARE_DIR="${nonarch_base_libdir}/firmware”"

Bitbake’s parser is crazy and stuff like that works.

I have tried several ways to pass it, what you suggest was in fact first thing I tried and it passes -DFIRMWARE_DIR="/usr/lib/firmware” as seen in bitbake preprocessing output but emits following into an implicit header file that compiler sees

#define FIRMWARE_DIR /usr/lib/firmware

which is not right string syntax in C. what we need is

#define FIRMWARE_DIR "/usr/lib/firmware"

on compiler commandline it should look like

-DFIRMWARE_DIR=\"/usr/lib/firmware\"

So how can we teach bitbake to do this ?

Quoted 2 lines

Ross

author
#28 lore raw

PATCH v2 15/28 gcc: Always use GCC toolchain

In reply to Khem Raj

GCC is not yet compilable with clang e.g.

---
 meta/recipes-devtools/gcc/gcc-15.1.inc | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-devtools/gcc/gcc-15.1.inc +2 -0
index 864c6091a6be81567bec2aaa9133c3929eaa2286..f3e9204131425b54e862655a52fd60fb4f8c41ca 100644
@@ -10,6 +10,8 @@ BINV = "15.1.0"
 
 FILESEXTRAPATHS =. "${FILE_DIRNAME}/gcc:${FILE_DIRNAME}/gcc/backport:"
 
+TOOLCHAIN = "gcc"
+
 DEPENDS =+ "mpfr gmp libmpc zlib zstd flex-native"
 NATIVEDEPS = "mpfr-native gmp-native libmpc-native zlib-native flex-native zstd-native"
 
Signature · 1 line
2.49.0
author
#29 lore raw

PATCH v2 16/28 glibc: Always use GCC toolchain

In reply to Khem Raj

Glibc is not yet buildable with non-gcc compilers e.g. clang

---
 meta/recipes-core/glibc/glibc-common.inc | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-core/glibc/glibc-common.inc +2 -0
index e048f75c5d743977151eccbc151b6c0726407067..fb62a4af94ae5ec5ee0e07dc2b953521af534a62 100644
@@ -23,3 +23,5 @@ ARM_INSTRUCTION_SET:armv6 = "arm"
 COMPATIBLE_HOST:libc-musl:class-target = "null"
 
 PV = "2.41+git"
+
+TOOLCHAIN = "gcc"
Signature · 1 line
2.49.0
author
#30 lore raw

PATCH v2 17/28 grub,grub-efi: Pin to using gcc on aarch64

In reply to Khem Raj

It needs porting to work with clang

---
 meta/recipes-bsp/grub/grub2.inc | 4 ++++
 1 file changed, 4 insertions(+)
meta/recipes-bsp/grub/grub2.inc +4 -0
index 1fe39a59d2d9dc6909ba88bfceaf6fd4222c13d2..ffa04e415d379d431995d551f5ca6f9ce479a87c 100644
@@ -106,3 +106,7 @@ do_configure:prepend() {
 	FROM_BOOTSTRAP=1 ${S}/autogen.sh
 	cd ${B}
 }
+
+# | aarch64-poky-linux-clang: error: invalid argument '-mcmodel=large' only allowed with '-fno-pic'
+# see - https://bugs.gentoo.org/942843
+TOOLCHAIN:aarch64 = "gcc"
Signature · 1 line
2.49.0
author
#31 lore raw

PATCH v2 18/28 valgrind: Use gcc to compile on riscv64

In reply to Khem Raj

clang does not yet support __builtin_longjmp on riscv64

---
 meta/recipes-devtools/valgrind/valgrind_3.25.0.bb | 8 ++++++++
 1 file changed, 8 insertions(+)
meta/recipes-devtools/valgrind/valgrind_3.25.0.bb +8 -0
index 6650dcedbfd09e03493306207aa2bf210741976b..3ae5db0ecacefb4307685c00d467806b0bc986fc 100644
@@ -106,3 +106,11 @@ INHIBIT_PACKAGE_STRIP_FILES = "${PKGD}${libexecdir}/valgrind/vgpreload_memcheck-
 # valgrind needs debug information for ld.so at runtime in order to
 # redirect functions like strlen.
 RRECOMMENDS:${PN} += "${TCLIBC}-dbg"
+
+# Valgrind needs intrinsics which are not provided by clang
+# m_signals.c:2213:7: error: __builtin_longjmp is not supported for the current target
+# 2213 |       VG_MINIMAL_LONGJMP(tst->sched_jmpbuf);
+#      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# It needs something like - https://bugs.kde.org/show_bug.cgi?id=369723
+TOOLCHAIN:riscv64 = "gcc"
Signature · 1 line
2.49.0
author
#32 lore raw

PATCH v2 19/28 syslinux: Pin to using GCC toolchain

In reply to Khem Raj

It does not compile with clang due to include_next stdarg.h not working as the system expects to match gcc behavior

---
 meta/recipes-devtools/syslinux/syslinux_6.04-pre2.bb | 5 +++++
 1 file changed, 5 insertions(+)
meta/recipes-devtools/syslinux/syslinux_6.04-pre2.bb +5 -0
index 1e65616081bea95ff28f40eec362195cbaf77390..449a75ebf8abf1dd6865f641f696ac1b67278819 100644
@@ -130,3 +130,8 @@ FILES:${PN}-staticdev += "${datadir}/${BPN}/com32/lib*.a ${libdir}/${BPN}/com32/
 FILES:${PN}-misc = "${datadir}/${BPN}/* ${libdir}/${BPN}/* ${bindir}/*"
 
 BBCLASSEXTEND = "native nativesdk"
+
+# com32/lib/../include/stdarg.h:9:15: fatal error: 'stdarg.h' file not found
+#    9 | #include_next <stdarg.h>
+#      |               ^~~~~~~~~~
+TOOLCHAIN = "gcc"
Signature · 1 line
2.49.0
author
#33 lore raw

PATCH v2 20/28 systemtap: Pin to build with GCC

In reply to Khem Raj

clang find a lot of warning

| In file included from ../git/tapset-procfs.cxx:11:
| ../git/session.h:169:47: error: 'used' attribute ignored on a non-definition declaration [-Werror,-Wignored-attributes]
|   169 |   static const char* morehelp __attribute__ ((used));
|       |                                               ^
---
 meta/recipes-kernel/systemtap/systemtap_git.bb | 4 ++++
 1 file changed, 4 insertions(+)
meta/recipes-kernel/systemtap/systemtap_git.bb +4 -0
index 21d50ffb04977bdd9666fbabb5e27289aff01370..254bac4d6f9c8637c575b4b7896322bd42e96841 100644
@@ -99,3 +99,7 @@ do_install:append () {
 }
 
 BBCLASSEXTEND = "nativesdk"
+
+# Emits lot of warning which are treated as errors
+# They must be looked into before disabling
+TOOLCHAIN = "gcc"
Signature · 1 line
2.49.0
#34 lore raw

Re: [OE-core] [PATCH v2 20/28] systemtap: Pin to build with GCC

Quoted 21 lines · Khem Raj via lists.openembedded.org

clang find a lot of warning

| In file included from ../git/tapset-procfs.cxx:11:
| ../git/session.h:169:47: error: 'used' attribute ignored on a non-definition declaration [-Werror,-Wignored-attributes]
|   169 |   static const char* morehelp __attribute__ ((used));
|       |                                               ^

---
meta/recipes-kernel/systemtap/systemtap_git.bb | 4 ++++

1 file changed, 4 insertions(+)
meta/recipes-kernel/systemtap/systemtap_git.bb +0 -0
index 21d50ffb04977bdd9666fbabb5e27289aff01370..254bac4d6f9c8637c575b4b7896322bd42e96841 100644
@@ -99,3 +99,7 @@ do_install:append () {
 }
 

BBCLASSEXTEND = "nativesdk"

meta/recipes-kernel/systemtap/systemtap_git.bb do_install:append () {

Quoted 4 lines
meta/recipes-kernel/systemtap/systemtap_git.bb +4 -0
+
+# Emits lot of warning which are treated as errors
+# They must be looked into before disabling
+TOOLCHAIN = “gcc"

Upstream configure.ac has a —disable-error which is probably the right thing to do:

https://sourceware.org/git/?p=systemtap.git;a=blob;f=configure.ac;h=6fc9527650413569300aa41cb154757ecc06be97;hb=HEAD#l126

Ross

author
#35 lore raw

Re: [OE-core] [PATCH v2 20/28] systemtap: Pin to build with GCC

Quoted 30 lines · Ross Burton
Quoted 21 lines · Khem Raj via lists.openembedded.org

clang find a lot of warning

| In file included from ../git/tapset-procfs.cxx:11:
| ../git/session.h:169:47: error: 'used' attribute ignored on a non-definition declaration [-Werror,-Wignored-attributes]
|   169 |   static const char* morehelp __attribute__ ((used));
|       |                                               ^

---
meta/recipes-kernel/systemtap/systemtap_git.bb | 4 ++++

1 file changed, 4 insertions(+)
meta/recipes-kernel/systemtap/systemtap_git.bb +0 -0
index 21d50ffb04977bdd9666fbabb5e27289aff01370..254bac4d6f9c8637c575b4b7896322bd42e96841 100644
@@ -99,3 +99,7 @@ do_install:append () {
 }
 

BBCLASSEXTEND = "nativesdk"

meta/recipes-kernel/systemtap/systemtap_git.bb do_install:append () {

Quoted 4 lines
meta/recipes-kernel/systemtap/systemtap_git.bb +4 -0
+
+# Emits lot of warning which are treated as errors
+# They must be looked into before disabling
+TOOLCHAIN = “gcc"

Upstream configure.ac has a —disable-error which is probably the right thing to do:

Quoted 2 lines

https://sourceware.org/git/?p=systemtap.git;a=blob;f=configure.ac;h=6fc9527650413569300aa41cb154757ecc06be97;hb=HEAD#l126

yeah it is not sufficient though, there still are warnings reported as errors - https://termbin.com/o1qn

Quoted 1 line

Ross

author
#36 lore raw

PATCH v2 21/28 webkitgtk: Use gcc to compile for arm target

In reply to Khem Raj

Builds with clang run into compiler errors

<inline asm>:320:1: error: Relocation Not In Range
320 | movw r4, #:lower16:.Lllint_op_tail_call_varargs - .Lllint_relativePCBase

      | ^
---
 meta/recipes-sato/webkit/webkitgtk_2.48.1.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-sato/webkit/webkitgtk_2.48.1.bb +2 -0
index 5b9846a6d631cb85d5dbe103155670dde9e6b777..a58b44440ee15fdbc5e9d6dbb9565fe4dcad4802 100644
@@ -176,3 +176,5 @@ src_package_preprocess () {
             ${B}/WebKitGTK/DerivedSources/webkit/*.cpp
 }
 
+# Clang-20 issue - https://github.com/llvm/llvm-project/issues/132322
+TOOLCHAIN:arm = "gcc"
Signature · 1 line
2.49.0
author
#37 lore raw

PATCH v2 22/28 pseudo: Pin to using GCC compiler

In reply to Khem Raj

It uses compiler built-ins which clang does not provide

---
 meta/recipes-devtools/pseudo/pseudo_git.bb | 7 +++++++
 1 file changed, 7 insertions(+)
meta/recipes-devtools/pseudo/pseudo_git.bb +7 -0
index d7528d336b14351b99e7a8c6a8ab3d96b1cbb224..4693afcaf62cb1fd48b802db78b32a1f51e44df3 100644
@@ -25,3 +25,10 @@ TARGET_CC_ARCH:remove = "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS
 
 # error: use of undeclared identifier '_STAT_VER'
 COMPATIBLE_HOST:libc-musl = 'null'
+
+#| ./ports/linux/pseudo_wrappers.c:80:14: error: use of unknown builtin '__builtin_apply' [-Wimplicit-function-declaration]
+#|         void *res = __builtin_apply((void (*)()) real_syscall, __builtin_apply_args(), sizeof(long) * 7);
+#|                     ^
+#| ./ports/linux/pseudo_wrappers.c:80:57: error: use of unknown builtin '__builtin_apply_args' [-Wimplicit-function-declaration]
+#|         void *res = __builtin_apply((void (*)()) real_syscall, __builtin_apply_args(), sizeof(long) * 7);
+TOOLCHAIN = "gcc"
Signature · 1 line
2.49.0
author
#38 lore raw

PATCH v2 23/28 rpm: Always use gcc compiler

In reply to Khem Raj

clang can build it ok but the openmp directives get emitted with full paths into binaries [1] until thats fixed in clang/openmp stick to gcc

[1] https://github.com/llvm/llvm-project/issues/82541

---
 meta/recipes-devtools/rpm/rpm_4.20.0.bb | 4 ++++
 1 file changed, 4 insertions(+)
meta/recipes-devtools/rpm/rpm_4.20.0.bb +4 -0
index 281fde1c82904caaa4c0aea94994b3ea3ac47315..bcc138dab045a25acf2ba73684d06c0a7df5aeba 100644
@@ -62,6 +62,10 @@ OECMAKE_GENERATOR = "Unix Makefiles"
 
 BBCLASSEXTEND = "native nativesdk"
 
+# Clang results in a reproducibility issue
+# https://github.com/llvm/llvm-project/issues/82541
+TOOLCHAIN = "gcc"
+
 PACKAGECONFIG ??= "archive"
 
 PACKAGECONFIG[plugins] = "-DENABLE_PLUGINS=ON,-DENABLE_PLUGINS=OFF"
Signature · 1 line
2.49.0
author
#39 lore raw

PATCH v2 24/28 pulseaudio: Pin to use GCC compiler

In reply to Khem Raj

Inline assembly is not written in portable fashion

---
 meta/recipes-multimedia/pulseaudio/pulseaudio.inc | 5 +++++
 1 file changed, 5 insertions(+)
meta/recipes-multimedia/pulseaudio/pulseaudio.inc +5 -0
index 3c65aaee6e02cf417e3165c194353883c453aa00..695f4b676de8c7a642efd6b713f9a66d6d658de4 100644
@@ -74,6 +74,11 @@ USE_NLS = "yes"
 # Helps tests for -msse fail on non-SSE architectures which is all non-x86
 TUNE_CCARGS:append:toolchain-clang = " -Werror=unused-command-line-argument"
 
+# mix_neon.c:179:9: error: invalid operand in inline asm: 'vld1.s32 ${0:h}, [$2]
+#      vld1.s32 ${1:h}, [$3] '
+TOOLCHAIN:armv7ve = "gcc"
+TOOLCHAIN:armv7a = "gcc"
+
 EXTRA_OEMESON = "\
 		-Dhal-compat=false \
 		-Dorc=disabled \
Signature · 1 line
2.49.0
author
#40 lore raw

PATCH v2 25/28 seatd: Disable sign-compare warning as error on clang

In reply to Khem Raj

Make it build with clang+musl combo

---
 meta/recipes-core/seatd/seatd_0.9.1.bb | 8 ++++++++
 1 file changed, 8 insertions(+)
meta/recipes-core/seatd/seatd_0.9.1.bb +8 -0
index 8ee43a3dc8f61eeb6f1c03dbd5a68585fa471424..87e1c3b67d69ba29cfde14caf17e3a2010046eac 100644
@@ -15,6 +15,14 @@ inherit meson pkgconfig systemd update-rc.d useradd
 
 # https://www.openwall.com/lists/musl/2020/01/20/3
 CFLAGS:append:libc-musl:powerpc64le = " -Wno-error=overflow"
+#../git/common/connection.c:154:55: error: comparison of integers of different signs: 'unsigned long' and 'long' [-Werror,-Wsign-compare]
+#  154 |         for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) {
+#      |                                                              ^~~~~~~~~~~~~~~~~~~~~~
+#/mnt/b/yoe/master/sources/poky/build/tmp/work/riscv64-poky-linux-musl/seatd/0.9.1/recipe-sysroot/usr/include/sys/socket.h:358:44: note: expanded from macro 'CMSG_NXTHDR'
+#  358 |         __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
+#      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#1 error generated.
+CFLAGS:append:libc-musl:toolchain-clang = " -Wno-error=sign-compare"
 
 PACKAGECONFIG ?= " \
 	${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} \
Signature · 1 line
2.49.0
#41 lore raw

Re: [OE-core] [PATCH v2 25/28] seatd: Disable sign-compare warning as error on clang

meta/recipes-core/seatd/seatd_0.9.1.bb inherit meson pkgconfig systemd update-rc.d useradd · line 25

Quoted 8 lines · Khem Raj via lists.openembedded.org
meta/recipes-core/seatd/seatd_0.9.1.bb +8 -0
+#../git/common/connection.c:154:55: error: comparison of integers of different signs: 'unsigned long' and 'long' [-Werror,-Wsign-compare]
+#  154 |         for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) {
+#      |                                                              ^~~~~~~~~~~~~~~~~~~~~~
+#/mnt/b/yoe/master/sources/poky/build/tmp/work/riscv64-poky-linux-musl/seatd/0.9.1/recipe-sysroot/usr/include/sys/socket.h:358:44: note: expanded from macro 'CMSG_NXTHDR'
+#  358 |         __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
+#      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#1 error generated.
+CFLAGS:append:libc-musl:toolchain-clang = " -Wno-error=sign-compare"

This is silencing an error, and it would be better to fix the issue instead. Also, why is it musl-specific?

Alex

author
#42 lore raw

Re: [OE-core] [PATCH v2 25/28] seatd: Disable sign-compare warning as error on clang

Quoted 14 lines · Alexander Kanavin

meta/recipes-core/seatd/seatd_0.9.1.bb inherit meson pkgconfig systemd update-rc.d useradd · line 25

Quoted 8 lines · Khem Raj via lists.openembedded.org
meta/recipes-core/seatd/seatd_0.9.1.bb +8 -0
+#../git/common/connection.c:154:55: error: comparison of integers of different signs: 'unsigned long' and 'long' [-Werror,-Wsign-compare]
+#  154 |         for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) {
+#      |                                                              ^~~~~~~~~~~~~~~~~~~~~~
+#/mnt/b/yoe/master/sources/poky/build/tmp/work/riscv64-poky-linux-musl/seatd/0.9.1/recipe-sysroot/usr/include/sys/socket.h:358:44: note: expanded from macro 'CMSG_NXTHDR'
+#  358 |         __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
+#      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#1 error generated.
+CFLAGS:append:libc-musl:toolchain-clang = " -Wno-error=sign-compare"

This is silencing an error, and it would be better to fix the issue instead. Also, why is it musl-specific?

It does not look like a problem in the package but rather something in system headers from musl since CMSG_NXTHDR is from sys/socket.h thats why its done
the way it is. I am working with musl to see if this is the right behavior for musl

Quoted 2 lines

Alex

author
#43 lore raw

PATCH v2 26/28 busybox: Fix build on architectures without SYS_settimeofday

In reply to Khem Raj

Fixes following errors on riscv32/musl

| util-linux/hwclock.c:143:20: error: use of undeclared identifier 'SYS_settimeofday'
|   143 |         int ret = syscall(SYS_settimeofday, NULL, tz);
|       |                           ^
| 1 error generated.
---
 ...ck-for-SYS_settimeofday-before-calling-sy.patch | 52 ++++++++++++++++++++++
 meta/recipes-core/busybox/busybox_1.37.0.bb        |  1 +
 2 files changed, 53 insertions(+)
meta/recipes-core/busybox/busybox/0001-hwclock-Check-for-SYS_settimeofday-before-calling-sy.patch new file +52 -0
new file mode 100644
index 0000000000000000000000000000000000000000..11ef2b6824b98325642dd13ad74f58126df51f59
@@ -0,0 +1,52 @@
+From 4e1eafc6e0de3e58cac9f62e57b552eddb50ca8e Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Sun, 7 Mar 2021 17:30:24 -0800
+Subject: [PATCH] hwclock: Check for SYS_settimeofday before calling syscall
+
+Some newer architectures e.g. RISCV32 have 64bit time_t from get go and
+thusly do not have gettimeofday_time64/settimeofday_time64 implemented
+therefore check for SYS_settimeofday definition before making the
+syscall. Fixes build for riscv32 and it will bail out at runtime.
+
+This issue has been discussed on the musl mailing list, and
+the musl developers' opinion is that Busybox is wrong:
+
+https://www.openwall.com/lists/musl/2024/03/03/2
+https://www.openwall.com/lists/musl/2024/04/07/2
+
+The correct fix isn't clear, and in the mean time, the patch
+turns the build issue into a runtime error only on the problematic
+architecture (riscv32), which seems like a reasonable trade-off
+
+Upstream-Status: Submitted [http://lists.busybox.net/pipermail/busybox/2021-March/088583.html]]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ util-linux/hwclock.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
+index c3fd0eb57..dea9c9a55 100644
+--- a/util-linux/hwclock.c
++++ b/util-linux/hwclock.c
+@@ -132,6 +132,7 @@ static void show_clock(const char **pp_rtcname, int utc)
+ 
+ static void set_kernel_tz(const struct timezone *tz)
+ {
++	int ret = 1;
+ #if LIBC_IS_MUSL
+ 	/* musl libc does not pass tz argument to syscall
+ 	 * because "it's deprecated by POSIX, therefore it's fine
+@@ -140,9 +141,11 @@ static void set_kernel_tz(const struct timezone *tz)
+ #if !defined(SYS_settimeofday) && defined(SYS_settimeofday_time32)
+ # define SYS_settimeofday SYS_settimeofday_time32
+ #endif
+-	int ret = syscall(SYS_settimeofday, NULL, tz);
++#if defined(SYS_settimeofday)
++	ret = syscall(SYS_settimeofday, NULL, tz);
++#endif
+ #else
+-	int ret = settimeofday(NULL, tz);
++	ret = settimeofday(NULL, tz);
+ #endif
+ 	if (ret)
+ 		bb_simple_perror_msg_and_die("settimeofday");
meta/recipes-core/busybox/busybox_1.37.0.bb +1 -0
index 85f22ada5338c419907666a7616cc19efe7565ab..9f7ded3354d91868900eab496708c41144cc3f1b 100644
@@ -54,6 +54,7 @@ SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
            file://0002-start-stop-daemon-fix-tests.patch \
            file://0003-start-stop-false.patch \
            file://0001-archival-disallow-path-traversals-CVE-2023-39810.patch \
+           file://0001-hwclock-Check-for-SYS_settimeofday-before-calling-sy.patch \
            "
 SRC_URI:append:libc-musl = " file://musl.cfg"
 SRC_URI:append:x86-64 = " file://sha_accel.cfg"
Signature · 1 line
2.49.0
author
#44 lore raw

PATCH v2 27/28 systemd-boot: Use gcc on musl/arm

In reply to Khem Raj

clang does not support -mgeneral-regs-only option for arm

---
 meta/recipes-core/systemd/systemd-boot_257.5.bb | 3 +++
 1 file changed, 3 insertions(+)
meta/recipes-core/systemd/systemd-boot_257.5.bb +3 -0
index 151e4a953735b524ed14a5ef5459dd037efdcdaf..f293a2f229374a48e17c574faf23620549ae35ac 100644
@@ -54,6 +54,9 @@ TUNE_CCARGS:remove = "-mfpmath=sse"
 
 CFLAGS:append:libc-musl = " -D__DEFINED_wchar_t"
 
+# arm-poky-linux-musleabi-clang: error: unsupported option '-mgeneral-regs-only' for target 'arm-poky-linux-musleabi'
+TOOLCHAIN:libc-musl:arm = "gcc"
+
 COMPATIBLE_HOST = "(aarch64.*|arm.*|x86_64.*|i.86.*|riscv.*)-linux"
 COMPATIBLE_HOST:x86-x32 = "null"
 
Signature · 1 line
2.49.0
#45 lore raw

Re: [OE-core] [PATCH v2 27/28] systemd-boot: Use gcc on musl/arm

meta/recipes-core/systemd/systemd-boot_257.5.bb TUNE_CCARGS:remove = "-mfpmath=sse" · line 58

Quoted 5 lines · Khem Raj via lists.openembedded.org

clang does not support -mgeneral-regs-only option for arm

meta/recipes-core/systemd/systemd-boot_257.5.bb +2 -0
+# arm-poky-linux-musleabi-clang: error: unsupported option '-mgeneral-regs-only' for target 'arm-poky-linux-musleabi'
+TOOLCHAIN:libc-musl:arm = "gcc"

Why is this specific to musl, does the choice of libc really control whether this option exists in clang?

Ross

author
#46 lore raw

Re: [OE-core] [PATCH v2 27/28] systemd-boot: Use gcc on musl/arm

Quoted 10 lines · Ross Burton

meta/recipes-core/systemd/systemd-boot_257.5.bb TUNE_CCARGS:remove = "-mfpmath=sse" · line 58

Quoted 5 lines · Khem Raj via lists.openembedded.org

clang does not support -mgeneral-regs-only option for arm

meta/recipes-core/systemd/systemd-boot_257.5.bb +2 -0
+# arm-poky-linux-musleabi-clang: error: unsupported option '-mgeneral-regs-only' for target 'arm-poky-linux-musleabi'
+TOOLCHAIN:libc-musl:arm = "gcc"

Why is this specific to musl, does the choice of libc really control whether this option exists in clang?

good question. I will rebuild once more for arm/glibc combo, The option does not exist for arm in clang so glibc version should fail as well. I wanted to keep the scope of these settings as narrow as possible thats why make is libc-musl:arm

Quoted 2 lines

Ross

author
#47 lore raw

Re: [OE-core] [PATCH v2 27/28] systemd-boot: Use gcc on musl/arm

In reply to Ross Burton
Quoted 9 lines · Ross Burton

meta/recipes-core/systemd/systemd-boot_257.5.bb TUNE_CCARGS:remove = "-mfpmath=sse" · line 58

Quoted 5 lines · Khem Raj via lists.openembedded.org

clang does not support -mgeneral-regs-only option for arm

meta/recipes-core/systemd/systemd-boot_257.5.bb +2 -0
+# arm-poky-linux-musleabi-clang: error: unsupported option '-mgeneral-regs-only' for target 'arm-poky-linux-musleabi'
+TOOLCHAIN:libc-musl:arm = "gcc"

Why is this specific to musl, does the choice of libc really control whether this option exists in clang?

This is not musl specific, build with arm/glibc failed with exact same error. I have removed the libc override for v3. Thanks for feedback

Quoted 2 lines

Ross

author
#48 lore raw

PATCH v2 28/28 perf: Do not treat maybe-uninitialized warnings as errors

In reply to Khem Raj

Clang finds more warnings in kernel code, make clang happy to not treat these extra warnings as errors

---
 meta/recipes-kernel/perf/perf.bb | 10 ++++++++++
 1 file changed, 10 insertions(+)
meta/recipes-kernel/perf/perf.bb +10 -0
index d06dd2fa5a2bb9b2982572081ef57e2dbafbd5da..0d19e1bdc222da26a5ad0a1d4964acca437a6692 100644
@@ -81,6 +81,16 @@ LDFLAGS = "-ldl -lutil"
 # avoiding the 'buildpaths' QA warning.
 TARGET_CC_ARCH += "${SELECTED_OPTIMIZATION} ${DEBUG_PREFIX_MAP}"
 
+#| libbpf.c: In function 'find_kernel_btf_id.constprop':
+#| libbpf.c:10009:33: error: 'mod_len' may be used uninitialized [-Werror=maybe-uninitialized]
+#| 10009 |                 if (mod_name && strncmp(mod->name, mod_name, mod_len) != 0)
+#|       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#| libbpf.c:9979:21: note: 'mod_len' was declared here
+#|  9979 |         int ret, i, mod_len;
+#|       |                     ^~~~~~~
+#| cc1: all warnings being treated as errors
+TARGET_CC_ARCH:append:toolchain-clang:arm = " -fno-error=maybe-uninitialized"
+
 EXTRA_OEMAKE = '\
     V=1 \
     VF=1 \
Signature · 1 line
2.49.0
#49 lore raw

Re: [OE-core] [PATCH v2 28/28] perf: Do not treat maybe-uninitialized warnings as errors

I just sent a patch to linux-yocto to silence this at root.

Ross

Quoted 44 lines · Khem Raj via lists.openembedded.org

Clang finds more warnings in kernel code, make clang happy to not treat these extra warnings as errors

---
meta/recipes-kernel/perf/perf.bb | 10 ++++++++++

1 file changed, 10 insertions(+)
meta/recipes-kernel/perf/perf.bb +0 -0
index d06dd2fa5a2bb9b2982572081ef57e2dbafbd5da..0d19e1bdc222da26a5ad0a1d4964acca437a6692 100644
@@ -81,6 +81,16 @@ LDFLAGS = "-ldl -lutil"
 # avoiding the 'buildpaths' QA warning.

TARGET_CC_ARCH += "${SELECTED_OPTIMIZATION} ${DEBUG_PREFIX_MAP}"

meta/recipes-kernel/perf/perf.bb +10 -0
+#| libbpf.c: In function 'find_kernel_btf_id.constprop':
+#| libbpf.c:10009:33: error: 'mod_len' may be used uninitialized [-Werror=maybe-uninitialized]
+#| 10009 |                 if (mod_name && strncmp(mod->name, mod_name, mod_len) != 0)
+#|       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#| libbpf.c:9979:21: note: 'mod_len' was declared here
+#|  9979 |         int ret, i, mod_len;
+#|       |                     ^~~~~~~
+#| cc1: all warnings being treated as errors
+TARGET_CC_ARCH:append:toolchain-clang:arm = " -fno-error=maybe-uninitialized"
+
EXTRA_OEMAKE = '\
    V=1 \
    VF=1 \
Signature · 10 lines
2.49.0


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#216996): https://lists.openembedded.org/g/openembedded-core/message/216996
Mute This Topic: https://lists.openembedded.org/mt/113225040/6875888
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
author
#50 lore raw

Re: [OE-core] [PATCH v2 28/28] perf: Do not treat maybe-uninitialized warnings as errors

Quoted 3 lines · Ross Burton

I just sent a patch to linux-yocto to silence this at root.

Thanks, we need to send a revert for this to OE-core as well once the linux-yocto change is merged with link to it.

Quoted 47 lines

Ross

Quoted 44 lines · Khem Raj via lists.openembedded.org

Clang finds more warnings in kernel code, make clang happy to not treat these extra warnings as errors

---
meta/recipes-kernel/perf/perf.bb | 10 ++++++++++

1 file changed, 10 insertions(+)
meta/recipes-kernel/perf/perf.bb +0 -0
index d06dd2fa5a2bb9b2982572081ef57e2dbafbd5da..0d19e1bdc222da26a5ad0a1d4964acca437a6692 100644
@@ -81,6 +81,16 @@ LDFLAGS = "-ldl -lutil"
 # avoiding the 'buildpaths' QA warning.

TARGET_CC_ARCH += "${SELECTED_OPTIMIZATION} ${DEBUG_PREFIX_MAP}"

meta/recipes-kernel/perf/perf.bb +10 -0
+#| libbpf.c: In function 'find_kernel_btf_id.constprop':
+#| libbpf.c:10009:33: error: 'mod_len' may be used uninitialized [-Werror=maybe-uninitialized]
+#| 10009 |                 if (mod_name && strncmp(mod->name, mod_name, mod_len) != 0)
+#|       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#| libbpf.c:9979:21: note: 'mod_len' was declared here
+#|  9979 |         int ret, i, mod_len;
+#|       |                     ^~~~~~~
+#| cc1: all warnings being treated as errors
+TARGET_CC_ARCH:append:toolchain-clang:arm = " -fno-error=maybe-uninitialized"
+
EXTRA_OEMAKE = '\
    V=1 \
    VF=1 \

--
2.49.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#216996): https://lists.openembedded.org/g/openembedded-core/message/216996
Mute This Topic: https://lists.openembedded.org/mt/113225040/6875888
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-