[Bug 274927] Toolchain fails on the __sync_val_compare_and_swap function without -march=native (port biology/seqwish)

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 06 Nov 2023 00:17:51 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274927

--- Comment #6 from Mark Millard <marklmi26-fbsd@yahoo.com> ---
https://llvm.org/docs/Atomics.html#libcalls-sync reports that these
routines are special and can not use locks:

QUOTE
. . ., the Target in LLVM can claim support for atomics of an appropriate size,
and then implement some subset of the operations via libcalls to a __sync_*
function. Such functions must not use locks in their implementation, because
unlike the __atomic_* routines used by AtomicExpandPass, these may be
mixed-and-matched with native instructions by the target lowering.
END QUOTE

If I read that correctly, there is no generic implementation
possible/available.
It has to use hardware instructions that handle the size required. Some amd64
hardware has such, other amd64 hw does not. -march or the like has to indicate
a context with an appropriate instruction for __sync_val_compare_and_swap_16
to use.

So, as far as I can tell, a pre-built biology/seqwish that just works
everywhere
for amd64 is not really an option for the port.

Also, use of -march=native is not guaranteed to use an instruction that works
for the general range of amd64 hardware. It just plugs in the definition that
works for FreeBSD build server (that happens to support the operation), not
something generally useful. So just some subset of amd64 hardware likely ends
up handled.

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