db: fix build with clang 16
The configure scripts frequently use `main` returning an implicit `int`, which causes spurious failures when CC is clang 16+. This is fixed by patching the provided macros and regenerating the scripts with autoreconfHook, though it requires some manual processing (see below). The upstream `configure.ac` is written in such a way that it requires fixups and post-processing. * Fixups are required because the original build process just cats the macros together into one file. When `aclocal` is run, it does not pick up all of them. This is worked around by catting the missing macros to a file that is picked up by autoreconfHook. * Post-processing is required to populate the version information. This is done in a subshell to avoid polluting the environment with the contents of `RELEASE`. Otherwise, the build will fail because the version C macros it expects will not be defined.
This commit is contained in:
parent
394e69c186
commit
6302ba07e3
@ -139,3 +139,67 @@ index f3922e0..e40fcdf 100644
|
||||
} else {
|
||||
DB_ASSERT(env, sharecount > 0);
|
||||
MEMBAR_EXIT();
|
||||
diff -ur a/dist/aclocal/clock.m4 b/dist/aclocal/clock.m4
|
||||
--- a/dist/aclocal/clock.m4 1969-12-31 19:00:01.000000000 -0500
|
||||
+++ b/dist/aclocal/clock.m4 2023-06-05 19:14:02.007080500 -0400
|
||||
@@ -21,6 +21,7 @@
|
||||
AC_CACHE_CHECK([for clock_gettime monotonic clock], db_cv_clock_monotonic, [
|
||||
AC_TRY_RUN([
|
||||
#include <sys/time.h>
|
||||
+int
|
||||
main() {
|
||||
struct timespec t;
|
||||
return (clock_gettime(CLOCK_MONOTONIC, &t) != 0);
|
||||
diff -ur a/dist/aclocal/mutex.m4 b/dist/aclocal/mutex.m4
|
||||
--- a/dist/aclocal/mutex.m4 1969-12-31 19:00:01.000000000 -0500
|
||||
+++ b/dist/aclocal/mutex.m4 2023-06-05 19:14:47.214158196 -0400
|
||||
@@ -4,6 +4,7 @@
|
||||
AC_DEFUN(AM_PTHREADS_SHARED, [
|
||||
AC_TRY_RUN([
|
||||
#include <pthread.h>
|
||||
+int
|
||||
main() {
|
||||
pthread_cond_t cond;
|
||||
pthread_mutex_t mutex;
|
||||
@@ -46,6 +47,7 @@
|
||||
AC_DEFUN(AM_PTHREADS_PRIVATE, [
|
||||
AC_TRY_RUN([
|
||||
#include <pthread.h>
|
||||
+int
|
||||
main() {
|
||||
pthread_cond_t cond;
|
||||
pthread_mutex_t mutex;
|
||||
diff -ur a/dist/aclocal/sequence.m4 b/dist/aclocal/sequence.m4
|
||||
--- a/dist/aclocal/sequence.m4 1969-12-31 19:00:01.000000000 -0500
|
||||
+++ b/dist/aclocal/sequence.m4 2023-06-05 19:14:02.007869956 -0400
|
||||
@@ -43,6 +43,9 @@
|
||||
# test, which won't test for the appropriate printf format strings.
|
||||
if test "$db_cv_build_sequence" = "yes"; then
|
||||
AC_TRY_RUN([
|
||||
+ #include <string.h>
|
||||
+ #include <stdio.h>
|
||||
+ int
|
||||
main() {
|
||||
$db_cv_seq_type l;
|
||||
unsigned $db_cv_seq_type u;
|
||||
@@ -59,7 +62,9 @@
|
||||
return (1);
|
||||
return (0);
|
||||
}],, [db_cv_build_sequence="no"],
|
||||
- AC_TRY_LINK(,[
|
||||
+ AC_TRY_LINK([
|
||||
+ #include <string.h>
|
||||
+ #include <stdio.h>],[
|
||||
$db_cv_seq_type l;
|
||||
unsigned $db_cv_seq_type u;
|
||||
char buf@<:@100@:>@;
|
||||
diff -ur a/dist/RELEASE b/dist/RELEASE
|
||||
--- a/dist/RELEASE 1969-12-31 19:00:01.000000000 -0500
|
||||
+++ b/dist/RELEASE 2023-07-02 17:32:34.703953049 -0400
|
||||
@@ -7,5 +7,5 @@
|
||||
|
||||
DB_VERSION_UNIQUE_NAME=`printf "_%d%03d" $DB_VERSION_MAJOR $DB_VERSION_MINOR`
|
||||
|
||||
-DB_RELEASE_DATE=`date "+%B %e, %Y"`
|
||||
+DB_RELEASE_DATE="April 9, 2010"
|
||||
DB_VERSION_STRING="Berkeley DB $DB_VERSION: ($DB_RELEASE_DATE)"
|
||||
|
@ -139,3 +139,111 @@ index 106b161..fc4de9d 100644
|
||||
} else {
|
||||
DB_ASSERT(env, sharecount > 0);
|
||||
MEMBAR_EXIT();
|
||||
diff -ur a/dist/aclocal/clock.m4 b/dist/aclocal/clock.m4
|
||||
--- a/dist/aclocal/clock.m4 1969-12-31 19:00:01.000000000 -0500
|
||||
+++ b/dist/aclocal/clock.m4 2023-06-05 19:14:02.007080500 -0400
|
||||
@@ -21,6 +21,7 @@
|
||||
AC_CACHE_CHECK([for clock_gettime monotonic clock], db_cv_clock_monotonic, [
|
||||
AC_TRY_RUN([
|
||||
#include <sys/time.h>
|
||||
+int
|
||||
main() {
|
||||
struct timespec t;
|
||||
return (clock_gettime(CLOCK_MONOTONIC, &t) != 0);
|
||||
diff -ur a/dist/aclocal/mmap.m4 b/dist/aclocal/mmap.m4
|
||||
--- a/dist/aclocal/mmap.m4 1969-12-31 19:00:01.000000000 -0500
|
||||
+++ b/dist/aclocal/mmap.m4 2023-06-05 19:14:02.007323624 -0400
|
||||
@@ -29,6 +29,8 @@
|
||||
* system to system.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
+ #include <stdlib.h>
|
||||
+ #include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -42,12 +44,13 @@
|
||||
#define MAP_FAILED (-1)
|
||||
#endif
|
||||
|
||||
- int catch_sig(sig)
|
||||
+ void catch_sig(sig)
|
||||
int sig;
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
|
||||
+ int
|
||||
main() {
|
||||
const char *underlying;
|
||||
unsigned gapsize;
|
||||
@@ -88,8 +91,8 @@
|
||||
return (4);
|
||||
}
|
||||
|
||||
- (void) signal(SIGSEGV, catch_sig);
|
||||
- (void) signal(SIGBUS, catch_sig);
|
||||
+ (void) signal(SIGSEGV, &catch_sig);
|
||||
+ (void) signal(SIGBUS, &catch_sig);
|
||||
|
||||
for (i = sizeof(buf); i < total_size; i += gapsize)
|
||||
base[i] = 'A';
|
||||
diff -ur a/dist/aclocal/mutex.m4 b/dist/aclocal/mutex.m4
|
||||
--- a/dist/aclocal/mutex.m4 1969-12-31 19:00:01.000000000 -0500
|
||||
+++ b/dist/aclocal/mutex.m4 2023-06-05 19:14:47.214158196 -0400
|
||||
@@ -5,6 +5,7 @@
|
||||
AC_TRY_RUN([
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
+int
|
||||
main() {
|
||||
pthread_cond_t cond;
|
||||
pthread_mutex_t mutex;
|
||||
@@ -49,6 +50,7 @@
|
||||
AC_TRY_RUN([
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
+int
|
||||
main() {
|
||||
pthread_cond_t cond;
|
||||
pthread_mutex_t mutex;
|
||||
@@ -89,6 +91,7 @@
|
||||
AC_TRY_RUN([
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
+int
|
||||
main() {
|
||||
pthread_cond_t cond;
|
||||
pthread_condattr_t condattr;
|
||||
@@ -110,6 +113,7 @@
|
||||
AC_TRY_RUN([
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
+int
|
||||
main() {
|
||||
pthread_rwlock_t rwlock;
|
||||
pthread_rwlockattr_t rwlockattr;
|
||||
diff -ur a/dist/aclocal/sequence.m4 b/dist/aclocal/sequence.m4
|
||||
--- a/dist/aclocal/sequence.m4 1969-12-31 19:00:01.000000000 -0500
|
||||
+++ b/dist/aclocal/sequence.m4 2023-06-05 19:14:02.007869956 -0400
|
||||
@@ -43,6 +43,9 @@
|
||||
# test, which won't test for the appropriate printf format strings.
|
||||
if test "$db_cv_build_sequence" = "yes"; then
|
||||
AC_TRY_RUN([
|
||||
+ #include <string.h>
|
||||
+ #include <stdio.h>
|
||||
+ int
|
||||
main() {
|
||||
$db_cv_seq_type l;
|
||||
unsigned $db_cv_seq_type u;
|
||||
@@ -59,7 +62,9 @@
|
||||
return (1);
|
||||
return (0);
|
||||
}],, [db_cv_build_sequence="no"],
|
||||
- AC_TRY_LINK(,[
|
||||
+ AC_TRY_LINK([
|
||||
+ #include <string.h>
|
||||
+ #include <stdio.h>],[
|
||||
$db_cv_seq_type l;
|
||||
unsigned $db_cv_seq_type u;
|
||||
char buf@<:@100@:>@;
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ lib, stdenv, fetchurl, ... } @ args:
|
||||
{ lib, stdenv, fetchurl, autoreconfHook, ... } @ args:
|
||||
|
||||
import ./generic.nix (args // {
|
||||
version = "4.8.30";
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ lib, stdenv, fetchurl, ... } @ args:
|
||||
{ lib, stdenv, fetchurl, autoreconfHook, ... } @ args:
|
||||
|
||||
import ./generic.nix (args // {
|
||||
version = "5.3.28";
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ lib, stdenv, fetchurl, ... } @ args:
|
||||
{ lib, stdenv, fetchurl, autoreconfHook, ... } @ args:
|
||||
|
||||
import ./generic.nix (args // {
|
||||
version = "6.0.20";
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ lib, stdenv, fetchurl, ... } @ args:
|
||||
{ lib, stdenv, fetchurl, autoreconfHook, ... } @ args:
|
||||
|
||||
import ./generic.nix (args // {
|
||||
version = "6.2.23";
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ lib, stdenv, fetchurl
|
||||
{ lib, stdenv, fetchurl, autoreconfHook
|
||||
, cxxSupport ? true
|
||||
, compat185 ? true
|
||||
, dbmSupport ? false
|
||||
@ -10,6 +10,9 @@
|
||||
, drvArgs ? {}
|
||||
}:
|
||||
|
||||
let
|
||||
shouldReconfigure = stdenv.cc.isClang;
|
||||
in
|
||||
stdenv.mkDerivation (rec {
|
||||
pname = "db";
|
||||
inherit version;
|
||||
@ -19,10 +22,48 @@ stdenv.mkDerivation (rec {
|
||||
sha256 = sha256;
|
||||
};
|
||||
|
||||
# The provided configure script features `main` returning implicit `int`, which causes
|
||||
# configure checks to work incorrectly with clang 16.
|
||||
nativeBuildInputs = lib.optionals stdenv.cc.isClang [ autoreconfHook ];
|
||||
|
||||
patches = extraPatches;
|
||||
|
||||
outputs = [ "bin" "out" "dev" ];
|
||||
|
||||
# Required when regenerated the configure script to make sure the vendored macros are found.
|
||||
autoreconfFlags = lib.optionalString shouldReconfigure [ "-fi" "-Iaclocal" "-Iaclocal_java" ];
|
||||
|
||||
preAutoreconf = lib.optionalString shouldReconfigure ''
|
||||
pushd dist
|
||||
# Upstream’s `dist/s_config` cats everything into `aclocal.m4`, but that doesn’t work with
|
||||
# autoreconfHook, so cat `config.m4` to another file. Otherwise, it won’t be found by `aclocal`.
|
||||
cat aclocal/config.m4 >> aclocal/options.m4
|
||||
'';
|
||||
|
||||
# This isn’t pretty. The version information is kept separate from the configure script.
|
||||
# After the configure script is regenerated, the version information has to be replaced with the
|
||||
# contents of `dist/RELEASE`.
|
||||
postAutoreconf = lib.optionalString shouldReconfigure ''
|
||||
(
|
||||
declare -a vars=(
|
||||
"DB_VERSION_FAMILY"
|
||||
"DB_VERSION_RELEASE"
|
||||
"DB_VERSION_MAJOR"
|
||||
"DB_VERSION_MINOR"
|
||||
"DB_VERSION_PATCH"
|
||||
"DB_VERSION_STRING"
|
||||
"DB_VERSION_FULL_STRING"
|
||||
"DB_VERSION_UNIQUE_NAME"
|
||||
"DB_VERSION"
|
||||
)
|
||||
source RELEASE
|
||||
for var in "''${vars[@]}"; do
|
||||
sed -e "s/__EDIT_''${var}__/''${!var}/g" -i configure
|
||||
done
|
||||
)
|
||||
popd
|
||||
'';
|
||||
|
||||
configureFlags =
|
||||
[
|
||||
(if cxxSupport then "--enable-cxx" else "--disable-cxx")
|
||||
|
Loading…
Reference in New Issue
Block a user