From 91bb236194162472d1e19b0cbc215e25eddc11d0 Mon Sep 17 00:00:00 2001 From: Dmitrii Sharshakov Date: Sat, 8 Nov 2025 21:48:46 +0100 Subject: [PATCH 1/2] 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 Closes: https://lore.kernel.org/u-boot/20251106221355.GZ6688@bill-the-cat/ Signed-off-by: Dmitrii Sharshakov --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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),) From 2ed758fa7ef9e434c586ff5e12eeca7dfae7efb2 Mon Sep 17 00:00:00 2001 From: Dmitrii Sharshakov Date: Sat, 8 Nov 2025 21:48:47 +0100 Subject: [PATCH 2/2] arch: arm: fix AArch64 builds with Clang 21+ Clang is strict with respect to unknown options. Therefore, only enable AArch32-specific options when CONFIG_ARM64 is not set. Signed-off-by: Dmitrii Sharshakov --- arch/arm/config.mk | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm/config.mk b/arch/arm/config.mk index ba7dd99672a..73fddd50bd7 100644 --- a/arch/arm/config.mk +++ b/arch/arm/config.mk @@ -30,18 +30,19 @@ PLATFORM_RELFLAGS += $(call cc-option,-mgeneral-regs-only) endif # LLVM support -LLVM_RELFLAGS := $(call cc-option,-mllvm,) \ - $(call cc-option,-mno-movt,) -PLATFORM_RELFLAGS += $(LLVM_RELFLAGS) - +LLVM_RELFLAGS := $(call cc-option,-mllvm,) PLATFORM_CPPFLAGS += -D__ARM__ ifdef CONFIG_ARM64 PLATFORM_ELFFLAGS += -B aarch64 -O elf64-littleaarch64 else PLATFORM_ELFFLAGS += -B arm -O elf32-littlearm +# no-movt is only available when targeting AArch32 +LLVM_RELFLAGS += $(call cc-option,-mno-movt,) endif +PLATFORM_RELFLAGS += $(LLVM_RELFLAGS) + # Choose between ARM/Thumb instruction sets ifeq ($(CONFIG_$(PHASE_)SYS_THUMB_BUILD),y) AFLAGS_IMPLICIT_IT := $(call as-option,-Wa$(comma)-mimplicit-it=always) @@ -50,7 +51,7 @@ PF_CPPFLAGS_ARM := $(AFLAGS_IMPLICIT_IT) \ $(call cc-option,-marm,)\ $(call cc-option,-mno-thumb-interwork,)\ ) -else +else ifneq ($(CONFIG_ARM64),y) PF_CPPFLAGS_ARM := $(call cc-option,-marm,) \ $(call cc-option,-mno-thumb-interwork,) endif