[PATCH 2/3] Makefile: clang: fix triplet computation for ARM

Ahmad Fatoum a.fatoum at barebox.org
Wed Jun 10 08:37:26 PDT 2026


The code that has been imported here is wrong, because it doesn't
account for the fact that SRCARCH in barebox is never arm64, even for
CONFIG_ARM64. This is not trivially fixable directly as this file is
included before CONFIG_ options are available, so we can't actually know
whether it's arm64 or arm32...

Fix this by requiring ARCH=arm64 to be used for 64-bit builds with clang.
At some point in the future, we can enforce this for everyone.

Note that clang building is currently only supported and tested for
sandbox, but with this change, everyone can see the errors and
collaboration on enabling clang support becomes feasible.

Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
 arch/arm/Kconfig       | 2 +-
 scripts/Makefile.clang | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 63877c965fad..fe4fd3f47178 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -42,7 +42,7 @@ config ARM64
 	select ARCH_HAS_BAREBOX_MEMORY_OFFSET
 
 config ARM64_STRICT_BUILD_ARCH
-	bool
+	def_bool CC_IS_CLANG
 	depends on ARM64
 	help
 	  When selected, ARCH=arm64 is required for 64-bit builds and ARCH=arm
diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang
index e93ffb77aa10..fca1b8eee985 100644
--- a/scripts/Makefile.clang
+++ b/scripts/Makefile.clang
@@ -2,8 +2,9 @@
 # Individual arch/{arch}/Makefiles should use -EL/-EB to set intended
 # endianness and -m32/-m64 to set word size based on Kconfigs instead of
 # relying on the target triple.
-CLANG_TARGET_FLAGS_arm		:= arm-linux-gnueabi
-CLANG_TARGET_FLAGS_arm64	:= aarch64-linux-gnu
+CLANG_TARGET_FLAGS-arm		:= arm-linux-gnueabi
+CLANG_TARGET_FLAGS-arm64	:= aarch64-linux-gnu
+CLANG_TARGET_FLAGS_arm		:= $(CLANG_TARGET_FLAGS-$(UTS_MACHINE))
 CLANG_TARGET_FLAGS_mips		:= mipsel-linux-gnu
 CLANG_TARGET_FLAGS_powerpc	:= powerpc64le-linux-gnu
 CLANG_TARGET_FLAGS_riscv	:= riscv64-linux-gnu
-- 
2.47.3




More information about the barebox mailing list