Bug 469049 - link failure on ppc64 (big endian) valgrind 3.20
Summary: link failure on ppc64 (big endian) valgrind 3.20
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.20.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-27 12:13 UTC by Dirk Mueller
Modified: 2023-06-26 12:14 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch for lto build on ppnbe (987 bytes, patch)
2023-04-29 06:52 UTC, Paul Floyd
Details
additional patch (3.75 KB, patch)
2023-06-26 11:21 UTC, Michal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Mueller 2023-04-27 12:13:52 UTC
SUMMARY
***

building valgrind for openSUSE Tumbleweed fails on ppc64 (big endian) with this link failure:


```
[   97s] make[3]: Entering directory '/home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck'
[   97s] ../coregrind/link_tool_exe_linux 0x58000000 gcc  -O2 -Wall -U_FORTIFY_SOURCE   -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type  -g   -o memcheck-ppc64be-linux -flto=auto -m64 -O2 -g -Wall -Wmissing-prototypes -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -Wcast-align -Wcast-qual -Wwrite-strings -Wempty-body -Wformat -Wformat-signedness -Wformat-security -Wignored-qualifiers -Wmissing-parameter-type -Wlogical-op -Wenum-conversion -Wimplicit-fallthrough=2 -Wold-style-declaration -finline-functions -fno-stack-protector -fno-strict-aliasing -fno-builtin   -O2 -static -nodefaultlibs -nostartfiles -u _start  -m64 memcheck_ppc64be_linux-mc_leakcheck.o memcheck_ppc64be_linux-mc_malloc_wrappers.o memcheck_ppc64be_linux-mc_main.o memcheck_ppc64be_linux-mc_main_asm.o memcheck_ppc64be_linux-mc_translate.o memcheck_ppc64be_linux-mc_machine.o memcheck_ppc64be_linux-mc_errors.o ../coregrind/libcoregrind-ppc64be-linux.a ../VEX/libvex-ppc64be-linux.a -lgcc ../coregrind/libgcc-sup-ppc64be-linux.a 
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans5.ltrans.o: in function `vgMemCheck_instrument':
[   97s] /home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_no_o'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans5.ltrans.o:/home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_no_o'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans5.ltrans.o: in function `vgMemCheck_instrument':
[   97s] /home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_w_o'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans5.ltrans.o:/home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_w_o'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans5.ltrans.o: in function `vgMemCheck_instrument':
[   97s] /home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_128_no_o'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans5.ltrans.o:/home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_128_no_o'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans8.ltrans.o: in function `tool_instrument_then_gdbserver_if_needed':
[   97s] /home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_helperc_CallDebugger'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans8.ltrans.o:/home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_helperc_CallDebugger'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans8.ltrans.o: in function `tool_instrument_then_gdbserver_if_needed':
[   97s] /home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_helperc_invalidate_if_not_gdbserved'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans8.ltrans.o:/home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_helperc_invalidate_if_not_gdbserved'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans8.ltrans.o: in function `vg_SP_update_pass':
[   97s] /home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update_w_ECU'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans8.ltrans.o:/home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update_w_ECU'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans8.ltrans.o: in function `vg_SP_update_pass':
[   97s] /home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans8.ltrans.o:/home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans8.ltrans.o: in function `vg_SP_update_pass':
[   97s] /home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update_w_ECU'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans8.ltrans.o:/home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update_w_ECU'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans8.ltrans.o: in function `vg_SP_update_pass':
[   97s] /home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update'
[   97s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccAV30QW.ltrans8.ltrans.o:/home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update'
[   97s] collect2: error: ld returned 1 exit status
[   97s] make[3]: *** [Makefile:1117: memcheck-ppc64be-linux] Error 1


```
***


STEPS TO REPRODUCE
1. on openSUSE Tumbleweed configure with ./configure --host=powerpc64-suse-linux-gnu --build=powerpc64-suse-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-lto=yes
2. make


is ppc64be still supported?
Comment 1 Mark Wielaard 2023-04-27 19:29:09 UTC
There is a debian ppc64(be) system for builder.sourceware.org which builds:
https://builder.sourceware.org/buildbot/#/builders/valgrind-debian-ppc64

It doesn't show that link error.
But looking at the auxchecks stdout report I see it has a runtime issue.
valgrind: m_syswrap/syswrap-main.c:549 (getSyscallArgsFromGuestState): Assertion 'gst->guest_syscall_flag == SC_FLAG' failed.
Comment 2 Paul Floyd 2023-04-28 08:13:16 UTC
(In reply to Mark Wielaard from comment #1)
> There is a debian ppc64(be) system for builder.sourceware.org which builds:
> https://builder.sourceware.org/buildbot/#/builders/valgrind-debian-ppc64
> 
> It doesn't show that link error.
> But looking at the auxchecks stdout report I see it has a runtime issue.
> valgrind: m_syswrap/syswrap-main.c:549 (getSyscallArgsFromGuestState):
> Assertion 'gst->guest_syscall_flag == SC_FLAG' failed.

#if defined(VGP_ppc64be_linux)
   /* The sc instruction is currently only supported on LE systems. */
   vg_assert(gst->guest_syscall_flag == SC_FLAG);
#endif

It looks to me that the comment doesn't match what the code does.

If only LE systems set SC_FLAG then the assert should be != rather than ==.

Is guest_ppc_toIR.c line 10778 put_syscall_flag( mkU32(SC_FLAG) ); executed ?
That's what the assert is expecting.
Comment 3 Paul Floyd 2023-04-28 08:30:14 UTC
(In reply to Dirk Mueller from comment #0)

> /tmp/ccAV30QW.ltrans8.ltrans.o:/home/abuild/rpmbuild/BUILD/valgrind-3.20.0/
> memcheck/../coregrind/m_machine.c:2393: undefined reference to
> `vgPlain_unknown_SP_update'
> [   97s]
> /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/
> ld: /tmp/ccAV30QW.ltrans8.ltrans.o: in function `vg_SP_update_pass':
> [   97s]
> /home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.
> c:2393: undefined reference to `vgPlain_unknown_SP_update_w_ECU'
> [   97s]
> /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/
> ld:
> /tmp/ccAV30QW.ltrans8.ltrans.o:/home/abuild/rpmbuild/BUILD/valgrind-3.20.0/
> memcheck/../coregrind/m_machine.c:2393: undefined reference to
> `vgPlain_unknown_SP_update_w_ECU'
> [   97s]
> /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/
> ld: /tmp/ccAV30QW.ltrans8.ltrans.o: in function `vg_SP_update_pass':
> [   97s]
> /home/abuild/rpmbuild/BUILD/valgrind-3.20.0/memcheck/../coregrind/m_machine.
> c:2393: undefined reference to `vgPlain_unknown_SP_update'

vgPlain_unknown_SP_update (aka VG_(unknown_SP_update)) is just an ordinary function in coregrind/m_stacks.c

I can't see any conditional compilation that would cause it to be not compiled. There is this bit in coregrind/Makefile.am

# The below files cannot be compiled with lto, otherwise that gives
# undefined symbols at link time. So, define a noinst library to
# build the needed .o with specific flags.
# These objects are added to the libcoregrind library.
NOLTO_COREGRIND_SOURCES_COMMON = \
        m_libcsetjmp.c \
        m_main.c

Perhaps m_stacks.c needs to be moved there?

Can you check with nm that vgPlain_unknown_SP_update is in libcoregrind-ppc64be-linux.a ?

> STEPS TO REPRODUCE
> 1. on openSUSE Tumbleweed configure with ./configure
> --host=powerpc64-suse-linux-gnu --build=powerpc64-suse-linux-gnu
> --program-prefix= --disable-dependency-tracking --prefix=/usr
> --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
> --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
> --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib
> --mandir=/usr/share/man --infodir=/usr/share/info --enable-lto=yes

Would it be possible to try a build with just "configure"? Or even just without --enable-lto=yes?
Comment 4 Mark Wielaard 2023-04-28 10:59:23 UTC
(In reply to Paul Floyd from comment #2)
> (In reply to Mark Wielaard from comment #1)
> > There is a debian ppc64(be) system for builder.sourceware.org which builds:
> > https://builder.sourceware.org/buildbot/#/builders/valgrind-debian-ppc64
> > 
> > It doesn't show that link error.
> > But looking at the auxchecks stdout report I see it has a runtime issue.
> > valgrind: m_syswrap/syswrap-main.c:549 (getSyscallArgsFromGuestState):
> > Assertion 'gst->guest_syscall_flag == SC_FLAG' failed.
> 
> #if defined(VGP_ppc64be_linux)
>    /* The sc instruction is currently only supported on LE systems. */
>    vg_assert(gst->guest_syscall_flag == SC_FLAG);
> #endif
> 
> It looks to me that the comment doesn't match what the code does.

I opened a separate bug for this: https://bugs.kde.org/show_bug.cgi?id=469097
Comment 5 Paul Floyd 2023-04-28 12:16:59 UTC
This is an LTO issue. On gccfarm gcc203 which is

paulf@gcc203:~/scratch/valgrind$ lscpu
Architecture:            ppc64
  CPU op-mode(s):        32-bit, 64-bit
  Byte Order:            Big Endian

Then with 

./configure --enable-lto=yes

(from git HEAD but surely the same as the RC tarball)

I get


s.o ../coregrind/libcoregrind-ppc64be-linux.a ../VEX/libvex-ppc64be-linux.a -lgcc ../coregrind/libgcc-sup-ppc64be-linux.a 
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o: in function `vg_SP_update_pass':
/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update_w_ECU'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o:/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update_w_ECU'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o: in function `vg_SP_update_pass':
/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o:/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o: in function `vg_SP_update_pass':
/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update_w_ECU'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o:/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update_w_ECU'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o: in function `vg_SP_update_pass':
/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o:/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_unknown_SP_update'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o: in function `vgMemCheck_instrument':
/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_no_o'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o:/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_no_o'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o: in function `vgMemCheck_instrument':
/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_w_o'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o:/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_w_o'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o: in function `vgMemCheck_instrument':
/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_128_no_o'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o:/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_128_no_o'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o: in function `tool_instrument_then_gdbserver_if_needed':
/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_helperc_CallDebugger'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o:/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_helperc_CallDebugger'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o: in function `tool_instrument_then_gdbserver_if_needed':
/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_helperc_invalidate_if_not_gdbserved'
/usr/bin/ld: /tmp/ccKRxaHx.ltrans0.ltrans.o:/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_helperc_invalidate_if_not_gdbserved'

$ nm coregrind/libcoregrind-ppc64be-linux.a | grep  vgPlain_unknown_SP_update
00000000 T vgPlain_unknown_SP_update
00000000 T vgPlain_unknown_SP_update_w_ECU

The same nm without lto

$ nm coregrind/libcoregrind-ppc64be-linux.a | grep  vgPlain_unknown_SP_update
00000000000000a8 D vgPlain_unknown_SP_update
0000000000000090 D vgPlain_unknown_SP_update_w_ECU

If I move m_stacks.c to NOLTO_COREGRIND_SOURCES_COMMON then I get fewer link errors

/usr/bin/ld: /tmp/ccOzIZRr.ltrans0.ltrans.o: in function `vgMemCheck_instrument':
/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_no_o'
/usr/bin/ld: /tmp/ccOzIZRr.ltrans0.ltrans.o:/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_no_o'
/usr/bin/ld: /tmp/ccOzIZRr.ltrans0.ltrans.o: in function `vgMemCheck_instrument':
/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_w_o'
/usr/bin/ld: /tmp/ccOzIZRr.ltrans0.ltrans.o:/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_w_o'
/usr/bin/ld: /tmp/ccOzIZRr.ltrans0.ltrans.o: in function `vgMemCheck_instrument':
/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_128_no_o'
/usr/bin/ld: /tmp/ccOzIZRr.ltrans0.ltrans.o:/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgMemCheck_helperc_MAKE_STACK_UNINIT_128_no_o'
/usr/bin/ld: /tmp/ccOzIZRr.ltrans0.ltrans.o: in function `tool_instrument_then_gdbserver_if_needed':
/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_helperc_CallDebugger'
/usr/bin/ld: /tmp/ccOzIZRr.ltrans0.ltrans.o:/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_helperc_CallDebugger'
/usr/bin/ld: /tmp/ccOzIZRr.ltrans0.ltrans.o: in function `tool_instrument_then_gdbserver_if_needed':
/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_helperc_invalidate_if_not_gdbserved'
/usr/bin/ld: /tmp/ccOzIZRr.ltrans0.ltrans.o:/home/paulf/scratch/valgrind/memcheck/../coregrind/m_machine.c:2393: undefined reference to `vgPlain_helperc_invalidate_if_not_gdbserved'

and the nm looks OK.
Comment 6 Mark Wielaard 2023-04-28 13:30:51 UTC
(In reply to Paul Floyd from comment #5)
> This is an LTO issue. On gccfarm gcc203 which is
> 
> paulf@gcc203:~/scratch/valgrind$ lscpu
> Architecture:            ppc64
>   CPU op-mode(s):        32-bit, 64-bit
>   Byte Order:            Big Endian
> 
> Then with 
> 
> ./configure --enable-lto=yes
> 
> (from git HEAD but surely the same as the RC tarball)

Can replicate a link issue on a ppc64-debian system with gcc (Debian 12.2.0-14) 12.2.0

But on an x86_64 fedora system with gcc (GCC) 13.0.1 20230401 (Red Hat 13.0.1-0)  --enable-lto=yes seems to work fine.

Dunno why this is ppc64 specific.

Clearly the workaround for now is to configure with --enable-lto=no
Comment 7 Paul Floyd 2023-04-29 05:17:32 UTC
I was wondering about the GCC version - the system that I reproduced on has GCC 12.2 so quite recent.
Comment 8 Paul Floyd 2023-04-29 06:52:29 UTC
Created attachment 158529 [details]
Patch for lto build on ppnbe

With this

== 744 tests, 14 stderr failures, 5 stdout failures, 0 stderrB failures, 2 stdoutB failures, 4 post failures ==
Comment 9 Paul Floyd 2023-05-06 05:55:25 UTC
commit 92a661ebf328b4cf0027234a33952e6e13964b5d (HEAD -> master, origin/master, origin/HEAD)
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Sat May 6 07:54:45 2023 +0200

    Bug 469049 - link failure on ppc64 (big endian) valgrind 3.20
Comment 10 Michal 2023-06-26 11:21:54 UTC
Created attachment 159912 [details]
additional patch

It does not really help. memcheck also fails to link, and when that is resolved callgrind fails to link 

[  145s] ../coregrind/link_tool_exe_linux 0x58000000 gcc  -O2 -Wall -U_FORTIFY_SOURCE   -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type  -g   -o callgrind-ppc64be-linux -flto=auto -m64 -O2 -g -Wall -Wmissing-prototypes -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -Wcast-align -Wcast-qual -Wwrite-strings -Wempty-body -Wformat -Wformat-signedness -Wformat-security -Wignored-qualifiers -Wmissing-parameter-type -Wlogical-op -Wenum-conversion -Wimplicit-fallthrough=2 -Wold-style-declaration -finline-functions -fno-stack-protector -fno-strict-aliasing -fno-builtin   -I../cachegrind -static -nodefaultlibs -nostartfiles -u _start  -m64 callgrind_ppc64be_linux-bb.o callgrind_ppc64be_linux-bbcc.o callgrind_ppc64be_linux-callstack.o callgrind_ppc64be_linux-clo.o callgrind_ppc64be_linux-context.o callgrind_ppc64be_linux-costs.o callgrind_ppc64be_linux-debug.o callgrind_ppc64be_linux-dump.o callgrind_ppc64be_linux-events.o callgrind_ppc64be_linux-fn.o callgrind_ppc64be_linux-jumps.o callgrind_ppc64be_linux-main.o callgrind_ppc64be_linux-sim.o callgrind_ppc64be_linux-threads.o ../coregrind/libcoregrind-ppc64be-linux.a ../VEX/libvex-ppc64be-linux.a -lgcc ../coregrind/libgcc-sup-ppc64be-linux.a 
[  145s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccaULq5i.ltrans1.ltrans.o: in function `vgCallgrind_instrument':
[  145s] /home/abuild/rpmbuild/BUILD/valgrind-3.21.0/callgrind/../coregrind/m_machine.c:2393: undefined reference to `vgCallgrind_setup_bbcc'
[  145s] /usr/lib64/gcc/powerpc64-suse-linux/13/../../../../powerpc64-suse-linux/bin/ld: /tmp/ccaULq5i.ltrans1.ltrans.o:/home/abuild/rpmbuild/BUILD/valgrind-3.21.0/callgrind/../coregrind/m_machine.c:2393: undefined reference to `vgCallgrind_setup_bbcc'
[  145s] collect2: error: ld returned 1 exit status
[  145s] make[3]: *** [Makefile:1119: callgrind-ppc64be-linux] Error 1
[  145s] make[3]: Leaving directory '/home/abuild/rpmbuild/BUILD/valgrind-3.21.0/callgrind'
[  145s] make[3]: *** Waiting for unfinished jobs....
[  156s] make[3]: Entering directory '/home/abuild/rpmbuild/BUILD/valgrind-3.21.0/callgrind'
[  156s] ../coregrind/link_tool_exe_linux 0x58000000 gcc  -O2 -Wall -U_FORTIFY_SOURCE   -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type  -g   -o callgrind-ppc32-linux -flto=auto -m32 -O2 -g -Wall -Wmissing-prototypes -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -Wcast-align -Wcast-qual -Wwrite-strings -Wempty-body -Wformat -Wformat-signedness -Wformat-security -Wignored-qualifiers -Wmissing-parameter-type -Wlogical-op -Wenum-conversion -Wimplicit-fallthrough=2 -Wold-style-declaration -finline-functions -fno-stack-protector -fno-strict-aliasing -fno-builtin   -I../cachegrind -static -nodefaultlibs -nostartfiles -u _start   -m32 callgrind_ppc32_linux-bb.o callgrind_ppc32_linux-bbcc.o callgrind_ppc32_linux-callstack.o callgrind_ppc32_linux-clo.o callgrind_ppc32_linux-context.o callgrind_ppc32_linux-costs.o callgrind_ppc32_linux-debug.o callgrind_ppc32_linux-dump.o callgrind_ppc32_linux-events.o callgrind_ppc32_linux-fn.o callgrind_ppc32_linux-jumps.o callgrind_ppc32_linux-main.o callgrind_ppc32_linux-sim.o callgrind_ppc32_linux-threads.o ../coregrind/libcoregrind-ppc32-linux.a ../VEX/libvex-ppc32-linux.a -lgcc ../coregrind/libgcc-sup-ppc32-linux.a 
[  156s] make[3]: Leaving directory '/home/abuild/rpmbuild/BUILD/valgrind-3.21.0/callgrind'
[  156s] make[2]: *** [Makefile:1637: all-recursive] Error 1
[  156s] make[1]: *** [Makefile:914: all-recursive] Error 1
[  156s] make: *** [Makefile:777: all] Error 2
[  156s] error: Bad exit status from /var/tmp/rpm-tmp.jTkwVz (%build)
Comment 11 Paul Floyd 2023-06-26 12:14:59 UTC
The real answer for this is to not use LTO.

Do you have evidence showing that there is a big benefit to using it?