linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/1] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0
@ 2021-06-10 20:58 Tor Vic
  2021-06-10 21:07 ` Nathan Chancellor
  2021-06-10 22:49 ` Kees Cook
  0 siblings, 2 replies; 7+ messages in thread
From: Tor Vic @ 2021-06-10 20:58 UTC (permalink / raw)
  To: linux-kernel, Nathan Chancellor, ndesaulniers, tglx, mingo
  Cc: clang-built-linux, x86

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

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

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

* Re: [PATCH v2 1/1] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0
  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
  2021-06-10 22:49 ` Kees Cook
  1 sibling, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2021-06-10 21:07 UTC (permalink / raw)
  To: Tor Vic
  Cc: clang-built-linux, x86, linux-kernel, Ingo Molnar,
	Thomas Gleixner, Nick Desaulniers, Kees Cook, Sami Tolvanen

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

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

* Re: [PATCH v2 1/1] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0
  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
@ 2021-06-10 22:49 ` Kees Cook
  2021-06-10 22:58   ` Nick Desaulniers
  1 sibling, 1 reply; 7+ messages in thread
From: Kees Cook @ 2021-06-10 22:49 UTC (permalink / raw)
  To: Nathan Chancellor, ndesaulniers, linux-kernel, tglx, Tor Vic, mingo
  Cc: Kees Cook, x86, clang-built-linux

On Thu, 10 Jun 2021 20:58:06 +0000, 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'?
> 
> [...]

Applied to for-next/clang/features, thanks!

[1/1] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0
      https://git.kernel.org/kees/c/e6c00f0b33ad

-- 
Kees Cook


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

* Re: [PATCH v2 1/1] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0
  2021-06-10 22:49 ` Kees Cook
@ 2021-06-10 22:58   ` Nick Desaulniers
  2021-06-10 23:47     ` Kees Cook
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Desaulniers @ 2021-06-10 22:58 UTC (permalink / raw)
  To: Kees Cook
  Cc: Nathan Chancellor, linux-kernel, tglx, Tor Vic, mingo, x86,
	clang-built-linux

On Thu, Jun 10, 2021 at 3:50 PM Kees Cook <keescook@chromium.org> wrote:
>
> On Thu, 10 Jun 2021 20:58:06 +0000, 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'?
> >
> > [...]
>
> Applied to for-next/clang/features, thanks!
>
> [1/1] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0
>       https://git.kernel.org/kees/c/e6c00f0b33ad

Can we get this into 5.13?
-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH v2 1/1] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0
  2021-06-10 22:58   ` Nick Desaulniers
@ 2021-06-10 23:47     ` Kees Cook
  2021-06-10 23:58       ` Nick Desaulniers
  0 siblings, 1 reply; 7+ messages in thread
From: Kees Cook @ 2021-06-10 23:47 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Nathan Chancellor, linux-kernel, tglx, Tor Vic, mingo, x86,
	clang-built-linux

On Thu, Jun 10, 2021 at 03:58:57PM -0700, Nick Desaulniers wrote:
> On Thu, Jun 10, 2021 at 3:50 PM Kees Cook <keescook@chromium.org> wrote:
> >
> > On Thu, 10 Jun 2021 20:58:06 +0000, 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'?
> > >
> > > [...]
> >
> > Applied to for-next/clang/features, thanks!
> >
> > [1/1] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0
> >       https://git.kernel.org/kees/c/e6c00f0b33ad
> 
> Can we get this into 5.13?

What's the ETA on LLVM 13.0? I was going to put this in -next, marked
for stable, but we're about 3 weeks from 5.14 merge window.

-- 
Kees Cook

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

* Re: [PATCH v2 1/1] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0
  2021-06-10 23:47     ` Kees Cook
@ 2021-06-10 23:58       ` Nick Desaulniers
  2021-06-11 18:23         ` Kees Cook
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Desaulniers @ 2021-06-10 23:58 UTC (permalink / raw)
  To: Kees Cook
  Cc: Nathan Chancellor, linux-kernel, tglx, Tor Vic, mingo, x86,
	clang-built-linux

On Thu, Jun 10, 2021 at 4:47 PM Kees Cook <keescook@chromium.org> wrote:
>
> On Thu, Jun 10, 2021 at 03:58:57PM -0700, Nick Desaulniers wrote:
> > On Thu, Jun 10, 2021 at 3:50 PM Kees Cook <keescook@chromium.org> wrote:
> > >
> > > On Thu, 10 Jun 2021 20:58:06 +0000, 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'?
> > > >
> > > > [...]
> > >
> > > Applied to for-next/clang/features, thanks!
> > >
> > > [1/1] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0
> > >       https://git.kernel.org/kees/c/e6c00f0b33ad
> >
> > Can we get this into 5.13?
>
> What's the ETA on LLVM 13.0? I was going to put this in -next, marked
> for stable, but we're about 3 weeks from 5.14 merge window.

Not soon; CI is red over this currently:
mainline:
https://github.com/ClangBuiltLinux/continuous-integration2/runs/2796736763?check_suite_focus=true
https://github.com/ClangBuiltLinux/continuous-integration2/runs/2796736978?check_suite_focus=true
linux-next:
https://github.com/ClangBuiltLinux/continuous-integration2/runs/2791754316?check_suite_focus=true
https://github.com/ClangBuiltLinux/continuous-integration2/runs/2791754426?check_suite_focus=true
https://github.com/ClangBuiltLinux/continuous-integration2/runs/2792796551?check_suite_focus=true
etc
-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH v2 1/1] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0
  2021-06-10 23:58       ` Nick Desaulniers
@ 2021-06-11 18:23         ` Kees Cook
  0 siblings, 0 replies; 7+ messages in thread
From: Kees Cook @ 2021-06-11 18:23 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Nathan Chancellor, linux-kernel, tglx, Tor Vic, mingo, x86,
	clang-built-linux

On Thu, Jun 10, 2021 at 04:58:24PM -0700, Nick Desaulniers wrote:
> On Thu, Jun 10, 2021 at 4:47 PM Kees Cook <keescook@chromium.org> wrote:
> >
> > On Thu, Jun 10, 2021 at 03:58:57PM -0700, Nick Desaulniers wrote:
> > > On Thu, Jun 10, 2021 at 3:50 PM Kees Cook <keescook@chromium.org> wrote:
> > > >
> > > > On Thu, 10 Jun 2021 20:58:06 +0000, 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'?
> > > > >
> > > > > [...]
> > > >
> > > > Applied to for-next/clang/features, thanks!
> > > >
> > > > [1/1] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0
> > > >       https://git.kernel.org/kees/c/e6c00f0b33ad
> > >
> > > Can we get this into 5.13?
> >
> > What's the ETA on LLVM 13.0? I was going to put this in -next, marked
> > for stable, but we're about 3 weeks from 5.14 merge window.
> 
> Not soon; CI is red over this currently:
> mainline:
> https://github.com/ClangBuiltLinux/continuous-integration2/runs/2796736763?check_suite_focus=true
> https://github.com/ClangBuiltLinux/continuous-integration2/runs/2796736978?check_suite_focus=true
> linux-next:
> https://github.com/ClangBuiltLinux/continuous-integration2/runs/2791754316?check_suite_focus=true
> https://github.com/ClangBuiltLinux/continuous-integration2/runs/2791754426?check_suite_focus=true
> https://github.com/ClangBuiltLinux/continuous-integration2/runs/2792796551?check_suite_focus=true
> etc

Fair enough. Pull request sent to Linus...

-- 
Kees Cook

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

end of thread, other threads:[~2021-06-11 18:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).