patches.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] s390/boot: Workaround current 'llvm-objdump -t -j ...' behavior
@ 2024-02-20 20:44 Nathan Chancellor
  2024-02-21  9:16 ` Heiko Carstens
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2024-02-20 20:44 UTC (permalink / raw)
  To: hca, gor, agordeev
  Cc: borntraeger, svens, morbo, justinstitt, linux-s390, llvm, patches,
	Nathan Chancellor

When building with OBJDUMP=llvm-objdump, there are a series of warnings
from the section comparisons that arch/s390/boot/Makefile performs
between vmlinux and arch/s390/boot/vmlinux:

  llvm-objdump: warning: section '.boot.preserved.data' mentioned in a -j/--section option, but not found in any input file
  llvm-objdump: warning: section '.boot.data' mentioned in a -j/--section option, but not found in any input file
  llvm-objdump: warning: section '.boot.preserved.data' mentioned in a -j/--section option, but not found in any input file
  llvm-objdump: warning: section '.boot.data' mentioned in a -j/--section option, but not found in any input file

The warning is a little misleading, as these sections do exist in the
input files. It is really pointing out that llvm-objdump does not match
GNU objdump's behavior of respecting '-j' / '--section' in combination
with '-t' / '--syms':

  $ s390x-linux-gnu-objdump -t -j .boot.data vmlinux.full

  vmlinux.full:     file format elf64-s390

  SYMBOL TABLE:
  0000000001951000 l     O .boot.data     0000000000003000 sclp_info_sccb
  00000000019550e0 l     O .boot.data     0000000000000001 sclp_info_sccb_valid
  00000000019550e2 g     O .boot.data     0000000000001000 early_command_line
  ...

  $ llvm-objdump -t -j .boot.data vmlinux.full

  vmlinux.full:   file format elf64-s390

  SYMBOL TABLE:
  0000000000100040 l     O .text  0000000000000010 dw_psw
  0000000000000000 l    df *ABS*  0000000000000000 main.c
  00000000001001b0 l     F .text  00000000000000c6 trace_event_raw_event_initcall_level
  0000000000100280 l     F .text  0000000000000100 perf_trace_initcall_level
  ...

It may be possible to change llvm-objdump's behavior to match GNU
objdump's behavior but the difficulty of that task has not yet been
explored. The combination of '$(OBJDUMP) -t -j' is not common in the
kernel tree on a whole, so workaround this tool difference by grepping
for the sections in the full symbol table output in a similar manner to
the sed invocation. This results in no visible change for GNU objdump
users while fixing the warnings for OBJDUMP=llvm-objdump, further
enabling use of LLVM=1 for ARCH=s390 with versions of LLVM that have
support for s390 in ld.lld and llvm-objcopy.

Reported-by: Heiko Carstens <hca@linux.ibm.com>
Closes: https://lore.kernel.org/20240219113248.16287-C-hca@linux.ibm.com/
Link: https://github.com/ClangBuiltLinux/linux/issues/859
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
s390 llvm-objcopy support may be backported to LLVM 18.1.0 in time for
the final release.

https://github.com/llvm/llvm-project/pull/82324

s390 ld.lld has already made it into release/18.x:

https://github.com/llvm/llvm-project/commit/0a44c3792a6ff799df5f100670d7e19d1bc49f03

If the objcopy change makes 18.1.0 final, features + this change should
build cleanly with LLVM 18.1.0+ using LLVM=1 :)
---
 arch/s390/boot/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/s390/boot/Makefile b/arch/s390/boot/Makefile
index aecafabc2054..294f08a8811a 100644
--- a/arch/s390/boot/Makefile
+++ b/arch/s390/boot/Makefile
@@ -60,9 +60,9 @@ clean-files += vmlinux.map
 
 quiet_cmd_section_cmp = SECTCMP $*
 define cmd_section_cmp
-	s1=`$(OBJDUMP) -t -j "$*" "$<" | sort | \
+	s1=`$(OBJDUMP) -t "$<" | grep "\s$*\s\+" | sort | \
 		sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
-	s2=`$(OBJDUMP) -t -j "$*" "$(word 2,$^)" | sort | \
+	s2=`$(OBJDUMP) -t "$(word 2,$^)" | grep "\s$*\s\+" | sort | \
 		sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
 	if [ "$$s1" != "$$s2" ]; then \
 		echo "error: section $* differs between $< and $(word 2,$^)" >&2; \

---
base-commit: 778666df60f0d96f215e33e27448de47a2207fb3
change-id: 20240220-s390-work-around-llvm-objdump-t-j-bf8dcdc4f291

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


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

* Re: [PATCH] s390/boot: Workaround current 'llvm-objdump -t -j ...' behavior
  2024-02-20 20:44 [PATCH] s390/boot: Workaround current 'llvm-objdump -t -j ...' behavior Nathan Chancellor
@ 2024-02-21  9:16 ` Heiko Carstens
  2024-02-21 16:48   ` Nathan Chancellor
  0 siblings, 1 reply; 3+ messages in thread
From: Heiko Carstens @ 2024-02-21  9:16 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: gor, agordeev, borntraeger, svens, morbo, justinstitt, linux-s390,
	llvm, patches

Hi Nathan,

On Tue, Feb 20, 2024 at 01:44:48PM -0700, Nathan Chancellor wrote:
> When building with OBJDUMP=llvm-objdump, there are a series of warnings
> from the section comparisons that arch/s390/boot/Makefile performs
> between vmlinux and arch/s390/boot/vmlinux:
...
> It may be possible to change llvm-objdump's behavior to match GNU
> objdump's behavior but the difficulty of that task has not yet been
> explored. The combination of '$(OBJDUMP) -t -j' is not common in the
> kernel tree on a whole, so workaround this tool difference by grepping
> for the sections in the full symbol table output in a similar manner to
> the sed invocation. This results in no visible change for GNU objdump
> users while fixing the warnings for OBJDUMP=llvm-objdump, further
> enabling use of LLVM=1 for ARCH=s390 with versions of LLVM that have
> support for s390 in ld.lld and llvm-objcopy.
> 
> Reported-by: Heiko Carstens <hca@linux.ibm.com>
> Closes: https://lore.kernel.org/20240219113248.16287-C-hca@linux.ibm.com/
> Link: https://github.com/ClangBuiltLinux/linux/issues/859
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> s390 llvm-objcopy support may be backported to LLVM 18.1.0 in time for
> the final release.
> 
> https://github.com/llvm/llvm-project/pull/82324
> 
> s390 ld.lld has already made it into release/18.x:
> 
> https://github.com/llvm/llvm-project/commit/0a44c3792a6ff799df5f100670d7e19d1bc49f03
> 
> If the objcopy change makes 18.1.0 final, features + this change should
> build cleanly with LLVM 18.1.0+ using LLVM=1 :)
> ---
>  arch/s390/boot/Makefile | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

This seems to work like expected (also verified with a couple of scenarios
where things are supposed to break).

So compiling the kernel with LLVM=1 finally works on s390!

Patch applied - Thanks a lot!

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

* Re: [PATCH] s390/boot: Workaround current 'llvm-objdump -t -j ...' behavior
  2024-02-21  9:16 ` Heiko Carstens
