Skip to content

Commit b33fff0

Browse files
samitolvanenkees
authored andcommitted
x86, build: allow LTO to be selected
Pass code model and stack alignment to the linker as these are not stored in LLVM bitcode, and allow CONFIG_LTO_CLANG* to be enabled. Signed-off-by: Sami Tolvanen <[email protected]> Reviewed-by: Kees Cook <[email protected]>
1 parent d2dcd3e commit b33fff0

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

arch/x86/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ config X86
9595
select ARCH_SUPPORTS_DEBUG_PAGEALLOC
9696
select ARCH_SUPPORTS_NUMA_BALANCING if X86_64
9797
select ARCH_SUPPORTS_KMAP_LOCAL_FORCE_MAP if NR_CPUS <= 4096
98+
select ARCH_SUPPORTS_LTO_CLANG if X86_64
99+
select ARCH_SUPPORTS_LTO_CLANG_THIN if X86_64
98100
select ARCH_USE_BUILTIN_BSWAP
99101
select ARCH_USE_QUEUED_RWLOCKS
100102
select ARCH_USE_QUEUED_SPINLOCKS

arch/x86/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
166166
KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
167167
endif
168168

169+
ifdef CONFIG_LTO_CLANG
170+
KBUILD_LDFLAGS += -plugin-opt=-code-model=kernel \
171+
-plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
172+
endif
173+
169174
# Workaround for a gcc prelease that unfortunately was shipped in a suse release
170175
KBUILD_CFLAGS += -Wno-sign-compare
171176
#

0 commit comments

Comments
 (0)