https://bugs.kde.org/show_bug.cgi?id=528993

            Bug ID: 528993
           Summary: FreeBSD: add powerpc64 and powerpc64le support
    Classification: Developer tools
           Product: valgrind
      Version First unspecified
       Reported In:
          Platform: Compiled Sources
                OS: FreeBSD
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

The attached series adds two new platforms, ppc64be-freebsd and
ppc64le-freebsd.  FreeBSD uses the ELFv2 ABI on both big and little
endian powerpc64, so both reuse the ELFv2 support of ppc64le-linux;
the FreeBSD specific parts follow the arm64-freebsd port.

Patches 1-5 are ppc fixes outside the new platforms.  They do not
depend on the port and can be reviewed and applied on their own; 1-4
also affect Linux, 5 is a no-op on Linux:

1. ppc64le: clobber the volatile vector registers in CALL_FN_*
   The ppc64le CALL_FN_* macros did not declare FPRs, VRs and VSRs as
   clobbered.  clang kept a constant in vs1 across the call in DRD's
   pthread_once wrapper, and DRD asserted in tc21_pthonce.  Affects
   clang builds on ppc64le-linux the same way.

2. ppc: don't lose a frame when the innermost function has no frame
   If the innermost function has not allocated a frame (clang leaf
   functions even at -O0, gcc leaf functions at -O1+, any prologue),
   the back chain unwinder lost the caller's caller.  The function is
   now checked for a "stdu/stdux/stwu/stwux r1" before the IP.

3. ppc64: evaluate clang's r31 DW_AT_frame_base
   clang uses DW_OP_reg31 as the frame base when it keeps a frame
   pointer; without this, no stack variable descriptions.

4. ppc64: find .plt in the second RW PT_LOAD of lld-linked objects
   Same pattern as bug 452802 for .got.plt.  The wrong .plt address
   made DRD and Helgrind report races on the PLT stubs.

5. VEX ppc: choose r11/r12 and fn descriptors by ABI, not endianness
   The noredir special instruction and the BCD helper calls assumed
   big endian == ELFv1.  Now keyed on host_ppc_calls_use_fndescrs (and
   64-bit mode for r12, so ppc32 keeps r11).  No change for the
   existing platforms; needed for big endian ELFv2, which is also what
   bug 398883 (musl based Linux) is about.

6. FreeBSD: add powerpc64 and powerpc64le support
   The port itself, including NEWS, README, README.freebsd and the
   regression test adjustments.  The commit message describes the
   kernel interface and the non-obvious parts (no r12-based TOC setup
   in the dispatcher, because lld does not relax it the way GNU ld
   does; thr_new register clearing).

Testing

FreeBSD 15.2 on POWER9, built with the base system clang
21.1.8 and lld, regression tests run as root with "ulimit -n 4096"
(see below):

- powerpc64:   788 tests, 60 failures
- powerpc64le: 788 tests, 67 failures (with an earlier build of the
  series; nothing changed since affects ppc64le)

42 of the failures on each are the none/tests/ppc64 and
memcheck/tests/ppc64 instruction tests, which need gcc and GNU as and
do not build with clang.  The rest:

- root vs. user: memcheck/tests/freebsd/{fchroot,getfh,kenv,setcred}
  expect to run as a normal user and pass that way.
- FreeBSD 15.2: scalar_pdfork uses a flags value (12) that is now
  valid (PD_NOWAITPID | PD_PTRACE_CAP), on every architecture.
- environment: kqueue, kqueuex, umtx_shm_creat1/2, getrlimitusage (CPU
  time under load), realpathat (depends on the length of the build
  directory path) and getfsstat.  getfsstat.c passes the mount count
  to getfsstat() with a 128 entry stack buffer, which overflows when
  more than 128 file systems are mounted (poudriere builds were
  running); that is a test bug on every architecture.
- the expected output came from gcc builds and clang's code differs
  (an extra frame, a line number or an extra load): fprw, mempool2,
  wrap8, supponlyobj, and on ppc64le drd fp_race, sem_open,
  sem_as_mutex, annotate_trace_memory.  pth_mutex_signal is output
  interleaving.

gdbserver_tests: the tests that only need vgdb (mchelp, mcinvokeRU,
nlfork_chain) pass.  The gdb-driven ones could not be run: gdb 15.1
from ports dies with "Recursive internal problem." as soon as a
breakpoint is hit on these machines, also without Valgrind.

Known open issue: drd/tests/tls_threads fails intermittently, a race
reported on thread-local data (ppc64le 2 of 5 runs, also seen once on
powerpc64).

Unrelated finding: FreeBSD sizes RLIMIT_NOFILE by the amount of RAM
(about 15 million on these machines).  Valgrind keeps its own file
descriptors just below the soft limit, so every fork copies a huge
file descriptor table: vfork+exec took 3 s under Valgrind against
22 ms natively, and the async-sigs tests time out.  A lower
"ulimit -n" avoids it.  This affects all FreeBSD architectures; I can
open a separate bug for it.

The patches were written with the help of an AI tool (Claude Code by
Anthropic); each commit has a Co-Authored-By trailer.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to