llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+
@ 2023-02-15 18:41 Nathan Chancellor
  2023-02-15 18:41 ` [PATCH 1/3] powerpc/boot: Only use '-mabi=elfv2' with CONFIG_PPC64_BOOT_WRAPPER Nathan Chancellor
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Nathan Chancellor @ 2023-02-15 18:41 UTC (permalink / raw)
  To: mpe
  Cc: npiggin, christophe.leroy, erhard_f, nathan, ndesaulniers, trix,
	linuxppc-dev, linux-kernel, llvm, patches

Currently, CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 is not selectable with
ld.lld because of an explicit dependency on GNU ld, due to lack of
testing with LLVM.

Erhard was kind enough to test this option on his hardware with LLVM 15,
which ran without any issues. This should not be too surprising, as
ld.lld does not have support for the ELFv1 ABI, only ELFv2, so it should
have decent support. With this series, big endian kernels can be built
with LLVM=1.

This has seen our basic set of powerpc configurations with clang-15,
clang-16, and clang-17 but I will never be opposed to more testing :)

The first two patches fix a couple of issues I noticed while build
testing and the final patch actually allows the option to be selected.

---
Nathan Chancellor (3):
      powerpc/boot: Only use '-mabi=elfv2' with CONFIG_PPC64_BOOT_WRAPPER
      powerpc: Fix use of '-mabi=elfv2' with clang
      powerpc: Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+

 arch/powerpc/Kconfig       | 3 +--
 arch/powerpc/Makefile      | 4 +---
 arch/powerpc/boot/Makefile | 6 +++---
 3 files changed, 5 insertions(+), 8 deletions(-)
---
base-commit: 5dc4c995db9eb45f6373a956eb1f69460e69e6d4
change-id: 20230118-ppc64-elfv2-llvm-39edac67bf0a

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


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

* [PATCH 1/3] powerpc/boot: Only use '-mabi=elfv2' with CONFIG_PPC64_BOOT_WRAPPER
  2023-02-15 18:41 [PATCH 0/3] Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+ Nathan Chancellor
@ 2023-02-15 18:41 ` Nathan Chancellor
  2023-02-15 18:41 ` [PATCH 2/3] powerpc: Fix use of '-mabi=elfv2' with clang Nathan Chancellor
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2023-02-15 18:41 UTC (permalink / raw)
  To: mpe
  Cc: npiggin, christophe.leroy, erhard_f, nathan, ndesaulniers, trix,
	linuxppc-dev, linux-kernel, llvm, patches

When CONFIG_PPC64_ELF_ABI_V2 is enabled with clang through
CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2, building the powerpc boot wrapper
in 32-bit mode (i.e. with CONFIG_PPC64_BOOT_WRAPPER=n) fails with:

    error: unknown target ABI 'elfv2'

The ABI cannot be changed with '-m32'; GCC silently accepts it but clang
errors out. Only provide '-mabi=elfv2' when CONFIG_PPC64_BOOT_WRAPPER is
enabled, which is the only way '-mabi=elfv2' will be useful.

Tested-by: "Erhard F." <erhard_f@mailbox.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/powerpc/boot/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index d32d95aea5d6..0d4a8e8bdcab 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -44,6 +44,9 @@ BOOTCFLAGS	+= -m64 -mcpu=powerpc64le
 else
 BOOTCFLAGS	+= -m64 -mcpu=powerpc64
 endif
+ifdef CONFIG_PPC64_ELF_ABI_V2
+BOOTCFLAGS	+= $(call cc-option,-mabi=elfv2)
+endif
 else
 BOOTCFLAGS	+= -m32 -mcpu=powerpc
 endif
@@ -55,9 +58,6 @@ BOOTCFLAGS	+= -mbig-endian
 else
 BOOTCFLAGS	+= -mlittle-endian
 endif
-ifdef CONFIG_PPC64_ELF_ABI_V2
-BOOTCFLAGS	+= $(call cc-option,-mabi=elfv2)
-endif
 
 BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCFLAGS) -nostdinc
 

-- 
2.39.2


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

* [PATCH 2/3] powerpc: Fix use of '-mabi=elfv2' with clang
  2023-02-15 18:41 [PATCH 0/3] Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+ Nathan Chancellor
  2023-02-15 18:41 ` [PATCH 1/3] powerpc/boot: Only use '-mabi=elfv2' with CONFIG_PPC64_BOOT_WRAPPER Nathan Chancellor
@ 2023-02-15 18:41 ` Nathan Chancellor
  2023-02-15 18:41 ` [PATCH 3/3] powerpc: Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+ Nathan Chancellor
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2023-02-15 18:41 UTC (permalink / raw)
  To: mpe
  Cc: npiggin, christophe.leroy, erhard_f, nathan, ndesaulniers, trix,
	linuxppc-dev, linux-kernel, llvm, patches

