Skip to contentSkip to conversation

x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0

PATCH Applied Tor Vic 4 participants 7 messages Jun 10, 2021 – Jun 11, 2021 x86

lore
Share & tools
lore

Tor Vic

author
#0 lore raw

PATCH v2 1/1 x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0

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

[1]: https://reviews.llvm.org/D103048
[2]: https://reviews.llvm.org/D52322

---
 arch/x86/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/Makefile +3 -2
index 307529417021..cb5e8d39cac1 100644
@@ -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
Signature · 1 line
2.32.0
Reviewed-by Tested-by on v2 1/1
#1 lore raw
Quoted 18 lines · Tor Vic

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.

Quoted 4 lines

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.

Quoted 5 lines

[1]: https://reviews.llvm.org/D103048
[2]: https://reviews.llvm.org/D52322

Thank you for the patch!

Quoted 11 lines
---
  arch/x86/Makefile | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/Makefile +0 -0
index 307529417021..cb5e8d39cac1 100644
@@ -200,8 +200,9 @@ endif
  KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)

arch/x86/Makefile endif · line 208

Quoted 10 lines
arch/x86/Makefile +3 -2
 
  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

Applied
#2 lore raw
In reply to Tor Vic
Quoted 9 lines · Tor Vic

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
Signature · 1 line
Kees Cook
#3 lore raw
Quoted 10 lines · Kees Cook
Quoted 8 lines · Tor Vic

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

Quoted 6 lines
Quoted 1 line

[...]

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?

Signature · 2 lines
Thanks,
~Nick Desaulniers
#4 lore raw
Quoted 11 lines · Nick Desaulniers
Quoted 10 lines · Kees Cook
Quoted 8 lines · Tor Vic

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

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

[...]

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.

Signature · 1 line
Kees Cook
#5 lore raw
Quoted 17 lines · Kees Cook
Quoted 15 lines · Nick Desaulniers
Quoted 14 lines · Kees Cook
Quoted 9 lines · Tor Vic

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!

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

[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

Signature · 2 lines
Thanks,
~Nick Desaulniers
#6 lore raw
Quoted 26 lines · Nick Desaulniers
Quoted 17 lines · Kees Cook
Quoted 15 lines · Nick Desaulniers
Quoted 14 lines · Kees Cook
Quoted 9 lines · Tor Vic

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!

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

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

Quoted 9 lines

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

Signature · 1 line
Kees Cook