arm64/aarch64 buildworld link error on atomics in lib/libgcc_s (+workaround)

From: Anders Straadt <anders_at_straadt.dk>
Date: Fri, 31 Oct 2025 11:25:23 UTC
I get several "non-exported symbols" on atomics like these:

--- all_subdir_bin ---
ld: error: non-exported symbol '__aarch64_cas4_acq' in
'.../arm64.aarch64/tmp/usr/lib/libgcc.a(outline_atomic_cas4_2.o)' is
referenced by DSO '.../arm64.aarch64/tmp/usr/lib/libgcc_s.so'

Last year's commit 361da40536d7f implements a workaround in
sys/conf/kern.mk for the same problem it seems (C11 atomics stuff?),
so I adapted it for lib/libgcc_s/Makefile, and after that buildworld
(and buildkernel) works:


--- a/lib/libgcc_s/Makefile
+++ b/lib/libgcc_s/Makefile
@@ -44,6 +44,10 @@ SRCS+=        s_logbf.c
 SRCS+=        s_scalbn.c
 SRCS+=        s_scalbnf.c

+.if ${MACHINE_CPUARCH} == "aarch64"
+CFLAGS+=    -mno-outline-atomics
+.endif
+
 # Don't include long double routines on architectures where long double
 # is the same size as double.
 .if ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "powerpc"


FWIW I get the same link error when building on 15.0-BETA3 native*,
and when cross-building (TARGET_ARCH=aarch64) on a 2017-ish Core i7
running 14.3-RELEASE, and the patch works in both cases.

-Anders

*) 14-3.RELEASE only booted in safe mode on my new Lenovo ThinkCentre
Neo 50q / Snapdragon X1-26-100. Normal boot blanked+rebooted after few
seconds; last non-blank frame in a phone video capture shows the line
right before "CPU  0: Qualcomm(...)" on 15.0-BETA3 -- which boots and
finds all 8 cores. The CPU is sluggish though ("World built in 13497
seconds, ncpu: 8, make -j8"), possibly due to some ACPI problem I see
in dmesg every 10 seconds (also, "powerd: no cpufreq(4) support --
aborting"), which is why I'm (new) here in -CURRENT (hi!)