* [PATCH] u-boot: add support for Clang toolchain
@ 2026-08-11 10:56 Harish.Sadineni
2026-08-11 12:13 ` [OE-core] " Quentin Schulz
0 siblings, 1 reply; 4+ messages in thread
From: Harish.Sadineni @ 2026-08-11 10:56 UTC (permalink / raw)
To: openembedded-core; +Cc: ross.burton, Sundeep.Kokkonda
From: Harish Sadineni <Harish.Sadineni@windriver.com>
Fix build issues that occur when the Clang toolchain is selected.
Remove the hard-coded TOOLCHAIN = "gcc" behavior and make the target compiler
selection conditional on TOOLCHAIN. This preserves GCC as the default compiler
while allowing Clang to be selected when TOOLCHAIN = "clang".
YOCTO [#16385]
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/recipes-bsp/u-boot/u-boot.inc | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/meta/recipes-bsp/u-boot/u-boot.inc b/meta/recipes-bsp/u-boot/u-boot.inc
index 00a12f1bb9..2197039dbc 100644
--- a/meta/recipes-bsp/u-boot/u-boot.inc
+++ b/meta/recipes-bsp/u-boot/u-boot.inc
@@ -3,10 +3,6 @@ PROVIDES = "virtual/bootloader"
PACKAGE_ARCH = "${MACHINE_ARCH}"
-# u-boot is best built with gcc
-# https://docs.u-boot-project.org/en/latest/build/clang.html
-TOOLCHAIN = "gcc"
-
DEPENDS += "${@bb.utils.contains('UBOOT_ENV_SUFFIX', 'scr', 'u-boot-mkimage-native', '', d)}"
DEPENDS += "${@ 'u-boot-mkenvimage-native' if bb.utils.to_boolean(d.getVar('UBOOT_INITIAL_ENV_BINARY')) else ''}"
@@ -15,7 +11,7 @@ inherit uboot-config uboot-extlinux-config uboot-sign deploy python3native
DEPENDS += "swig-native"
EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} V=1'
-EXTRA_OEMAKE += 'CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS} ${DEBUG_PREFIX_MAP}"'
+EXTRA_OEMAKE += 'CC="${TARGET_PREFIX}${@bb.utils.contains('TOOLCHAIN', 'clang', 'clang', 'gcc', d)} ${TOOLCHAIN_OPTIONS} ${DEBUG_PREFIX_MAP}"'
EXTRA_OEMAKE += 'HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}"'
EXTRA_OEMAKE += 'STAGING_INCDIR=${STAGING_INCDIR_NATIVE} STAGING_LIBDIR=${STAGING_LIBDIR_NATIVE}'
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [OE-core] [PATCH] u-boot: add support for Clang toolchain
2026-08-11 10:56 [PATCH] u-boot: add support for Clang toolchain Harish.Sadineni
@ 2026-08-11 12:13 ` Quentin Schulz
2026-08-11 12:21 ` Ross Burton
0 siblings, 1 reply; 4+ messages in thread
From: Quentin Schulz @ 2026-08-11 12:13 UTC (permalink / raw)
To: Harish.Sadineni, openembedded-core; +Cc: ross.burton, Sundeep.Kokkonda
Hi Harish,
On 8/11/26 12:56 PM, Sadineni, Harish via lists.openembedded.org wrote:
> From: Harish Sadineni <Harish.Sadineni@windriver.com>
>
> Fix build issues that occur when the Clang toolchain is selected.
>
> Remove the hard-coded TOOLCHAIN = "gcc" behavior and make the target compiler
> selection conditional on TOOLCHAIN. This preserves GCC as the default compiler
> while allowing Clang to be selected when TOOLCHAIN = "clang".
>
> YOCTO [#16385]
>
> Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
> ---
> meta/recipes-bsp/u-boot/u-boot.inc | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/meta/recipes-bsp/u-boot/u-boot.inc b/meta/recipes-bsp/u-boot/u-boot.inc
> index 00a12f1bb9..2197039dbc 100644
> --- a/meta/recipes-bsp/u-boot/u-boot.inc
> +++ b/meta/recipes-bsp/u-boot/u-boot.inc
> @@ -3,10 +3,6 @@ PROVIDES = "virtual/bootloader"
>
> PACKAGE_ARCH = "${MACHINE_ARCH}"
>
> -# u-boot is best built with gcc
> -# https://docs.u-boot-project.org/en/latest/build/clang.html
> -TOOLCHAIN = "gcc"
> -
> DEPENDS += "${@bb.utils.contains('UBOOT_ENV_SUFFIX', 'scr', 'u-boot-mkimage-native', '', d)}"
> DEPENDS += "${@ 'u-boot-mkenvimage-native' if bb.utils.to_boolean(d.getVar('UBOOT_INITIAL_ENV_BINARY')) else ''}"
>
> @@ -15,7 +11,7 @@ inherit uboot-config uboot-extlinux-config uboot-sign deploy python3native
> DEPENDS += "swig-native"
>
> EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} V=1'
> -EXTRA_OEMAKE += 'CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS} ${DEBUG_PREFIX_MAP}"'
> +EXTRA_OEMAKE += 'CC="${TARGET_PREFIX}${@bb.utils.contains('TOOLCHAIN', 'clang', 'clang', 'gcc', d)} ${TOOLCHAIN_OPTIONS} ${DEBUG_PREFIX_MAP}"'
Why not simply ${TOOLCHAIN}?
Have you checked we can build u-boot-tools, u-boot-tools-native and
nativesdk-u-boot-tools with clang?
Cheers,
Quentin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [OE-core] [PATCH] u-boot: add support for Clang toolchain
2026-08-11 12:13 ` [OE-core] " Quentin Schulz
@ 2026-08-11 12:21 ` Ross Burton
2026-08-11 12:32 ` Quentin Schulz
0 siblings, 1 reply; 4+ messages in thread
From: Ross Burton @ 2026-08-11 12:21 UTC (permalink / raw)
To: Quentin Schulz
Cc: Harish.Sadineni@windriver.com,
openembedded-core@lists.openembedded.org,
Sundeep.Kokkonda@windriver.com
On 11 Aug 2026, at 13:13, Quentin Schulz <quentin.schulz@cherry.de> wrote:
> Why not simply ${TOOLCHAIN}?
That would be a big assumption that TOOLCHAIN is also the name of the binary, which fails for any native builds.
But it would also work here…
> Have you checked we can build u-boot-tools, u-boot-tools-native and nativesdk-u-boot-tools with clang?
FWIW, upstream CI exercises the build with clang so it should work. Our CI will be doing build+boot tests of some clang builds with qemu.
Ross
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [OE-core] [PATCH] u-boot: add support for Clang toolchain
2026-08-11 12:21 ` Ross Burton
@ 2026-08-11 12:32 ` Quentin Schulz
0 siblings, 0 replies; 4+ messages in thread
From: Quentin Schulz @ 2026-08-11 12:32 UTC (permalink / raw)
To: Ross Burton
Cc: Harish.Sadineni@windriver.com,
openembedded-core@lists.openembedded.org,
Sundeep.Kokkonda@windriver.com
Hi Ross,
On 8/11/26 2:21 PM, Ross Burton wrote:
> On 11 Aug 2026, at 13:13, Quentin Schulz <quentin.schulz@cherry.de> wrote:
>> Why not simply ${TOOLCHAIN}?
>
> That would be a big assumption that TOOLCHAIN is also the name of the binary, which fails for any native builds.
>
> But it would also work here…
>
OK. Let's rather not use anti-patterns whenever we can so people aren't
tempted to copy this for recipes that can be native/nativesdk too.
Please ignore my suggestion for TOOLCHAIN.
>> Have you checked we can build u-boot-tools, u-boot-tools-native and nativesdk-u-boot-tools with clang?
>
> FWIW, upstream CI exercises the build with clang so it should work. Our CI will be doing build+boot tests of some clang builds with qemu.
>
From my shell history when I built Rockchip boards in U-Boot with clang
a few months ago I had run:
make CROSS_COMPILE="aarch64-linux-gnu-" O=build/puma HOSTCC=clang
CC=clang puma-rk3399_defconfig
So we need to check HOSTCC is proper and that we really need to add
${TARGET_PREFIX} in front of gcc/clang in CC.
I thought u-boot-tools includes u-boot.inc but it doesn't, so ignore my
previous comment (we should however verify at some point we can build
with either toolchain).
Cheers,
Quentin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-11 12:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11 10:56 [PATCH] u-boot: add support for Clang toolchain Harish.Sadineni
2026-08-11 12:13 ` [OE-core] " Quentin Schulz
2026-08-11 12:21 ` Ross Burton
2026-08-11 12:32 ` Quentin Schulz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox