Skip to content

Commit 2398ce8

Browse files
torvic9kees
authored andcommitted
x86, lto: Pass -stack-alignment only 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. [1] https://reviews.llvm.org/D103048 [2] https://reviews.llvm.org/D52322 Cc: [email protected] Link: ClangBuiltLinux#1377 Signed-off-by: Tor Vic <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 06af867 commit 2398ce8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/x86/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ endif
200200
KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
201201

202202
ifdef CONFIG_LTO_CLANG
203-
KBUILD_LDFLAGS += -plugin-opt=-code-model=kernel \
204-
-plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
203+
ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
204+
KBUILD_LDFLAGS += -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
205+
endif
205206
endif
206207

207208
ifdef CONFIG_X86_NEED_RELOCS

0 commit comments

Comments
 (0)