From 9da016ebff542c1137cfb742dd2683974f86929b Mon Sep 17 00:00:00 2001 From: patrick Date: Tue, 28 Dec 2021 15:45:17 +0000 Subject: [PATCH] Compile out-of-line helpers for atomic operations which can be enabled through -moutline-atomics. These are included by default in this updated version of compiler-rt, we just haven't enabled them yet. Some ports start to make use of that option, so it makes sense to provide these helpers. The helpers would make use of the ARMv8.1 LSE instructions, if we flagged that the running system supports those. As we do not yet have a mechanism to show support for LSE, the code will always fall back to regular atomics. Issue raised by jca@ Tested by phessler@ Input from jsg@ ok kettenis@ --- gnu/lib/libcompiler_rt/Makefile | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/gnu/lib/libcompiler_rt/Makefile b/gnu/lib/libcompiler_rt/Makefile index ba0c4c5fe0f..89db447998a 100644 --- a/gnu/lib/libcompiler_rt/Makefile +++ b/gnu/lib/libcompiler_rt/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.5 2021/04/28 22:56:22 drahn Exp $ +# $OpenBSD: Makefile,v 1.6 2021/12/28 15:45:17 patrick Exp $ .include @@ -14,6 +14,7 @@ NOPIC= NOPROFILE= CFLAGS+= -fPIC -std=gnu99 -fvisibility=hidden -fno-stack-protector +CPPFLAGS+= -I${.CURDIR}/../../llvm/compiler-rt/lib/builtins CPPFLAGS+= -DVISIBILITY_HIDDEN .if ${MACHINE_ARCH} == "amd64" @@ -210,6 +211,24 @@ SRCS+= comparetf2.c \ multc3.c \ trunctfdf2.c \ trunctfsf2.c + +# Prepare multiple versions of the LSE-helper +CPPFLAGS+=-DHAS_ASM_LSE +.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" +outline_atomic_${pat}${size}_${model}.S: Makefile ${.CURDIR}/../../llvm/compiler-rt/lib/builtins/${RTARCH}/lse.S + @echo "#define L_${pat}\n#define SIZE ${size}\n#define MODEL ${model}\n" > $@.tmp + @cat ${.CURDIR}/../../llvm/compiler-rt/lib/builtins/${RTARCH}/lse.S >> $@.tmp + @mv $@.tmp $@ + +SRCS+= outline_atomic_${pat}${size}_${model}.S +. endif +. endfor +. endfor +.endfor + .endif .if ${RTARCH} == "arm" -- 2.20.1