db: fix clang build

* patch to avoid using name atomic_init
** from https://github.com/bitcoin/bitcoin/blob/master/depends/patches/bdb/clang_cxx_11.patch
* patch to hide macro "store" from libc++ headers
* hacking around autotools madness
This commit is contained in:
Jeremy Drake 2021-08-30 12:53:25 -07:00
parent f7305383d6
commit f2d027a555
4 changed files with 183 additions and 4 deletions

View File

@ -5,7 +5,7 @@ _realname=db
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=6.0.19
pkgrel=4
pkgrel=5
pkgdesc="The Berkeley DB embedded database system (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
@ -14,14 +14,26 @@ license=('custom')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
source=(http://download.oracle.com/berkeley-db/db-${pkgver}.tar.gz
mingw.patch)
mingw.patch
clang_cxx_11.patch
clang_libc++_store.patch)
sha256sums=('2917c28f60903908c2ca4587ded1363b812c4e830a5326aaa77c9879d13ae18e'
'009ce8f8bf5fd18ce63a1c4d3ee972374d5f968754b028d4017d546755d3de86')
'62981c4064efccbe4219406316151a5266258c270b621f3b3faff39108978d02'
'd7bc0d56fc20f7e71dca5b4bee21ef296cb6cd4d835ff9789dc61c11f3977325'
'69be5d13b1377a0bebe767789afc1e9ab34fd6c15c5adcaeec2d5953508ae260')
prepare()
{
cd ${srcdir}/${_realname}-${pkgver}
patch -p1 -i ${srcdir}/mingw.patch
patch -Nbp1 -i ${srcdir}/mingw.patch
patch -Nbp1 -i ${srcdir}/clang_cxx_11.patch
patch -Nbp1 -i ${srcdir}/clang_libc++_store.patch
pushd dist
autoreconf -fiv -I aclocal -I aclocal_java
# they have an extra sed in here that we need
./s_config
popd
}
build() {

View File

@ -0,0 +1,120 @@
commit 3311d68f11d1697565401eee6efc85c34f022ea7
Author: fanquake <fanquake@gmail.com>
Date: Mon Aug 17 20:03:56 2020 +0800
Fix C++11 compatibility
diff --git a/src/dbinc/atomic.h b/src/dbinc/atomic.h
index 0034dcc..7c11d4a 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
diff --git a/src/mp/mp_fget.c b/src/mp/mp_fget.c
index 5fdee5a..0b75f57 100644
--- a/src/mp/mp_fget.c
+++ b/src/mp/mp_fget.c
@@ -617,7 +617,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,
@@ -911,7 +911,7 @@ alloc: /* Allocate a new buffer header and data space. */
MVCC_MPROTECT(bhp->buf, mfp->stat.st_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 a/src/mp/mp_mvcc.c b/src/mp/mp_mvcc.c
index 34467d2..f05aa0c 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 a/src/mp/mp_region.c b/src/mp/mp_region.c
index e6cece9..ddbe906 100644
--- a/src/mp/mp_region.c
+++ b/src/mp/mp_region.c
@@ -224,7 +224,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);
}
/*
@@ -269,7 +269,7 @@ __memp_init(env, dbmp, reginfo_off, htab_buckets, max_nreg)
hp->mtx_hash = (mtx_base == MUTEX_INVALID) ? MUTEX_INVALID :
mtx_base + i;
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 a/src/mutex/mut_method.c b/src/mutex/mut_method.c
index 2588763..5c6d516 100644
--- a/src/mutex/mut_method.c
+++ b/src/mutex/mut_method.c
@@ -426,7 +426,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 a/src/mutex/mut_tas.c b/src/mutex/mut_tas.c
index f3922e0..e40fcdf 100644
--- a/src/mutex/mut_tas.c
+++ b/src/mutex/mut_tas.c
@@ -46,7 +46,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)) {
@@ -486,7 +486,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();

View File

@ -0,0 +1,21 @@
--- db-6.0.19/src/dbinc/db_cxx.in.orig 2021-08-30 11:16:06.008802400 -0700
+++ db-6.0.19/src/dbinc/db_cxx.in 2021-08-30 11:18:04.727661400 -0700
@@ -48,6 +48,9 @@
// Forward declarations
//
+#pragma push_macro("store")
+#undef store
+
#include <stdarg.h>
@cxx_have_stdheaders@
@@ -61,6 +64,8 @@
#define __DB_STD(x) x
#endif
+#pragma pop_macro("store")
+
#include "db.h"
class Db; // forward

View File

@ -30,6 +30,32 @@ diff -ruN db-5.3.28.orig/dist/configure.ac db-5.3.28/dist/configure.ac
*) CLASSPATH=".:$CLASSPATH";;
esac
export CLASSPATH
@@ -489,12 +489,12 @@
OSDIR=os_windows
PATH_SEPARATOR="\\\\/:"
- AC_DEFINE(DB_WIN32)
- AC_DEFINE(STDC_HEADERS)
+ AC_DEFINE(DB_WIN32, [], [Description])
+ AC_DEFINE(STDC_HEADERS, [], [Description])
else
OSDIR=os
PATH_SEPARATOR="/"
- AC_DEFINE(HAVE_SYSTEM_INCLUDE_FILES)
+ AC_DEFINE(HAVE_SYSTEM_INCLUDE_FILES, [], [Description])
fi
# Optional SQL API.
--- db-6.0.19/dist/aclocal_java/ac_jni_include_dirs.m4.orig 2021-08-30 12:17:27.639455100 -0700
+++ db-6.0.19/dist/aclocal_java/ac_jni_include_dirs.m4 2021-08-30 12:17:43.422456700 -0700
@@ -76,6 +76,7 @@
aix*) _JNI_INC_SUBDIRS="aix";;
bsdi*) _JNI_INC_SUBDIRS="bsdos";;
cygwin*) _JNI_INC_SUBDIRS="win32";;
+ mingw*) _JNI_INC_SUBDIRS="win32";;
freebsd*) _JNI_INC_SUBDIRS="freebsd";;
hp*) _JNI_INC_SUBDIRS="hp-ux";;
linux*) _JNI_INC_SUBDIRS="linux genunix";;
diff -ruN db-5.3.28.orig/dist/Makefile.in db-5.3.28/dist/Makefile.in
--- db-5.3.28.orig/dist/Makefile.in 2013-09-09 17:35:02.000000000 +0200
+++ db-5.3.28/dist/Makefile.in 2014-03-29 21:00:05.731463900 +0100