[PATCH 4/4] Makefile: clang: fail non-sandbox LLVM builds early

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Feb 17 02:46:11 PST 2025


The sandbox architecture is the only architecture so far that has been
validated to build to completion with clang and function correctly
afterwards.

Until other architectures follow suit, fail the build gracefully for them.

Note that in Linux, CLANG_TARGET_FLAGS_sandbox expands to
$(CLANG_TARGET_FLAGS_$(SRCARCH)). This requires that we have support for
non-sandbox architectures in the first place. Until we do, just make it
a no-op by setting CLANG_TARGET_FLAGS to the same target triple that's used
by default anyway.

Reported-by: Steffen Trumtrar <s.trumtrar at pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 scripts/Makefile.clang | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang
index 874110ea83ad..7e4dfb8622d3 100644
--- a/scripts/Makefile.clang
+++ b/scripts/Makefile.clang
@@ -1,4 +1,14 @@
 # SPDX-License-Identifier: GPL-2.0-only
+
+CLANG_TARGET_FLAGS_sandbox	:= $(shell $(CC) -print-target-triple)
+CLANG_TARGET_FLAGS		:= $(CLANG_TARGET_FLAGS_$(SRCARCH))
+
+ifeq ($(CLANG_TARGET_FLAGS),)
+$(error add '--target=' option to scripts/Makefile.clang)
+else
+CLANG_FLAGS	+= --target=$(CLANG_TARGET_FLAGS)
+endif
+
 CLANG_FLAGS	+= -Wno-typedef-redefinition
 CLANG_FLAGS	+= -Werror=unknown-warning-option
 CLANG_FLAGS	+= -Werror=ignored-optimization-argument
-- 
2.39.5




More information about the barebox mailing list