Hello, OpenBSD ports list!
I would like to make 3 changes to devel/boehm-gc, a garbage collector.
This is the same diff that I sent as "Re: Update lang/ecl to 20.4.24"
last week (Wed 29 Jul). The 3 changes are,
1. switch from sbrk() to mmap()
2. fix powerpc64
3. add AO_fetch_compare_and_swap for sparc64
sparc64 got an #error in ecl 20.4.24 when AO_fetch_compare_and_swap
was missing. With this diff, Josh Elsasser built ecl on sparc64, but
ecl "hung (not spinning)" in ecl's tests. I don't know why they hung,
so I'm not sure whether this AO_fetch_compare_and_swap is correct.
This diff passes boehm-gc's "make test" on amd64, macppc, powerpc64;
and works for me with lang/ecl 20.4.24 on those 3 platforms, and with
lang/crystal on amd64. We have boehm-gc 7.6.0, libatomic_ops 7.6.6;
latest are gc 8.0.4, ops 7.6.10, but I would like to commit this diff
without updating the versions.
OK to commit?
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, */