public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Tor Vic <torvic9@mailbox.org>
Cc: clang-built-linux@googlegroups.com, x86@kernel.org,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Kees Cook <keescook@chromium.org>,
	Sami Tolvanen <samitolvanen@google.com>
Subject: Re: [PATCH v2 1/1] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0
Date: Thu, 10 Jun 2021 14:07:30 -0700	[thread overview]
Message-ID: <9b93b016-c19a-21db-2cc4-041810ae722d@kernel.org> (raw)
In-Reply-To: <f2c018ee-5999-741e-58d4-e482d5246067@mailbox.org>

On 6/10/2021 1:58 PM, Tor Vic wrote:
> Since LLVM commit 3787ee4, the '-stack-alignment' flag has been dropped
> [1], leading to the following error message when building a LTO kernel
> with Clang-13 and LLD-13:
> 
>      ld.lld: error: -plugin-opt=-: ld.lld: Unknown command line argument
>      '-stack-alignment=8'.  Try 'ld.lld --help'
>      ld.lld: Did you mean '--stackrealign=8'?
> 
> It also appears that the '-code-model' flag is not necessary anymore
> starting with LLVM-9 [2].
> 
> Drop '-code-model' and make '-stack-alignment' conditional on LLD < 13.0.0.
> 
> These flags were necessary because these flags were not encoded in the
> IR properly, so the link would restart optimizations without them. Now
> there are properly encoded in the IR, and these flags exposing
> implementation details are no longer necessary.
> 
> Changes from v1:
> - based on mainline
> - provide more information about the flags (Nick)
> - use correct tags

Small note for the future, probably not worth resending unless the x86 
folks feel it is necessary but these comments belong between the '---' 
and the stats below so that they do not get included in the final commit 
message.

> Cc: stable@vger.kernel.org
> Link: https://github.com/ClangBuiltLinux/linux/issues/1377
> [1]: https://reviews.llvm.org/D103048
> [2]: https://reviews.llvm.org/D52322
> Signed-off-by: Tor Vic <torvic9@mailbox.org>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>

Thank you for the patch!

> ---
>   arch/x86/Makefile | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index 307529417021..cb5e8d39cac1 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -200,8 +200,9 @@ endif
>   KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
> 
>   ifdef CONFIG_LTO_CLANG
> -KBUILD_LDFLAGS	+= -plugin-opt=-code-model=kernel \
> -		   -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
> +ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
> +KBUILD_LDFLAGS	+= -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
> +endif
>   endif
> 
>   ifdef CONFIG_X86_NEED_RELOCS
> 

Cheers,
Nathan

  reply	other threads:[~2021-06-10 21:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-10 20:58 [PATCH v2 1/1] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0 Tor Vic
2021-06-10 21:07 ` Nathan Chancellor [this message]
2021-06-10 22:49 ` Kees Cook
2021-06-10 22:58   ` Nick Desaulniers
2021-06-10 23:47     ` Kees Cook
2021-06-10 23:58       ` Nick Desaulniers
2021-06-11 18:23         ` 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=9b93b016-c19a-21db-2cc4-041810ae722d@kernel.org \
    --to=nathan@kernel.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=ndesaulniers@google.com \
    --cc=samitolvanen@google.com \
    --cc=tglx@linutronix.de \
    --cc=torvic9@mailbox.org \
    --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