[PATCH] barebox-tools: Fix linking the target tools with clang
From: Khem Raj <hidden>
Date: 2026-09-04 14:47:48
Subsystem:
the rest · Maintainer:
Linus Torvalds
Makefile.clang hardcodes a generic triple per ARCH
(x86_64-linux-gnu for ARCH=sandbox) and ignores CROSS_COMPILE, unlike the
Linux kbuild. It appends that --target= to KBUILD_CPPFLAGS, which
overrides the triple clang is already targeting. clang then looks for
the GCC installation under a triple that is not staged in the
recipe sysroot, gives up, linker fails:
ld.lld: error: cannot open crtbeginS.o: No such file or directory
ld.lld: error: unable to find library -lgcc
ld.lld: error: cannot open crtendS.o: No such file or directory
The runtime is present, just under ${libdir}/${TARGET_SYS}/<ver>, so this
is purely the wrong triple rather than a missing dependency.
Set CLANG_TARGET_FLAGS on the make command line, which takes precedence
over the makefile's assignment, so CLANG_FLAGS names the real triple.
The variable is unused when building with gcc.
Signed-off-by: Khem Raj <redacted>
---
meta/recipes-bsp/barebox/barebox-tools.bb | 3 +++
1 file changed, 3 insertions(+)
diff --git a/meta/recipes-bsp/barebox/barebox-tools.bb b/meta/recipes-bsp/barebox/barebox-tools.bb
index eb327306d9..054dd97a71 100644
--- a/meta/recipes-bsp/barebox/barebox-tools.bb
+++ b/meta/recipes-bsp/barebox/barebox-tools.bb@@ -19,6 +19,9 @@ EXTRA_OEMAKE = " \ LD='${LD}' \ " +# scripts/Makefile.clang hardcodes a generic triple per ARCH +EXTRA_OEMAKE:append:class-target = " CLANG_TARGET_FLAGS=${TARGET_SYS}" + do_compile:class-target () { export userccflags="${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" export userldflags="${TARGET_LDFLAGS}${TOOLCHAIN_OPTIONS}"