linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: Enable clang LTO for 32-bit as well
@ 2021-04-29 23:26 Nathan Chancellor
  2021-04-30 20:58 ` Nick Desaulniers
  2021-06-10 17:11 ` Kees Cook
  0 siblings, 2 replies; 4+ messages in thread
From: Nathan Chancellor @ 2021-04-29 23:26 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
	Sami Tolvanen, Kees Cook
  Cc: H. Peter Anvin, Nick Desaulniers, linux-kernel,
	clang-built-linux, Nathan Chancellor

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.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/x86/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 0fc82237414d..d8a919d9535e 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -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
-- 
2.31.1.362.g311531c9de


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

* Re: [PATCH] x86: Enable clang LTO for 32-bit as well
  2021-04-29 23:26 [PATCH] x86: Enable clang LTO for 32-bit as well Nathan Chancellor
@ 2021-04-30 20:58 ` Nick Desaulniers
  2021-04-30 23:04   ` Kees Cook
  2021-06-10 17:11 ` Kees Cook
  1 sibling, 1 reply; 4+ messages in thread
From: Nick Desaulniers @ 2021-04-30 20:58 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Sami Tolvanen, Kees Cook, H. Peter Anvin, LKML,
	clang-built-linux

On Thu, Apr 29, 2021 at 4:26 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> 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

For allmodconfig
HAS_LTO_CLANG cannot be selected unless
FTRACE
GCOV_KERNEL
are disabled.

I was able to run through similar tests, though I only did so for ToT LLVM.

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>

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.

>
> 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 <nathan@kernel.org>
> ---
>  arch/x86/Kconfig | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 0fc82237414d..d8a919d9535e 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -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
> --
> 2.31.1.362.g311531c9de
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] x86: Enable clang LTO for 32-bit as well
  2021-04-30 20:58 ` Nick Desaulniers
@ 2021-04-30 23:04   ` Kees Cook
  0 siblings, 0 replies; 4+ messages in thread
From: Kees Cook @ 2021-04-30 23:04 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Nathan Chancellor, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Sami Tolvanen, H. Peter Anvin, LKML, clang-built-linux

On Fri, Apr 30, 2021 at 01:58:57PM -0700, Nick Desaulniers wrote:
> On Thu, Apr 29, 2021 at 4:26 PM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > 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
> 
> For allmodconfig
> HAS_LTO_CLANG cannot be selected unless
> FTRACE
> GCOV_KERNEL
> are disabled.
> 
> I was able to run through similar tests, though I only did so for ToT LLVM.
> 
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> Tested-by: Nick Desaulniers <ndesaulniers@google.com>
> 
> 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.

-- 
Kees Cook

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

* Re: [PATCH] x86: Enable clang LTO for 32-bit as well
  2021-04-29 23:26 [PATCH] x86: Enable clang LTO for 32-bit as well Nathan Chancellor
  2021-04-30 20:58 ` Nick Desaulniers
@ 2021-06-10 17:11 ` Kees Cook
  1 sibling, 0 replies; 4+ messages in thread
From: Kees Cook @ 2021-06-10 17:11 UTC (permalink / raw)
  To: Sami Tolvanen, Thomas Gleixner, Nathan Chancellor, x86,
	Borislav Petkov, Ingo Molnar
  Cc: Kees Cook, Nick Desaulniers, linux-kernel, clang-built-linux,
	H. Peter Anvin

On Thu, 29 Apr 2021 16:26:12 -0700, Nathan Chancellor wrote:
> 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
> 
> [...]

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

-- 
Kees Cook


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

end of thread, other threads:[~2021-06-10 17:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29 23:26 [PATCH] x86: Enable clang LTO for 32-bit as well Nathan Chancellor
2021-04-30 20:58 ` Nick Desaulniers
2021-04-30 23:04   ` Kees Cook
2021-06-10 17:11 ` 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).