[Bug 298461] emulators/qemu-user-static-devel: does not build on FreeBSD 15 (undefined symbol __realpathat; keymap generation)

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 14 Sep 2026 00:01:04 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=298461

--- Comment #1 from Rick Richard <rick@sloservers.com> ---
Follow-up after checking upstream: this port is pinned to qemu-bsd-user commit
64ff0f053df, dated 2022-02-04, on the "blitz" branch. That branch is still
actively maintained - HEAD is e725658f (2026-05-24) and now carries VERSION
11.0.50, five major QEMU releases ahead of the 6.2.50 this port ships.

Two of the three things in my patch are already fixed upstream, one of them
better than my version:

1) __realpathat. blitz HEAD no longer references the libc symbol at all. In
bsd-user/freebsd/os-stat.h it now does:

    ret = get_errno(syscall(SYS___realpathat, arg1, p, b, arg4, arg5));

That sidesteps the two-underscore vs three-underscore question entirely and is
clearly preferable to the rename in my patch. My hunk fixes a snapshot upstream
has already moved past.

2) A separate runtime defect in the same snapshot, also fixed upstream. In
bsd-user/freebsd/os-thread.c, freebsd_umtx_nwake_private() indexed its batch
array with the outer loop variable:

    uaddrs[i % BATCH_SIZE] = (uintptr_t)g2h_untagged(tp[j]);

BATCH_SIZE is 128, so for any broadcast of fewer than 128 waiters every address
lands in uaddrs[0] and the kernel is handed one real address plus uninitialised
stack as wake targets. pthread_cond_broadcast() to N waiters wakes exactly one.
Any 32-bit guest using a thread pool hangs: "zstd -T8" under emulation writes
its complete output and never exits, and poudriere cross builds stall in
"pkg create" and "pkg repo" because Mk/bsd.port.mk passes
-T${MAKE_JOBS_NUMBER}.

blitz HEAD already reads uaddrs[j % BATCH_SIZE]. Changing i to j in the pinned
version took a poudriere armv7 bulk run from crashed after 2h25m to done in
1m43s with full build parallelism.

3) The keymap problem IS still present upstream at blitz HEAD:

    native_qemu_keymap = find_program('qemu-keymap', required: false, disabler:
true)

so that hunk stays relevant regardless of version.

Given the above, updating the port to a current blitz commit is a better fix
than my first two hunks and would pick up four years of bsd-user work besides.
I am attempting that now and will follow up here with a version-bump patch if
it builds cleanly; treat the attached diff as a stopgap for the pinned version
in the meantime.

For completeness: mainline QEMU is not affected - bsd-user/freebsd in qemu.git
has no os-thread.c and no umtx implementation, so there is nothing to report
upstream of the fork.

-- 
You are receiving this mail because:
You are the assignee for the bug.