public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Nathan Chancellor <nathan@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] x86/boot/compressed: Move CLANG_FLAGS to beginning of KBUILD_CFLAGS
Date: Wed, 22 Dec 2021 15:17:12 +0100	[thread overview]
Message-ID: <YcMzaBPBF+0rUeag@zn.tnic> (raw)
In-Reply-To: <20211222005245.3081136-1-nathan@kernel.org>

On Tue, Dec 21, 2021 at 05:52:45PM -0700, Nathan Chancellor wrote:
> When cross compiling i386_defconfig on an arm64 host with clang, there
> are a few instances of '-Waddress-of-packed-member' and
> '-Wgnu-variable-sized-type-not-at-end' in arch/x86/boot/compressed/,
> which should both be disabled with the cc-disable-warning calls in that
> directory's Makefile, which indicates that cc-disable-warning is failing
> at the point of testing these flags.
> 
> The cc-disable-warning calls fail because at the point that the flags
> are tested, KBUILD_CFLAGS has '-march=i386' without $(CLANG_FLAGS),
> which has the '--target=' flag to tell clang what architecture it is
> targeting. Without the '--target=' flag, the host architecture (arm64)
> is used and i386 is not a valid value for '-march=' in that case. This
> error can be seen by adding some logging to try-run:
> 
> clang-14: error: the clang compiler does not support '-march=i386'
> 
> Invoking the compiler has to succeed prior to calling cc-option or
> cc-disable-warning in order to accurately test whether or not the flag
> is supported; if it doesn't, the requested flag can never be added to
> the compiler flags. Move $(CLANG_FLAGS) to the beginning of KBUILD_FLAGS
> so that any new flags that might be added in the future can be
> accurately tested.
> 
> Fixes: d5cbd80e302d ("x86/boot: Add $(CLANG_FLAGS) to compressed KBUILD_CFLAGS")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  arch/x86/boot/compressed/Makefile | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
> index 431bf7f846c3..169186dba1d7 100644
> --- a/arch/x86/boot/compressed/Makefile
> +++ b/arch/x86/boot/compressed/Makefile
> @@ -28,7 +28,7 @@ KCOV_INSTRUMENT		:= n
>  targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
>  	vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4 vmlinux.bin.zst
>  
> -KBUILD_CFLAGS := -m$(BITS) -O2
> +KBUILD_CFLAGS := -m$(BITS) -O2 $(CLANG_FLAGS)

I don't mind but this makes the placement of that variable magical so it
needs a comment above it that it cannot be moved around freely and why
that is the case.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

      reply	other threads:[~2021-12-22 14:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-22  0:52 [PATCH] x86/boot/compressed: Move CLANG_FLAGS to beginning of KBUILD_CFLAGS Nathan Chancellor
2021-12-22 14:17 ` Borislav Petkov [this message]

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=YcMzaBPBF+0rUeag@zn.tnic \
    --to=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mingo@redhat.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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