barebox-tools: Fix linking the target tools with clang
PATCH 1/1 barebox-tools: Fix linking the target tools with clang
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.
--- meta/recipes-bsp/barebox/barebox-tools.bb | 3 +++ 1 file changed, 3 insertions(+)
meta/recipes-bsp/barebox/barebox-tools.bb +3 -0
@@ -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}"