@ 2024-02-21 16:48   ` Nathan Chancellor
  0 siblings, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2024-02-21 16:48 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: gor, agordeev, borntraeger, svens, morbo, justinstitt, linux-s390,
	llvm, patches

Hi Heiko,

On Wed, Feb 21, 2024 at 10:16:12AM +0100, Heiko Carstens wrote:
> On Tue, Feb 20, 2024 at 01:44:48PM -0700, Nathan Chancellor wrote:
> > When building with OBJDUMP=llvm-objdump, there are a series of warnings
> > from the section comparisons that arch/s390/boot/Makefile performs
> > between vmlinux and arch/s390/boot/vmlinux:
> ...
> > It may be possible to change llvm-objdump's behavior to match GNU
> > objdump's behavior but the difficulty of that task has not yet been
> > explored. The combination of '$(OBJDUMP) -t -j' is not common in the
> > kernel tree on a whole, so workaround this tool difference by grepping
> > for the sections in the full symbol table output in a similar manner to
> > the sed invocation. This results in no visible change for GNU objdump
> > users while fixing the warnings for OBJDUMP=llvm-objdump, further
> > enabling use of LLVM=1 for ARCH=s390 with versions of LLVM that have
> > support for s390 in ld.lld and llvm-objcopy.
> > 
> > Reported-by: Heiko Carstens <hca@linux.ibm.com>
> > Closes: https://lore.kernel.org/20240219113248.16287-C-hca@linux.ibm.com/
> > Link: https://github.com/ClangBuiltLinux/linux/issues/859
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> > s390 llvm-objcopy support may be backported to LLVM 18.1.0 in time for
> > the final release.
> > 
> > https://github.com/llvm/llvm-project/pull/82324
> > 
> > s390 ld.lld has already made it into release/18.x:
> > 
> > https://github.com/llvm/llvm-project/commit/0a44c3792a6ff799df5f100670d7e19d1bc49f03
> > 
> > If the objcopy change makes 18.1.0 final, features + this change should
> > build cleanly with LLVM 18.1.0+ using LLVM=1 :)
> > ---
> >  arch/s390/boot/Makefile | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> This seems to work like expected (also verified with a couple of scenarios
> where things are supposed to break).
> 
> So compiling the kernel with LLVM=1 finally works on s390!
> 
> Patch applied - Thanks a lot!

Thanks a lot for testing and applying this quickly! Small update on the
LLVM side, the llvm-objcopy change made it into 18.1.0-rc3:

https://github.com/llvm/llvm-project/commit/5ef297ab611822537a385d45244867519563d3ef
https://github.com/llvm/llvm-project/commits/llvmorg-18.1.0-rc3

So it's pretty much official, 'ARCH=s390 LLVM=1' should build without
any issues with Linux 6.9+ and LLVM 18.1.0+ :)

Cheers,
Nathan

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

end of thread, other threads:[~2024-02-21 16:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-20 20:44 [PATCH] s390/boot: Workaround current 'llvm-objdump -t -j ...' behavior Nathan Chancellor
2024-02-21  9:16 ` Heiko Carstens
2024-02-21 16:48   ` Nathan Chancellor

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