sys-libs/db: fix more modern C configure errors

even with a patch to fix various configure macros, feature autodetection
still misfired in one case due to yet another missing header.

Fix by backporting the same header from upstream's fix in SLOT="6.0" and
realign a previous fix to use the header ordering from upstream, for
diffing purposes.

Closes: https://bugs.gentoo.org/898622
Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
This commit is contained in:
Eli Schwartz
2024-11-17 22:57:05 -05:00
parent 3ac3a468cc
commit f6ae391fac
2 changed files with 568 additions and 0 deletions

View File

@@ -0,0 +1,240 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
inherit autotools db flag-o-matic multilib-minimal toolchain-funcs
#Number of official patches
#PATCHNO=`echo ${PV}|sed -e "s,\(.*_p\)\([0-9]*\),\2,"`
PATCHNO="${PV/*.*.*_p}"
if [[ ${PATCHNO} == "${PV}" ]] ; then
MY_PV="${PV}"
MY_P="${P}"
PATCHNO=0
else
MY_PV="${PV/_p${PATCHNO}}"
MY_P="${PN}-${MY_PV}"
fi
RESTRICT="!test? ( test )"
S_BASE="${WORKDIR}/${MY_P}"
S="${S_BASE}/build_unix"
DESCRIPTION="Oracle Berkeley DB"
HOMEPAGE="https://www.oracle.com/technetwork/database/database-technologies/berkeleydb/overview/index.html"
SRC_URI="https://download.oracle.com/berkeley-db/${MY_P}.tar.gz"
for (( i=1 ; i<=${PATCHNO} ; i++ )) ; do
SRC_URI+=" https://www.oracle.com/technology/products/berkeley-db/db/update/${MY_PV}/patch.${MY_PV}.${i}"
done
LICENSE="Sleepycat"
SLOT="$(ver_cut 1-2)"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
IUSE="doc cxx tcl test"
REQUIRED_USE="test? ( tcl )"
# the entire testsuite needs the TCL functionality
DEPEND="tcl? ( >=dev-lang/tcl-8.5.15-r1:0=[${MULTILIB_USEDEP}] )
test? ( >=dev-lang/tcl-8.5.15-r1:0=[${MULTILIB_USEDEP}] )"
RDEPEND="tcl? ( >=dev-lang/tcl-8.5.15-r1:0=[${MULTILIB_USEDEP}] )"
# bug #841698
# Need binutils for tc-ld-force-bfd
BDEPEND="
dev-build/autoconf-archive
sys-devel/binutils:*
"
MULTILIB_WRAPPED_HEADERS=(
/usr/include/db${SLOT}/db.h
)
PATCHES=(
# sqlite configure call has an extra leading ..
# upstreamed:5.2.36, missing in 5.3.x
"${FILESDIR}"/${PN}-5.2.28-sqlite-configure-path.patch
# The upstream testsuite copies .lib and the binaries for each parallel test
# core, ~300MB each. This patch uses links instead, saves a lot of space.
"${FILESDIR}"/${PN}-6.0.20-test-link.patch
# Needed when compiling with clang
"${FILESDIR}"/${PN}-5.1.29-rename-atomic-compare-exchange.patch
"${FILESDIR}"/${PN}-5.3.28-modern-c.patch
"${FILESDIR}"/${PN}-4.8.30-tls-configure.patch
)
src_prepare() {
cd "${S_BASE}" || die
for (( i=1 ; i<=${PATCHNO} ; i++ ))
do
eapply -p0 "${DISTDIR}"/patch."${MY_PV}"."${i}"
done
default
# Upstream release script grabs the dates when the script was run, so lets
# end-run them to keep the date the same.
export REAL_DB_RELEASE_DATE="$(awk \
'/^DB_VERSION_STRING=/{ gsub(".*\\(|\\).*","",$0); print $0; }' \
"${S_BASE}"/dist/configure)"
sed -r \
-e "/^DB_RELEASE_DATE=/s~=.*~='${REAL_DB_RELEASE_DATE}'~g" \
-i dist/RELEASE || die
cd dist || die
rm aclocal/libtool.m4 || die
sed \
-e '/AC_PROG_LIBTOOL$/aLT_OUTPUT' \
-i configure.ac || die
sed \
-e '/^AC_PATH_TOOL/s/ sh, none/ bash, none/' \
-i aclocal/programs.m4 || die
AT_M4DIR="aclocal" eautoreconf
# They do autoconf and THEN replace the version variables :(
. ./RELEASE
local v ev
for v in \
DB_VERSION_{FAMILY,LETTER,RELEASE,MAJOR,MINOR} \
DB_VERSION_{PATCH,FULL,UNIQUE_NAME,STRING,FULL_STRING} \
DB_VERSION \
DB_RELEASE_DATE ; do
ev="__EDIT_${v}__"
sed -e "s/${ev}/${!v}/g" -i configure || die
done
# This is a false positive skip in the tests as the test-reviewer code
# looks for 'Skipping\s'
sed \
-e '/db_repsite/s,Skipping:,Skipping,g' \
-i "${S_BASE}"/test/tcl/reputils.tcl || die
}
src_configure() {
# Force bfd before calling multilib_toolchain_setup
tc-ld-force-bfd #470634 #729510
multilib-minimal_src_configure
}
multilib_src_configure() {
local myconf=(
# sql_compat will cause a collision with sqlite3
#--enable-sql_compat
# Don't --enable-sql* because we don't want to use bundled sqlite.
# See Gentoo bug #605688
--enable-compat185
--enable-dbm
--enable-o_direct
--without-uniquename
--disable-sql
--disable-sql_codegen
--disable-sql_compat
--disable-static
--disable-java
$([[ ${ABI} == amd64 ]] && echo --with-mutex=x86/gcc-assembly)
$(use_enable cxx)
$(use_enable cxx stl)
$(use_enable test)
)
# compilation with -O0 fails on amd64, see bug #171231
if [[ ${ABI} == amd64 ]]; then
local CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}"
replace-flags -O0 -O2
is-flagq -O[s123] || append-flags -O2
fi
# Add linker versions to the symbols. Easier to do, and safer than header file
# mumbo jumbo.
append-ldflags -Wl,--default-symver
# Bug #270851: test needs TCL support
if use tcl || use test ; then
myconf+=(
--enable-tcl
--with-tcl="${EPREFIX}/usr/$(get_libdir)"
)
else
myconf+=(--disable-tcl )
fi
ECONF_SOURCE="${S_BASE}"/dist \
STRIP="true" \
econf "${myconf[@]}"
# The embedded assembly on ARM does not work on newer hardware
# so you CANNOT use --with-mutex=ARM/gcc-assembly anymore.
# Specifically, it uses the SWPB op, which was deprecated:
# http://www.keil.com/support/man/docs/armasm/armasm_dom1361289909499.htm
# The op ALSO cannot be used in ARM-Thumb mode.
# Trust the compiler instead.
# >=db-6.1 uses LDREX instead.
}
multilib_src_install() {
emake DESTDIR="${D}" install
db_src_install_headerslot
db_src_install_usrlibcleanup
}
multilib_src_install_all() {
db_src_install_usrbinslot
db_src_install_doc
dodir /usr/sbin
# This file is not always built, and no longer exists as of db-4.8
if [[ -f "${ED}"/usr/bin/berkeley_db_svc ]] ; then
mv "${ED}"/usr/bin/berkeley_db_svc \
"${ED}"/usr/sbin/berkeley_db"${SLOT/./}"_svc || die
fi
# no static libraries
find "${ED}" -name '*.la' -delete || die
}
pkg_postinst() {
multilib_foreach_abi db_fix_so
}
pkg_postrm() {
multilib_foreach_abi db_fix_so
}
src_test() {
# db_repsite is impossible to build, as upstream strips those sources.
# db_repsite is used directly in the setup_site_prog,
# setup_site_prog is called from open_site_prog
# which is called only from tests in the multi_repmgr group.
#sed -ri \
# -e '/set subs/s,multi_repmgr,,g' \
# "${S_BASE}/test/testparams.tcl"
sed -r \
-e '/multi_repmgr/d' \
-i "${S_BASE}/test/tcl/test.tcl" || die
# This is the only failure in 5.2.28 so far, and looks like a false positive.
# Repmgr018 (btree): Test of repmgr stats.
# Repmgr018.a: Start a master.
# Repmgr018.b: Start a client.
# Repmgr018.c: Run some transactions at master.
# Rep_test: btree 20 key/data pairs starting at 0
# Rep_test.a: put/get loop
# FAIL:07:05:59 (00:00:00) perm_no_failed_stat: expected 0, got 1
sed -r \
-e '/set parms.*repmgr018/d' \
-e 's/repmgr018//g' \
-i "${S_BASE}/test/tcl/test.tcl" || die
multilib-minimal_src_test
}
multilib_src_test() {
multilib_is_native_abi || return
S="${BUILD_DIR}" db_src_test
}

