public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kbuild: clang: Support building UM with SUBARCH=i386
@ 2025-03-03 21:52 Kees Cook
  2025-03-03 22:29 ` Thomas Weißschuh
  0 siblings, 1 reply; 7+ messages in thread
From: Kees Cook @ 2025-03-03 21:52 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Kees Cook, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Masahiro Yamada, Nicolas Schier, llvm, linux-kbuild, David Gow,
	linux-kernel, linux-hardening

The UM builds distinguish i386 from x86_64 via SUBARCH, but we don't
support building i386 directly with Clang. To make SUBARCH work for
i386 UM, we need to explicitly test for it.

This lets me run i386 KUnit tests with Clang:

$ ./tools/testing/kunit/kunit.py run \
	--make_options LLVM=1 \
	--make_options SUBARCH=i386
...

Fixes: c7500c1b53bf ("um: Allow builds with Clang")
Signed-off-by: Kees Cook <kees@kernel.org>
---
I could not find a cleaner way to do this without hardcoding a test
for i386 UM. Does anyone see a more sane way to accomplish this? The
comment above the CLANG_TARGET_FLAGS seems like it can't be done with
UM's Makefile...

Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Bill Wendling <morbo@google.com>
Cc: Justin Stitt <justinstitt@google.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Nicolas Schier <nicolas@fjasle.eu>
Cc: llvm@lists.linux.dev
Cc: linux-kbuild@vger.kernel.org
---
 scripts/Makefile.clang | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang
index 2435efae67f5..fa6f9a9be4ac 100644
--- a/scripts/Makefile.clang
+++ b/scripts/Makefile.clang
@@ -12,8 +12,12 @@ CLANG_TARGET_FLAGS_riscv	:= riscv64-linux-gnu
 CLANG_TARGET_FLAGS_s390		:= s390x-linux-gnu
 CLANG_TARGET_FLAGS_sparc	:= sparc64-linux-gnu
 CLANG_TARGET_FLAGS_x86		:= x86_64-linux-gnu
+ifeq ($(SRCARCH):$(SUBARCH),um:i386)
+CLANG_TARGET_FLAGS		:= i386-linux-gnu
+else
 CLANG_TARGET_FLAGS_um		:= $(CLANG_TARGET_FLAGS_$(SUBARCH))
 CLANG_TARGET_FLAGS		:= $(CLANG_TARGET_FLAGS_$(SRCARCH))
+endif
 
 ifeq ($(CLANG_TARGET_FLAGS),)
 $(error add '--target=' option to scripts/Makefile.clang)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-03-06  6:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-03 21:52 [PATCH] kbuild: clang: Support building UM with SUBARCH=i386 Kees Cook
2025-03-03 22:29 ` Thomas Weißschuh
2025-03-04 10:25   ` Nathan Chancellor
2025-03-04 14:51     ` Thomas Weißschuh
2025-03-04 17:07       ` Kees Cook
2025-03-05 14:45         ` Nathan Chancellor
2025-03-06  6:12           ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox