mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Kees Cook <kees@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>,
	 Nick Desaulniers <ndesaulniers@google.com>,
	Bill Wendling <morbo@google.com>,
	 Justin Stitt <justinstitt@google.com>,
	Masahiro Yamada <masahiroy@kernel.org>,
	 Nicolas Schier <nicolas@fjasle.eu>,
	llvm@lists.linux.dev, linux-kbuild@vger.kernel.org,
	 David Gow <davidgow@google.com>,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] kbuild: clang: Support building UM with SUBARCH=i386
Date: Mon, 3 Mar 2025 23:29:58 +0100	[thread overview]
Message-ID: <05a25510-ab44-4eb1-a878-71e84c8aff0d@t-8ch.de> (raw)
In-Reply-To: <20250303215240.work.379-kees@kernel.org>

On 2025-03-03 13:52:41-0800, Kees Cook wrote:
> 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...

This seems to work for me:

diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang
index 2435efae67f5..8e349bf30fa8 100644
--- a/scripts/Makefile.clang
+++ b/scripts/Makefile.clang
@@ -12,6 +12,7 @@ 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
+CLANG_TARGET_FLAGS_i386                := i386-linux-gnu
 CLANG_TARGET_FLAGS_um          := $(CLANG_TARGET_FLAGS_$(SUBARCH))
 CLANG_TARGET_FLAGS             := $(CLANG_TARGET_FLAGS_$(SRCARCH))

This is also what exists in tools/testing/selftests/lib.mk.
Minus the missing CONFIG_FORTIFY_SOURCE on clang x86_32
and a failure of overflow.DEFINE_FLEX_test (clang 19.1.7).

> 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
> 

  reply	other threads:[~2025-03-03 22:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-03 21:52 Kees Cook
2025-03-03 22:29 ` Thomas Weißschuh [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=05a25510-ab44-4eb1-a878-71e84c8aff0d@t-8ch.de \
    --to=linux@weissschuh.net \
    --cc=davidgow@google.com \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®