x86: Enable clang LTO for 32-bit as well
PATCH 1/1 x86: Enable clang LTO for 32-bit as well
Commit b33fff07e3e3 ("x86, build: allow LTO to be selected") enabled support for LTO for x86_64 but 32-bit works fine as well.
I tested the following config combinations:
* i386_defconfig + CONFIG_LTO_CLANG_FULL=y
* i386_defconfig + CONFIG_LTO_CLANG_THIN=y
* ARCH=i386 allmodconfig + CONFIG_LTO_CLANG_THIN=y
with LLVM 11.1.0, 12.0.0, and 13.0.0 from git without any build failures. The defconfigs boot in QEMU with no new warnings.
--- arch/x86/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/Kconfig +2 -2
@@ -97,8 +97,8 @@ config X86 select ARCH_SUPPORTS_DEBUG_PAGEALLOC select ARCH_SUPPORTS_NUMA_BALANCING if X86_64 select ARCH_SUPPORTS_KMAP_LOCAL_FORCE_MAP if NR_CPUS <= 4096 - select ARCH_SUPPORTS_LTO_CLANG if X86_64 - select ARCH_SUPPORTS_LTO_CLANG_THIN if X86_64 + select ARCH_SUPPORTS_LTO_CLANG + select ARCH_SUPPORTS_LTO_CLANG_THIN select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_QUEUED_RWLOCKS select ARCH_USE_QUEUED_SPINLOCKS
base-commit: d8201efe75e13146ebde433745c7920e15593baf
Signature · 1 line
2.31.1.362.g311531c9de
Quoted 11 lines · Nathan Chancellor
Commit
b33fff07e3e3("x86, build: allow LTO to be selected") enabled support for LTO forx86_64but 32-bit works fine as well.I tested the following config combinations:
*
i386_defconfig+CONFIG_LTO_CLANG_FULL=y*
i386_defconfig+CONFIG_LTO_CLANG_THIN=y* ARCH=i386 allmodconfig +
CONFIG_LTO_CLANG_THIN=y
For allmodconfigHAS_LTO_CLANG cannot be selected unless
FTRACEGCOV_KERNEL
are disabled.
I was able to run through similar tests, though I only did so for ToT LLVM.
I additionally tried full LTO allmodconfig. Full LTO allmodconfig can be tested by disabling CONFIG_COMPILE_TEST (in addition to the above), though I hit https://github.com/ClangBuiltLinux/linux/issues/1215 (the xfs tests aren't building under LTO). I think this change though is fine, and enables another avenue to help us debug that failure.
Quoted 29 lines
with LLVM 11.1.0, 12.0.0, and 13.0.0 from git without any build failures. The defconfigs boot in QEMU with no new warnings.
Signed-off-by Nathan Chancellor <[email protected]>--- arch/x86/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/x86/Kconfig +2
-2@@ -97,8 +97,8 @@ config X86 select ARCH_SUPPORTS_DEBUG_PAGEALLOC select ARCH_SUPPORTS_NUMA_BALANCING if X86_64 select ARCH_SUPPORTS_KMAP_LOCAL_FORCE_MAP if NR_CPUS <= 4096 - select ARCH_SUPPORTS_LTO_CLANG if X86_64 - select ARCH_SUPPORTS_LTO_CLANG_THIN if X86_64 + select ARCH_SUPPORTS_LTO_CLANG + select ARCH_SUPPORTS_LTO_CLANG_THIN select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_QUEUED_RWLOCKS select ARCH_USE_QUEUED_SPINLOCKSbase-commit:
d8201efe75e13146ebde433745c7920e15593baf--
2.31.1.362.g311531c9de
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 21 lines · Nick Desaulniers
Quoted 11 lines · Nathan Chancellor
Commit
b33fff07e3e3("x86, build: allow LTO to be selected") enabled support for LTO forx86_64but 32-bit works fine as well.I tested the following config combinations:
*
i386_defconfig+CONFIG_LTO_CLANG_FULL=y*
i386_defconfig+CONFIG_LTO_CLANG_THIN=y* ARCH=i386 allmodconfig +
CONFIG_LTO_CLANG_THIN=yFor allmodconfig
HAS_LTO_CLANGcannot be selected unless
FTRACEGCOV_KERNEL
are disabled.I was able to run through similar tests, though I only did so for ToT LLVM.
Quoted 8 lines
Reviewed-by Nick Desaulniers <[email protected]>Tested-by Nick Desaulniers <[email protected]>I additionally tried full LTO allmodconfig. Full LTO allmodconfig can be tested by disabling
CONFIG_COMPILE_TEST(in addition to the above), though I hit https://github.com/ClangBuiltLinux/linux/issues/1215 (the xfs tests aren't building under LTO). I think this change though is fine, and enables another avenue to help us debug that failure.
Awesome; thank you both! I'll collect this for -next once -rc2 is released.
Signature · 1 line
Kees Cook
Kees Cook
AppliedQuoted 8 lines · Nathan Chancellor
Commit
b33fff07e3e3("x86, build: allow LTO to be selected") enabled support for LTO forx86_64but 32-bit works fine as well.I tested the following config combinations:
*
i386_defconfig+CONFIG_LTO_CLANG_FULL=y[...]
Applied to for-next/clang/features, thanks!
[1/1] x86: Enable clang LTO for 32-bit as well
https://git.kernel.org/kees/c/5083971eb1a8
Signature · 1 line
Kees Cook