git: 1a398266112e - stable/12 - compilert-rt: build out-of-line LSE atomics helpers for aarch64

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sat, 25 Dec 2021 11:55:35 UTC
The branch stable/12 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=1a398266112e73f91a4f2e2701ceefd3f2948aac

commit 1a398266112e73f91a4f2e2701ceefd3f2948aac
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-07-28 20:30:04 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-12-25 11:51:11 +0000

    compilert-rt: build out-of-line LSE atomics helpers for aarch64
    
    Both clang >= 12 and gcc >= 10.1 now default to -moutline-atomics for
    aarch64. This requires a bunch of helper functions in libcompiler_rt.a,
    to avoid link errors like "undefined symbol: __aarch64_ldadd8_acq_rel".
    
    (Note: of course you can use -mno-outline-atomics as a workaround too,
    but this would negate the potential performance benefit of the faster
    LSE instructions.)
    
    Bump __FreeBSD_version so ports maintainers can easily detect this.
    
    PR:             257392
    MFC after:      2 weeks
    
    (cherry picked from commit cc55ee8009a550810d38777fd6ace9abf3a2f6b4)
---
 lib/libcompiler_rt/Makefile | 20 ++++++++++++++++++++
 sys/sys/param.h             |  2 +-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/lib/libcompiler_rt/Makefile b/lib/libcompiler_rt/Makefile
index 0f42dd516c51..9088c9452125 100644
--- a/lib/libcompiler_rt/Makefile
+++ b/lib/libcompiler_rt/Makefile
@@ -19,6 +19,26 @@ NO_WERROR.gcc=
 
 .include "Makefile.inc"
 
+# Out-of-line LSE atomics helpers for aarch64
+.if ${MACHINE_CPUARCH} == "aarch64"
+. for pat in cas swp ldadd ldclr ldeor ldset
+.  for size in 1 2 4 8 16
+.   for model in 1 2 3 4
+.    if ${pat} == "cas" || ${size} != "16"
+# Use .for to define lse_name, to get a special loop-local variable
+.     for lse_name in outline_atomic_${pat}${size}_${model}.S
+CLEANFILES+=	${lse_name}
+STATICOBJS+=	${lse_name:R}.o
+ACFLAGS.${lse_name}+= -DL_${pat} -DSIZE=${size} -DMODEL=${model} -I${CRTSRC}
+${lse_name}: lse.S
+	ln -sf ${.ALLSRC} ${.TARGET}
+.     endfor # lse_name
+.    endif
+.   endfor # model
+.  endfor # size
+. endfor # pat
+.endif
+
 .if ${MK_INSTALLLIB} != "no"
 SYMLINKS+=	libcompiler_rt.a ${LIBDIR}/libgcc.a
 .endif
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 4aa0c765e96c..d31ba8da1ffa 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -60,7 +60,7 @@
  *		in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1203503	/* Master, propagated to newvers */
+#define __FreeBSD_version 1203504	/* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,