View File

@@ -0,0 +1,328 @@
https://bugs.gentoo.org/883413
--- a/dist/aclocal/clock.m4
+++ b/dist/aclocal/clock.m4
@@ -20,12 +20,14 @@ esac
# existence to mean the clock really exists.
AC_CACHE_CHECK([for clock_gettime monotonic clock], db_cv_clock_monotonic, [
AC_TRY_RUN([
+#include <time.h>
#include <sys/time.h>
-main() {
+int main(void) {
struct timespec t;
return (clock_gettime(CLOCK_MONOTONIC, &t) != 0);
}], db_cv_clock_monotonic=yes, db_cv_clock_monotonic=no,
AC_TRY_LINK([
+#include <time.h>
#include <sys/time.h>], [
struct timespec t;
clock_gettime(CLOCK_MONOTONIC, &t);
--- a/dist/aclocal/mmap.m4
+++ b/dist/aclocal/mmap.m4
@@ -28,8 +28,10 @@ if test "$mmap_ok" = "yes" ; then
/* Not all these includes are needed, but the minimal set varies from
* system to system.
*/
+ #include <stdlib.h>
#include <stdio.h>
#include <string.h>
+ #include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -42,13 +44,12 @@ if test "$mmap_ok" = "yes" ; then
#define MAP_FAILED (-1)
#endif
- int catch_sig(sig)
- int sig;
+ void catch_sig(int sig)
{
exit(1);
}
- main() {
+ int main(void) {
const char *underlying;
unsigned gapsize;
char *base;
--- a/dist/aclocal/mutex.m4
+++ b/dist/aclocal/mutex.m4
@@ -5,7 +5,7 @@ AC_DEFUN(AM_PTHREADS_SHARED, [
AC_TRY_RUN([
#include <stdlib.h>
#include <pthread.h>
-main() {
+int main(void) {
pthread_cond_t cond;
pthread_mutex_t mutex;
pthread_condattr_t condattr;
@@ -49,7 +49,7 @@ AC_DEFUN(AM_PTHREADS_PRIVATE, [
AC_TRY_RUN([
#include <stdlib.h>
#include <pthread.h>
-main() {
+int main(void) {
pthread_cond_t cond;
pthread_mutex_t mutex;
pthread_condattr_t condattr;
@@ -89,7 +89,7 @@ AC_DEFUN(AM_PTHREADS_CONDVAR_DUPINITCHK, [
AC_TRY_RUN([
#include <stdlib.h>
#include <pthread.h>
-main() {
+int main(void) {
pthread_cond_t cond;
pthread_condattr_t condattr;
exit(pthread_condattr_init(&condattr) ||
@@ -110,7 +110,7 @@ AC_DEFUN(AM_PTHREADS_RWLOCKVAR_DUPINITCHK, [
AC_TRY_RUN([
#include <stdlib.h>
#include <pthread.h>
-main() {
+int main(void) {
pthread_rwlock_t rwlock;
pthread_rwlockattr_t rwlockattr;
exit(pthread_rwlockattr_init(&rwlockattr) ||
@@ -227,6 +227,7 @@ if test "$db_cv_mutex" = no; then
# LWP threads: _lwp_XXX
if test "$db_cv_mutex" = no; then
AC_TRY_LINK([
+ #include <stdlib.h>
#include <synch.h>],[
static lwp_mutex_t mi = SHAREDMUTEX;
static lwp_cond_t ci = SHAREDCV;
@@ -243,6 +244,7 @@ if test "$db_cv_mutex" = no; then
LIBS="$LIBS -lthread"
AC_TRY_LINK([
#include <thread.h>
+ #include <stdlib.h>
#include <synch.h>],[
mutex_t mutex;
cond_t cond;
@@ -258,6 +260,7 @@ if test "$db_cv_mutex" = no; then
if test "$db_cv_mutex" = no -o "$db_cv_mutex" = ui_only; then
AC_TRY_LINK([
#include <thread.h>
+ #include <stdlib.h>
#include <synch.h>],[
mutex_t mutex;
cond_t cond;
@@ -282,7 +285,7 @@ if test "$db_cv_mutex" = no; then
# x86/gcc: FreeBSD, NetBSD, BSD/OS, Linux
AC_TRY_COMPILE(,[
#if (defined(i386) || defined(__i386__)) && defined(__GNUC__)
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -291,7 +294,7 @@ if test "$db_cv_mutex" = no; then
# x86_64/gcc: FreeBSD, NetBSD, BSD/OS, Linux
AC_TRY_COMPILE(,[
#if (defined(x86_64) || defined(__x86_64__)) && defined(__GNUC__)
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -314,7 +317,7 @@ if test "$db_cv_mutex" = no; then
AC_TRY_COMPILE(,[
#if defined(__sparc__) && defined(__GNUC__)
asm volatile ("membar #StoreStore|#StoreLoad|#LoadStore");
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -356,7 +359,7 @@ AC_TRY_LINK([
msem_init(&x, 0);
msem_lock(&x, 0);
msem_unlock(&x, 0);
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -373,7 +376,7 @@ AC_TRY_LINK([
msem_init(&x, 0);
msem_lock(&x, 0);
msem_unlock(&x, 0);
- exit(0);
+ return 0;
], [db_cv_mutex=UNIX/msem_init])
fi
@@ -395,7 +398,7 @@ fi
if test "$db_cv_mutex" = no; then
AC_TRY_COMPILE(,[
#if defined(__USLC__)
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -452,7 +455,7 @@ fi
if test "$db_cv_mutex" = no; then
AC_TRY_COMPILE(,[
#if defined(__alpha) && defined(__DECC)
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -463,7 +466,7 @@ fi
if test "$db_cv_mutex" = no; then
AC_TRY_COMPILE(,[
#if defined(__alpha) && defined(__GNUC__)
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -474,7 +477,7 @@ fi
if test "$db_cv_mutex" = no; then
AC_TRY_COMPILE(,[
#if defined(__arm__) && defined(__GNUC__)
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -485,7 +488,7 @@ fi
if test "$db_cv_mutex" = no; then
AC_TRY_COMPILE(,[
#if (defined(__mips) || defined(__mips__)) && defined(__GNUC__)
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -496,7 +499,7 @@ fi
if test "$db_cv_mutex" = no; then
AC_TRY_COMPILE(,[
#if (defined(__hppa) || defined(__hppa__)) && defined(__GNUC__)
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -507,7 +510,7 @@ fi
if test "$db_cv_mutex" = no; then
AC_TRY_COMPILE(,[
#if (defined(__powerpc__) || defined(__ppc__)) && defined(__GNUC__)
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -518,7 +521,7 @@ fi
if test "$db_cv_mutex" = no; then
AC_TRY_COMPILE(,[
#if (defined(mc68020) || defined(sun3)) && defined(__GNUC__)
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -529,7 +532,7 @@ fi
if test "$db_cv_mutex" = no; then
AC_TRY_COMPILE(,[
#if defined(__MVS__) && defined(__IBMC__)
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -540,7 +543,7 @@ fi
if test "$db_cv_mutex" = no; then
AC_TRY_COMPILE(,[
#if defined(__s390__) && defined(__GNUC__)
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -551,7 +554,7 @@ fi
if test "$db_cv_mutex" = no; then
AC_TRY_COMPILE(,[
#if defined(__ia64) && defined(__GNUC__)
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -562,7 +565,7 @@ fi
if test "$db_cv_mutex" = no; then
AC_TRY_COMPILE(,[
#if defined(_UTS)
- exit(0);
+ return 0;
#else
FAIL TO COMPILE/LINK
#endif
@@ -910,9 +913,9 @@ fi
if test "$db_cv_atomic" = no; then
AC_TRY_COMPILE(,[
#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
@@ -921,6 +924,7 @@ fi
if test "$db_cv_atomic" = no; then
AC_TRY_LINK([
+#include <stdlib.h>
#include <sys/atomic.h>],[
volatile unsigned val = 1;
exit (atomic_inc_uint_nv(&val) != 2 ||
--- a/dist/aclocal/sequence.m4
+++ b/dist/aclocal/sequence.m4
@@ -43,7 +43,9 @@ AC_DEFUN(AM_SEQUENCE_CONFIGURE, [
# test, which won't test for the appropriate printf format strings.
if test "$db_cv_build_sequence" = "yes"; then
AC_TRY_RUN([
- main() {
+ #include <stdio.h>
+ #include <string.h>
+ int main(void) {
$db_cv_seq_type l;
unsigned $db_cv_seq_type u;
char buf@<:@100@:>@;
@@ -59,7 +61,10 @@ AC_DEFUN(AM_SEQUENCE_CONFIGURE, [
return (1);
return (0);
}],, [db_cv_build_sequence="no"],
- AC_TRY_LINK(,[
+ AC_TRY_LINK([
+ #include <stdio.h>
+ #include <string.h>
+ ],[
$db_cv_seq_type l;
unsigned $db_cv_seq_type u;
char buf@<:@100@:>@;
--- a/dist/aclocal/types.m4
+++ b/dist/aclocal/types.m4
@@ -69,7 +69,7 @@ AC_SUBST(stdint_h_decl)
AC_MSG_CHECKING(for stdint.h)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <stdint.h>
- int main() {
+ int main(void) {
uint_least8_t x=0;
return x;
}])],[AC_MSG_RESULT(yes)
@@ -77,7 +77,7 @@ if test "$db_cv_cxx" = "yes"; then
AC_MSG_CHECKING([if stdint.h can be used by C++])
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <stdint.h>
- int main() {
+ int main(void) {
uint_least8_t x=0;
return x;
}])],[AC_MSG_RESULT(yes)