git: b148c7b87148 - stable/12 - Add atomic and bswap functions to libcompiler_rt
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 22 Dec 2021 10:06:08 UTC
The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=b148c7b87148b653fdbef9c5aa591b9abcd99e26 commit b148c7b87148b653fdbef9c5aa591b9abcd99e26 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2020-08-25 06:49:10 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2021-12-22 09:58:36 +0000 Add atomic and bswap functions to libcompiler_rt There have been several mentions on our mailing lists about missing atomic functions in our system libraries (e.g. __atomic_load_8 and friends), and recently I saw __bswapdi2 and __bswapsi2 mentioned too. To address this, add implementations for the functions from compiler-rt to the system compiler support libraries, e.g. libcompiler_rt.a and and libgcc_s.so. This also needs a small fixup in compiler-rt's atomic.c, to ensure that 32-bit mips can build correctly. Bump __FreeBSD_version to make it easier for port maintainers to detect when these functions were added. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D26159 (cherry picked from commit 46c8c5540fe4995e01fcf2e173c05761e7ba9488) --- contrib/llvm-project/compiler-rt/lib/builtins/atomic.c | 4 ++-- lib/libcompiler_rt/Makefile.inc | 6 ++++++ sys/sys/param.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c b/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c index 2a69101fbcee..84d116a36cd9 100644 --- a/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c +++ b/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c @@ -125,8 +125,8 @@ static __inline Lock *lock_for_pointer(void *ptr) { #define IS_LOCK_FREE_2 __c11_atomic_is_lock_free(2) #define IS_LOCK_FREE_4 __c11_atomic_is_lock_free(4) -/// 32 bit PowerPC doesn't support 8-byte lock_free atomics -#if !defined(__powerpc64__) && defined(__powerpc__) +/// 32 bit MIPS and PowerPC don't support 8-byte lock_free atomics +#if defined(__mips__) || (!defined(__powerpc64__) && defined(__powerpc__)) #define IS_LOCK_FREE_8 0 #else #define IS_LOCK_FREE_8 __c11_atomic_is_lock_free(8) diff --git a/lib/libcompiler_rt/Makefile.inc b/lib/libcompiler_rt/Makefile.inc index 5766e835ea38..217ea4da0049 100644 --- a/lib/libcompiler_rt/Makefile.inc +++ b/lib/libcompiler_rt/Makefile.inc @@ -1,5 +1,7 @@ # $FreeBSD$ +.include <bsd.compiler.mk> + CRTARCH= ${MACHINE_CPUARCH:C/amd64/x86_64/} CRTSRC= ${SRCTOP}/contrib/llvm-project/compiler-rt/lib/builtins @@ -129,6 +131,10 @@ SRCF+= umodti3 SRCF+= atomic .endif +.if "${COMPILER_TYPE}" == "clang" +CFLAGS.atomic.c+= -Wno-atomic-alignment +.endif + # Avoid using SSE2 instructions on i386, if unsupported. .if ${MACHINE_CPUARCH} == "i386" && empty(MACHINE_CPU:Msse2) SRCS+= floatdidf.c diff --git a/sys/sys/param.h b/sys/sys/param.h index 2bfe64db455a..3a7cf79e918b 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 1203500 /* Master, propagated to newvers */ +#define __FreeBSD_version 1203501 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,