summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitrii Sharshakov <[email protected]>2025-11-08 21:48:46 +0100
committerTom Rini <[email protected]>2025-11-18 15:52:11 -0600
commit91bb236194162472d1e19b0cbc215e25eddc11d0 (patch)
tree7eba76c05cb31219ed0461cb9d8109f07197fd66
parent928af44314a1a086e946ef3c0901d40bdb3e19a9 (diff)
build: fix prefix for Clang when CROSS_COMPILE is an absolute path
Clang cross-compilation worked when cross binutils were available in PATH. However, when binutils are not in the PATH clang failed to discover the assembler, falling back to host one. Make --prefix always absolute, Clang supports this and will search for e.g. $(prefix)-as for assembler. This makes sure user does not have to add cross binutils to PATH for Clang build. Fixes build for these examples (with qemu_arm(64)_defconfig): make CC=clang-21 CROSS_COMPILE=/.../bin/arm-none-eabi- make CC=clang-20 CROSS_COMPILE=/.../bin/aarch64-linux-gnu- Also validated for the case when provided with cross toolchain on PATH: PATH=/.../bin:$PATH make CC=clang-21 CROSS_COMPILE=arm-none-eabi- -j20 This patch does not affect GCC builds, and they have _not_ been validated against regressions. Reported-by: Tom Rini <[email protected]> Closes: https://lore.kernel.org/u-boot/20251106221355.GZ6688@bill-the-cat/ Signed-off-by: Dmitrii Sharshakov <[email protected]>
-rw-r--r--Makefile2
1 files changed, 1 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 62a24e38283..cca82a01843 100644
--- a/Makefile
+++ b/Makefile
@@ -600,7 +600,7 @@ ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
ifneq ($(CROSS_COMPILE),)
CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
-CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)
+CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE:%-=%))-
GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
endif
ifneq ($(GCC_TOOLCHAIN),)