Browse Source

Bring in some libdb patches; Still not enough for macOS

pull/10/head
falkTX 4 years ago
parent
commit
ccf4ec254a
4 changed files with 400 additions and 7 deletions
  1. +4
    -7
      bootstrap-jack2.sh
  2. +0
    -0
      patches/db/01_fix-including-winioctl-h-lowcase.patch
  3. +252
    -0
      patches/db/02_configure.patch
  4. +144
    -0
      patches/db/03_dbinc_atomic.h.patch

+ 4
- 7
bootstrap-jack2.sh View File

@@ -61,7 +61,8 @@ function build_custom_db() {
extraconfrules+=" --host=${TOOLCHAIN_PREFIX}"
fi
if [ "${MACOS}" -eq 1 ]; then
extraconfrules+=" --enable-posixmutexes"
# NOTE: this doesn't actually work..
extraconfrules+=" --with-mutex=x86_64/gcc-assembly"
fi
if [ "${WIN32}" -eq 1 ]; then
extraconfrules+=" --enable-mingw"
@@ -93,15 +94,11 @@ function build_custom_db() {
_postbuild
}

patch_file db "${DB_VERSION}" "src/dbinc/atomic.h" 's/__atomic_compare_exchange/__db_atomic_compare_exchange/'

# FIXME: db fails for macOS universal builds
if [ "${MACOS_UNIVERSAL}" -eq 0 ]; then
# FIXME: db fails to work properly under macOS, even if it builds fine
if [ "${MACOS}" -eq 0 ]; then
build_custom_db db "${DB_VERSION}" "--disable-java --disable-replication --disable-sql --disable-tcl"
fi

# --enable-posixmutexes --enable-compat185 --enable-cxx --enable-dbm --enable-stl

# ---------------------------------------------------------------------------------------------------------------------
# rtaudio (download, win32 only)



patches/db/db-1-fix-including-winioctl-h-lowcase.patch → patches/db/01_fix-including-winioctl-h-lowcase.patch View File


+ 252
- 0
patches/db/02_configure.patch View File

@@ -0,0 +1,252 @@
--- a/dist/configure.orig 2013-09-10 01:35:02.000000000 +1000
+++ b/dist/configure 2021-02-02 22:31:20.000000000 +1100
@@ -21275,7 +21275,7 @@
static lwp_cond_t ci = SHAREDCV;
lwp_mutex_t mutex = mi;
lwp_cond_t cond = ci;
- exit (
+ return (
_lwp_mutex_lock(&mutex) ||
_lwp_mutex_unlock(&mutex));
@@ -21305,7 +21305,7 @@
mutex_t mutex;
cond_t cond;
int type = USYNC_PROCESS;
- exit (
+ return (
mutex_init(&mutex, type, NULL) ||
cond_init(&cond, type, NULL) ||
mutex_lock(&mutex) ||
@@ -21335,7 +21335,7 @@
mutex_t mutex;
cond_t cond;
int type = USYNC_PROCESS;
- exit (
+ return (
mutex_init(&mutex, type, NULL) ||
cond_init(&cond, type, NULL) ||
mutex_lock(&mutex) ||
@@ -21370,7 +21370,7 @@
{
#if (defined(i386) || defined(__i386__)) && defined(__GNUC__)
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -21393,7 +21393,7 @@
{
#if (defined(x86_64) || defined(__x86_64__)) && defined(__GNUC__)
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -21445,7 +21445,7 @@
#if defined(__sparc__) && defined(__GNUC__)
asm volatile ("membar #StoreStore|#StoreLoad|#LoadStore");
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -21516,7 +21516,7 @@
msem_init(&x, 0);
msem_lock(&x, 0);
msem_unlock(&x, 0);
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -21548,7 +21548,7 @@
msem_init(&x, 0);
msem_lock(&x, 0);
msem_unlock(&x, 0);
- exit(0);
+ return (0);
;
return 0;
@@ -21600,7 +21600,7 @@
{
#if defined(__USLC__)
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -21731,7 +21731,7 @@
{
#if defined(__alpha) && defined(__DECC)
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -21756,7 +21756,7 @@
{
#if defined(__alpha) && defined(__GNUC__)
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -21781,7 +21781,7 @@
{
#if defined(__arm__) && defined(__GNUC__)
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -21806,7 +21806,7 @@
{
#if (defined(__mips) || defined(__mips__)) && defined(__GNUC__)
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -21831,7 +21831,7 @@
{
#if (defined(__hppa) || defined(__hppa__)) && defined(__GNUC__)
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -21856,7 +21856,7 @@
{
#if (defined(__powerpc__) || defined(__ppc__)) && defined(__GNUC__)
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -21881,7 +21881,7 @@
{
#if (defined(mc68020) || defined(sun3)) && defined(__GNUC__)
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -21906,7 +21906,7 @@
{
#if defined(__MVS__) && defined(__IBMC__)
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -21931,7 +21931,7 @@
{
#if defined(__s390__) && defined(__GNUC__)
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -21956,7 +21956,7 @@
{
#if defined(__ia64) && defined(__GNUC__)
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -21981,7 +21981,7 @@
{
#if defined(_UTS)
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -22464,9 +22464,9 @@
{
#if ((defined(i386) || defined(__i386__)) && defined(__GNUC__))
- exit(0);
+ return (0);
#elif ((defined(x86_64) || defined(__x86_64__)) && defined(__GNUC__))
- exit(0);
+ return (0);
#else
FAIL TO COMPILE/LINK
#endif
@@ -22491,7 +22491,7 @@
{
volatile unsigned val = 1;
- exit (atomic_inc_uint_nv(&val) != 2 ||
+ return (atomic_inc_uint_nv(&val) != 2 ||
atomic_dec_uint_nv(&val) != 1 ||
atomic_cas_32(&val, 1, 3) != 3);
@@ -24192,6 +24192,11 @@
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
+#include <stdio.h>
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+
int
main ()
{
@@ -24226,7 +24231,12 @@
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
- main() {
+#include <stdio.h>
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+
+ int main() {
$db_cv_seq_type l;
unsigned $db_cv_seq_type u;
char buf[100];
@@ -24309,6 +24319,9 @@
#include <fcntl.h>
#include <sys/mman.h>
#include <signal.h>
+ #if HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif
#define TEST_MMAP_BUFSIZE (16 * 1024)
#define TEST_MMAP_EXTENDSIZE (16 * 1024 * 1024)
@@ -24319,10 +24332,10 @@
int catch_sig(sig)
int sig;
{
- exit(1);
+ return (1);
}
- main() {
+ int main() {
const char *underlying;
unsigned gapsize;
char *base;

+ 144
- 0
patches/db/03_dbinc_atomic.h.patch View File

@@ -0,0 +1,144 @@
http://www.databaseusers.com/article/6047407/Bug%3A+Build+failure+on+Linux+with+clang+libc%2B%2B+(atomic+issues)
https://gist.githubusercontent.com/LnL7/5153b251fd525fe15de69b67e63a6075/raw/7778e9364679093a32dec2908656738e16b6bdcb/clang.patch

diff --git src/dbinc/atomic.h src/dbinc/atomic.h
index 6a858f7..9f338dc 100644
--- a/src/dbinc/atomic.h
+++ b/src/dbinc/atomic.h
@@ -70,7 +70,7 @@ typedef struct {
* These have no memory barriers; the caller must include them when necessary.
*/
#define atomic_read(p) ((p)->value)
-#define atomic_init(p, val) ((p)->value = (val))
+#define atomic_init_db(p, val) ((p)->value = (val))
#ifdef HAVE_ATOMIC_SUPPORT
@@ -144,7 +144,7 @@ typedef LONG volatile *interlocked_val;
#define atomic_inc(env, p) __atomic_inc(p)
#define atomic_dec(env, p) __atomic_dec(p)
#define atomic_compare_exchange(env, p, o, n) \
- __atomic_compare_exchange((p), (o), (n))
+ __atomic_compare_exchange_db((p), (o), (n))
static inline int __atomic_inc(db_atomic_t *p)
{
int temp;
@@ -176,7 +176,7 @@ static inline int __atomic_dec(db_atomic_t *p)
* http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html
* which configure could be changed to use.
*/
-static inline int __atomic_compare_exchange(
+static inline int __atomic_compare_exchange_db(
db_atomic_t *p, atomic_value_t oldval, atomic_value_t newval)
{
atomic_value_t was;
@@ -206,7 +206,7 @@ static inline int __atomic_compare_exchange(
#define atomic_dec(env, p) (--(p)->value)
#define atomic_compare_exchange(env, p, oldval, newval) \
(DB_ASSERT(env, atomic_read(p) == (oldval)), \
- atomic_init(p, (newval)), 1)
+ atomic_init_db(p, (newval)), 1)
#else
#define atomic_inc(env, p) __atomic_inc(env, p)
#define atomic_dec(env, p) __atomic_dec(env, p)
diff --git src/mp/mp_fget.c src/mp/mp_fget.c
index 16de695..d0dcc29 100644
--- a/src/mp/mp_fget.c
+++ b/src/mp/mp_fget.c
@@ -649,7 +649,7 @@ alloc: /* Allocate a new buffer header and data space. */
/* Initialize enough so we can call __memp_bhfree. */
alloc_bhp->flags = 0;
- atomic_init(&alloc_bhp->ref, 1);
+ atomic_init_db(&alloc_bhp->ref, 1);
#ifdef DIAGNOSTIC
if ((uintptr_t)alloc_bhp->buf & (sizeof(size_t) - 1)) {
__db_errx(env, DB_STR("3025",
@@ -955,7 +955,7 @@ alloc: /* Allocate a new buffer header and data space. */
MVCC_MPROTECT(bhp->buf, mfp->pagesize,
PROT_READ);
- atomic_init(&alloc_bhp->ref, 1);
+ atomic_init_db(&alloc_bhp->ref, 1);
MUTEX_LOCK(env, alloc_bhp->mtx_buf);
alloc_bhp->priority = bhp->priority;
alloc_bhp->pgno = bhp->pgno;
diff --git src/mp/mp_mvcc.c src/mp/mp_mvcc.c
index 770bad8..e28cce0 100644
--- a/src/mp/mp_mvcc.c
+++ b/src/mp/mp_mvcc.c
@@ -276,7 +276,7 @@ __memp_bh_freeze(dbmp, infop, hp, bhp, need_frozenp)
#else
memcpy(frozen_bhp, bhp, SSZA(BH, buf));
#endif
- atomic_init(&frozen_bhp->ref, 0);
+ atomic_init_db(&frozen_bhp->ref, 0);
if (mutex != MUTEX_INVALID)
frozen_bhp->mtx_buf = mutex;
else if ((ret = __mutex_alloc(env, MTX_MPOOL_BH,
@@ -428,7 +428,7 @@ __memp_bh_thaw(dbmp, infop, hp, frozen_bhp, alloc_bhp)
#endif
alloc_bhp->mtx_buf = mutex;
MUTEX_LOCK(env, alloc_bhp->mtx_buf);
- atomic_init(&alloc_bhp->ref, 1);
+ atomic_init_db(&alloc_bhp->ref, 1);
F_CLR(alloc_bhp, BH_FROZEN);
}
diff --git src/mp/mp_region.c src/mp/mp_region.c
index 4952030..47645f8 100644
--- a/src/mp/mp_region.c
+++ b/src/mp/mp_region.c
@@ -245,7 +245,7 @@ __memp_init(env, dbmp, reginfo_off, htab_buckets, max_nreg)
MTX_MPOOL_FILE_BUCKET, 0, &htab[i].mtx_hash)) != 0)
return (ret);
SH_TAILQ_INIT(&htab[i].hash_bucket);
- atomic_init(&htab[i].hash_page_dirty, 0);
+ atomic_init_db(&htab[i].hash_page_dirty, 0);
}
/*
@@ -302,7 +302,7 @@ no_prealloc:
} else
hp->mtx_hash = mtx_base + (i % dbenv->mp_mtxcount);
SH_TAILQ_INIT(&hp->hash_bucket);
- atomic_init(&hp->hash_page_dirty, 0);
+ atomic_init_db(&hp->hash_page_dirty, 0);
#ifdef HAVE_STATISTICS
hp->hash_io_wait = 0;
hp->hash_frozen = hp->hash_thawed = hp->hash_frozen_freed = 0;
diff --git src/mutex/mut_method.c src/mutex/mut_method.c
index 09353b0..177353c 100644
--- a/src/mutex/mut_method.c
+++ b/src/mutex/mut_method.c
@@ -474,7 +474,7 @@ atomic_compare_exchange(env, v, oldval, newval)
MUTEX_LOCK(env, mtx);
ret = atomic_read(v) == oldval;
if (ret)
- atomic_init(v, newval);
+ atomic_init_db(v, newval);
MUTEX_UNLOCK(env, mtx);
return (ret);
diff --git src/mutex/mut_tas.c src/mutex/mut_tas.c
index 106b161..fc4de9d 100644
--- a/src/mutex/mut_tas.c
+++ b/src/mutex/mut_tas.c
@@ -47,7 +47,7 @@ __db_tas_mutex_init(env, mutex, flags)
#ifdef HAVE_SHARED_LATCHES
if (F_ISSET(mutexp, DB_MUTEX_SHARED))
- atomic_init(&mutexp->sharecount, 0);
+ atomic_init_db(&mutexp->sharecount, 0);
else
#endif
if (MUTEX_INIT(&mutexp->tas)) {
@@ -536,7 +536,7 @@ __db_tas_mutex_unlock(env, mutex)
F_CLR(mutexp, DB_MUTEX_LOCKED);
/* Flush flag update before zeroing count */
MEMBAR_EXIT();
- atomic_init(&mutexp->sharecount, 0);
+ atomic_init_db(&mutexp->sharecount, 0);
} else {
DB_ASSERT(env, sharecount > 0);
MEMBAR_EXIT();

Loading…
Cancel
Save