On Wed, 29 Jul 2020 01:25:00 -0400 Kurt Mosiejczuk <k...@cranky.work> wrote:
> I gave building it a try, it died early on with: > > /usr/ports/pobj/ecl-20.4.24/ecl-20.4.24/build/ecl/ecl_atomics.h:39:4: error: > #er > ror "ECL needs AO_fetch_compare_and_swap or an equivalent" > # error "ECL needs AO_fetch_compare_and_swap or an equivalent" Thank you for the speedy test. libatomic_ops in devel/boehm-gc is missing AO_fetch_compare_and_swap for sparc. It's still missing upstream: https://github.com/ivmai/libatomic_ops/blob/master/src/atomic_ops/sysdeps/gcc/sparc.h#L64 In this diff to devel/boehm-gc, I have tried to provide the missing function (by copying AO_compare_and_swap_full, guessing, and referring to SPARCV9.pdf, A.9 Compare and Swap, page 129), but I don't know whether it compiles. Even if it compiles, if sparc64 will have the ecl_symbol_value bug, we won't know if it works. I left my other local changes (mmap and powerpc64) in the diff. I describe the 64-bit big-endian ecl_symbol_value bug at https://gitlab.com/embeddable-common-lisp/ecl/-/issues/604 Index: Makefile =================================================================== RCS file: /cvs/ports/devel/boehm-gc/Makefile,v retrieving revision 1.74 diff -u -p -r1.74 Makefile --- Makefile 4 Apr 2020 20:59:41 -0000 1.74 +++ Makefile 30 Jul 2020 02:37:28 -0000 @@ -12,7 +12,7 @@ DISTNAME= gc-${VERSION} PKGNAME-atomic= libatomic_ops-${LIBAO_VERSION} PKGNAME-main= boehm-gc-${VERSION} -REVISION= 5 +REVISION= 6 DISTFILES= ${DISTNAME}${EXTRACT_SUFX} \ libatomic_ops-${LIBAO_VERSION}${EXTRACT_SUFX} Index: patches/patch-include_private_gcconfig_h =================================================================== RCS file: /cvs/ports/devel/boehm-gc/patches/patch-include_private_gcconfig_h,v retrieving revision 1.22 diff -u -p -r1.22 patch-include_private_gcconfig_h --- patches/patch-include_private_gcconfig_h 15 Apr 2017 14:02:46 -0000 1.22 +++ patches/patch-include_private_gcconfig_h 30 Jul 2020 02:37:28 -0000 @@ -1,12 +1,25 @@ $OpenBSD: patch-include_private_gcconfig_h,v 1.22 2017/04/15 14:02:46 naddy Exp $ +- use mmap, not sbrk, on OpenBSD - All OpenBSD mips platforms are 64-bit, so correct the wordsize and alignment - use __data_start instead of _fdata on OpenBSD/mips64 -- add support for OpenBSD/aarch64 +- add support for OpenBSD/aarch64 and powerpc64 ---- include/private/gcconfig.h.orig Tue Aug 2 21:36:14 2016 -+++ include/private/gcconfig.h Fri Apr 14 17:44:40 2017 -@@ -102,7 +102,8 @@ +Index: include/private/gcconfig.h +--- include/private/gcconfig.h.orig ++++ include/private/gcconfig.h +@@ -76,6 +76,10 @@ + /* And one for OpenBSD: */ + # if defined(__OpenBSD__) + # define OPENBSD ++# ifndef USE_MMAP ++# define USE_MMAP ++# endif ++# define USE_MMAP_ANON + # endif + + /* And one for FreeBSD: */ +@@ -102,7 +106,8 @@ # endif # if defined(__aarch64__) # define AARCH64 @@ -16,7 +29,7 @@ $OpenBSD: patch-include_private_gcconfig # define NOSYS # define mach_type_known # endif -@@ -137,6 +138,10 @@ +@@ -137,6 +142,10 @@ # define ARM32 # define mach_type_known # endif @@ -27,7 +40,21 @@ $OpenBSD: patch-include_private_gcconfig # if defined(OPENBSD) && defined(__sh__) # define SH # define mach_type_known -@@ -1712,14 +1717,15 @@ +@@ -962,7 +971,12 @@ + # endif + # ifdef OPENBSD + # define OS_TYPE "OPENBSD" +-# define ALIGNMENT 4 ++# if defined(__powerpc64__) ++# define ALIGNMENT 8 ++# define CPP_WORDSZ 64 ++# else ++# define ALIGNMENT 4 ++# endif + # ifndef GC_OPENBSD_THREADS + # include <sys/param.h> + # include <uvm/uvm_extern.h> +@@ -1712,14 +1726,15 @@ # endif # ifdef OPENBSD # define OS_TYPE "OPENBSD" @@ -46,7 +73,7 @@ $OpenBSD: patch-include_private_gcconfig extern int _end[]; # define DATAEND ((ptr_t)(&_end)) # define DYNAMIC_LOADING -@@ -2165,6 +2171,19 @@ +@@ -2165,6 +2180,19 @@ extern char etext[]; # define DATASTART GC_FreeBSDGetDataStart(0x1000, (ptr_t)etext) # define DATASTART_USES_BSDGETDATASTART Index: patches/patch-libatomic_ops_src_atomic_ops_sysdeps_gcc_sparc_h =================================================================== RCS file: /cvs/ports/devel/boehm-gc/patches/patch-libatomic_ops_src_atomic_ops_sysdeps_gcc_sparc_h,v retrieving revision 1.3 diff -u -p -r1.3 patch-libatomic_ops_src_atomic_ops_sysdeps_gcc_sparc_h --- patches/patch-libatomic_ops_src_atomic_ops_sysdeps_gcc_sparc_h 4 Apr 2020 20:59:41 -0000 1.3 +++ patches/patch-libatomic_ops_src_atomic_ops_sysdeps_gcc_sparc_h 30 Jul 2020 02:37:28 -0000 @@ -2,6 +2,8 @@ $OpenBSD: patch-libatomic_ops_src_atomic Use the same type for input and output inline asm operands. +Provide AO_fetch_compare_and_swap, needed by lang/ecl 20.4.24. + Index: libatomic_ops/src/atomic_ops/sysdeps/gcc/sparc.h --- libatomic_ops/src/atomic_ops/sysdeps/gcc/sparc.h.orig +++ libatomic_ops/src/atomic_ops/sysdeps/gcc/sparc.h @@ -14,3 +16,26 @@ Index: libatomic_ops/src/atomic_ops/sysd __asm__ __volatile__ ("membar #StoreLoad | #LoadLoad\n\t" # if defined(__arch64__) "casx [%2],%0,%1\n\t" +@@ -61,7 +61,21 @@ AO_compare_and_swap_full(volatile AO_t *addr, AO_t old + } + #define AO_HAVE_compare_and_swap_full + +-/* TODO: implement AO_fetch_compare_and_swap. */ ++AO_INLINE AO_t ++AO_fetch_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val) { ++ __asm__ __volatile__ ("membar #StoreLoad | #LoadLoad\n\t" ++# if defined(__arch64__) ++ "casx [%1],%2,%0\n\t" ++# else ++ "cas [%1],%2,%0\n\t" /* 32-bit version */ ++# endif ++ "membar #StoreLoad | #StoreStore\n\t" ++ : "+r" (new_val) ++ : "r" (addr), "r" (old) ++ : "memory"); ++ return new_val; ++} ++#define AO_HAVE_fetch_compare_and_swap_full + #endif /* !AO_NO_SPARC_V9 */ + + /* TODO: Extend this for SPARC v8 and v9 (V8 also has swap, V9 has CAS, */