'-mabi=elfv2' is not added to clang's invocations when
CONFIG_PPC64_ELF_ABI_V2 is enabled, resulting in the generation of elfv1
code, as evidenced by the orphan section warnings/errors:

  ld.lld: error: vmlinux.a(arch/powerpc/kernel/prom_init.o):(.opd) is being placed in '.opd'
  ld.lld: error: vmlinux.a(init/main.o):(.opd) is being placed in '.opd'
  ld.lld: error: vmlinux.a(init/version.o):(.opd) is being placed in '.opd'

To resolve this, add '-mabi=elfv2' to CFLAGS with clang. This uncovers
an issue in the 32-bit vDSO:

  error: unknown target ABI 'elfv2'

The ELFv2 ABI cannot be used when building code for a 32-bit target. To
resolve this, just remove the '-mabi' flags from the assembler flags, as
it was only needed for preprocessing (the _CALL_ELF macro) but this was
cleaned up in commit 5b89492c03e5 ("powerpc: Finalise cleanup around ABI
use").

Tested-by: "Erhard F." <erhard_f@mailbox.org
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/powerpc/Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index dc4cbf0a5ca9..3f2dd930e3cd 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -123,14 +123,12 @@ endif
 endif
 
 CFLAGS-$(CONFIG_PPC64)	:= $(call cc-option,-mtraceback=no)
-ifndef CONFIG_CC_IS_CLANG
 ifdef CONFIG_PPC64_ELF_ABI_V2
 CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
-AFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv2)
 else
+ifndef CONFIG_CC_IS_CLANG
 CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv1)
 CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcall-aixdesc)
-AFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv1)
 endif
 endif
 CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))

-- 
2.39.2


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

* [PATCH 3/3] powerpc: Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+
  2023-02-15 18:41 [PATCH 0/3] Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+ Nathan Chancellor
  2023-02-15 18:41 ` [PATCH 1/3] powerpc/boot: Only use '-mabi=elfv2' with CONFIG_PPC64_BOOT_WRAPPER Nathan Chancellor
  2023-02-15 18:41 ` [PATCH 2/3] powerpc: Fix use of '-mabi=elfv2' with clang Nathan Chancellor
@ 2023-02-15 18:41 ` Nathan Chancellor
  2023-02-20  6:11 ` [PATCH 0/3] " Michael Ellerman
  2023-03-22 12:25 ` Michael Ellerman
  4 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2023-02-15 18:41 UTC (permalink / raw)
  To: mpe
  Cc: npiggin, christophe.leroy, erhard_f, nathan, ndesaulniers, trix,
	linuxppc-dev, linux-kernel, llvm, patches

Commit 5017b4594672 ("powerpc/64: Option to build big-endian with ELFv2
ABI") restricted the ELFv2 ABI configuration such that it can only be
selected when linking with ld.bfd, due to lack of testing with LLVM.

ld.lld can link ELFv2 kernels without any issues; in fact, it is the
only ABI that ld.lld supports, as ELFv1 is not supported in ld.lld.

As this has not seen a ton of real world testing yet, be conservative
and only allow this option to be selected with the latest stable release
of LLVM (15.x) and newer.

While in the area, remove 'default n', as it is unnecessary to specify
it explicitly since all boolean/tristate configuration symbols default
to n.

Tested-by: "Erhard F." <erhard_f@mailbox.org
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/powerpc/Kconfig | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index b8c4ac56bddc..f9f13029c98a 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -603,8 +603,7 @@ config PPC64_BIG_ENDIAN_ELF_ABI_V2
 	bool "Build big-endian kernel using ELF ABI V2 (EXPERIMENTAL)"
 	depends on PPC64 && CPU_BIG_ENDIAN
 	depends on CC_HAS_ELFV2
-	depends on LD_IS_BFD && LD_VERSION >= 22400
-	default n
+	depends on LD_VERSION >= 22400 || LLD_VERSION >= 150000
 	help
 	  This builds the kernel image using the "Power Architecture 64-Bit ELF
 	  V2 ABI Specification", which has a reduced stack overhead and faster

-- 
2.39.2


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

* Re: [PATCH 0/3] Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+
  2023-02-15 18:41 [PATCH 0/3] Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+ Nathan Chancellor
                   ` (2 preceding siblings ...)
  2023-02-15 18:41 ` [PATCH 3/3] powerpc: Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+ Nathan Chancellor
@ 2023-02-20  6:11 ` Michael Ellerman
  2023-02-20 15:51   ` Nathan Chancellor
  2023-03-22 12:25 ` Michael Ellerman
  4 siblings, 1 reply; 7+ messages in thread
From: Michael Ellerman @ 2023-02-20  6:11 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: npiggin, christophe.leroy, erhard_f, nathan, ndesaulniers, trix,
	linuxppc-dev, linux-kernel, llvm, patches

Nathan Chancellor <nathan@kernel.org> writes:
> Currently, CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 is not selectable with
> ld.lld because of an explicit dependency on GNU ld, due to lack of
> testing with LLVM.
>
> Erhard was kind enough to test this option on his hardware with LLVM 15,
> which ran without any issues. This should not be too surprising, as
> ld.lld does not have support for the ELFv1 ABI, only ELFv2, so it should
> have decent support. With this series, big endian kernels can be built
> with LLVM=1.
>
> This has seen our basic set of powerpc configurations with clang-15,
> clang-16, and clang-17 but I will never be opposed to more testing :)
>
> The first two patches fix a couple of issues I noticed while build
> testing and the final patch actually allows the option to be selected.

Thanks for this.

I thought about applying this last week but decided not to. I'll plan to
pick it up for 6.4.

cheers

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

* Re: [PATCH 0/3] Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+
  2023-02-20  6:11 ` [PATCH 0/3] " Michael Ellerman
@ 2023-02-20 15:51   ` Nathan Chancellor
  0 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2023-02-20 15:51 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: npiggin, christophe.leroy, erhard_f, ndesaulniers, trix,
	linuxppc-dev, linux-kernel, llvm, patches

On Mon, Feb 20, 2023 at 05:11:54PM +1100, Michael Ellerman wrote:
> Nathan Chancellor <nathan@kernel.org> writes:
> > Currently, CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 is not selectable with
> > ld.lld because of an explicit dependency on GNU ld, due to lack of
> > testing with LLVM.
> >
> > Erhard was kind enough to test this option on his hardware with LLVM 15,
> > which ran without any issues. This should not be too surprising, as
> > ld.lld does not have support for the ELFv1 ABI, only ELFv2, so it should
> > have decent support. With this series, big endian kernels can be built
> > with LLVM=1.
> >
> > This has seen our basic set of powerpc configurations with clang-15,
> > clang-16, and clang-17 but I will never be opposed to more testing :)
> >
> > The first two patches fix a couple of issues I noticed while build
> > testing and the final patch actually allows the option to be selected.
> 
> Thanks for this.
> 
> I thought about applying this last week but decided not to. I'll plan to
> pick it up for 6.4.

No worries, I sent this much later in the development cycle than I had
initially intended, so I figured that 6.3 was a long shot anyways. Plus
more soak time is never a bad thing :)

Thanks for taking the initial look, cheers!
Nathan

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

* Re: [PATCH 0/3] Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+
  2023-02-15 18:41 [PATCH 0/3] Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+ Nathan Chancellor
                   ` (3 preceding siblings ...)
  2023-02-20  6:11 ` [PATCH 0/3] " Michael Ellerman
@ 2023-03-22 12:25 ` Michael Ellerman
  4 siblings, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2023-03-22 12:25 UTC (permalink / raw)
  To: mpe, Nathan Chancellor
  Cc: npiggin, christophe.leroy, erhard_f, ndesaulniers, trix,
	linuxppc-dev, linux-kernel, llvm, patches

On Wed, 15 Feb 2023 11:41:14 -0700, Nathan Chancellor wrote:
> Currently, CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 is not selectable with
> ld.lld because of an explicit dependency on GNU ld, due to lack of
> testing with LLVM.
> 
> Erhard was kind enough to test this option on his hardware with LLVM 15,
> which ran without any issues. This should not be too surprising, as
> ld.lld does not have support for the ELFv1 ABI, only ELFv2, so it should
> have decent support. With this series, big endian kernels can be built
> with LLVM=1.
> 
> [...]

Applied to powerpc/next.

[1/3] powerpc/boot: Only use '-mabi=elfv2' with CONFIG_PPC64_BOOT_WRAPPER
      https://git.kernel.org/powerpc/c/d1c5accacb234c3a9f1609a73b4b2eaa4ef07d1a
[2/3] powerpc: Fix use of '-mabi=elfv2' with clang
      https://git.kernel.org/powerpc/c/7c3bd8362b06cff0a4044a4975adb7d71db2dfba
[3/3] powerpc: Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+
      https://git.kernel.org/powerpc/c/a11334d8327b3fd7987cbfb38e956a44c722d88f

cheers

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

end of thread, other threads:[~2023-03-22 12:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-15 18:41 [PATCH 0/3] Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+ Nathan Chancellor
2023-02-15 18:41 ` [PATCH 1/3] powerpc/boot: Only use '-mabi=elfv2' with CONFIG_PPC64_BOOT_WRAPPER Nathan Chancellor
2023-02-15 18:41 ` [PATCH 2/3] powerpc: Fix use of '-mabi=elfv2' with clang Nathan Chancellor
2023-02-15 18:41 ` [PATCH 3/3] powerpc: Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+ Nathan Chancellor
2023-02-20  6:11 ` [PATCH 0/3] " Michael Ellerman
2023-02-20 15:51   ` Nathan Chancellor
2023-03-22 12:25 ` Michael Ellerman

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