Unable to build BDB 4.8 on macOS Big Sur beta or Xcode 12.0 #19411

issue Sjors openend this issue on June 29, 2020
  1. Sjors commented at 1:44 pm on June 29, 2020: member

    Update 22-9-2020: this happens on macOS Catalina as well with Xcode 12.0

    Update 9-10-2020; workaround suggested by @willcl-ark:

    0brew install llvm
    1export LLVM_PREFIX=$(brew --prefix llvm)
    2CC=$LLVM_PREFIX/bin/clang CXX=$LLVM_PREFIX/bin/clang++ LDFLAGS="-L$LLVM_PREFIX/opt/llvm/lib -Wl,-rpath,$LLVM_PREFIX/opt/llvm/lib" ./contrib/install_db4.sh .
    

    Update 20-10-2020: better workaround suggested by @fanquake:

    0CFLAGS="-Wno-error=implicit-function-declaration"  ./contrib/install_db4.sh .
    

    For more problems with macOS Big Sur (beta) see #19406.

    I’m unable to build Berkeley DB 4.8. When using depends as when using contrib/install_db4.sh:

    0checking for mutexes... UNIX/fcntl
    1configure: WARNING: NO SHARED LATCH IMPLEMENTATION FOUND FOR THIS PLATFORM.
    2configure: error: Unable to find a mutex implementation
    

    configure.log stdout from Big Sur beta config.log on Catalina with Xcode 12.0

    I got the same error when compiling for iOs in #12557.

    On macOS Catalina it finds the following:

    0checking for mutexes... POSIX/pthreads/library/x86_64/gcc-assembly
    

    So perhaps something moved or was removed…

    Looking at dist/configure I think I narrowed it down to this check:

     0#include <pthread.h>
     1main() {
     2	pthread_cond_t cond;
     3	pthread_mutex_t mutex;
     4	pthread_condattr_t condattr;
     5	pthread_mutexattr_t mutexattr;
     6	exit (
     7	pthread_condattr_init(&condattr) ||
     8	pthread_condattr_setpshared(&condattr, PTHREAD_PROCESS_SHARED) ||
     9	pthread_mutexattr_init(&mutexattr) ||
    10	pthread_mutexattr_setpshared(&mutexattr, PTHREAD_PROCESS_SHARED) ||
    11	pthread_cond_init(&cond, &condattr) ||
    12	pthread_mutex_init(&mutex, &mutexattr) ||
    13	pthread_mutex_lock(&mutex) ||
    14	pthread_mutex_unlock(&mutex) ||
    15	pthread_mutex_destroy(&mutex) ||
    16	pthread_cond_destroy(&cond) ||
    17	pthread_condattr_destroy(&condattr) ||
    18	pthread_mutexattr_destroy(&mutexattr));
    19}
    20_ACEOF
    21if ac_fn_c_try_run "$LINENO"; then :
    22  db_cv_mutex="POSIX/pthreads/library"
    23fi
    

    If I replace the main() function body with exit(0); it still fails, but it’s “happy” when why I use return 0;. I initially assumed this was a -Werror=return-type problem, but something like exit(0); return 0; doesn’t work either. I don’t know how to inspect the compilation output.

    I can replace exit with return in the above function and it compiles, bitcoind builds and wallet tests pass.

    This suggests an obvious patch, but also a bit of a mystery.

  2. Sjors added the label Bug on Jun 29, 2020
  3. jakeleventhal commented at 7:00 am on July 31, 2020: contributor
    @Sjors where were you making this patch? having trouble with this myself
  4. Sjors commented at 5:03 pm on July 31, 2020: member
    @jakeleventhal I haven’t tried. In fact I had to ditch my Big Sur machine because it was broken. Will probably upgrade another machine later this summer and try again.
  5. jakeleventhal commented at 6:33 am on August 2, 2020: contributor
    @Sjors i only have one machine and i need it on big sur. is there a docker image you recommend using that i can just share my workspace with as a volume? one that has most of everything installed already?
  6. jakeleventhal commented at 5:57 pm on August 2, 2020: contributor
    Update: cdecker/bitcoin-dev:common is a good docker image that lets you build bitcoin for anyone who comes across this issue in the future
  7. BioMike commented at 12:14 pm on September 21, 2020: none
    It seems that passing –enable-posixmutexes is sufficient to get configure to continue and the build to succeed. This finds /POSIX/pthreads/private when looking for mutexes. Not sure if the build libdb behaves properly though.
  8. BioMike commented at 12:14 pm on September 21, 2020: none
    It seems that passing –enable-posixmutexes is sufficient to get configure to continue and the build to succeed. This finds /POSIX/pthreads/private when looking for mutexes. Not sure if the build libdb behaves properly though.
  9. Sjors renamed this:
    Unable to build BDB 4.8 on macOS Big Sur beta (depends & contrib script)
    Unable to build BDB 4.8 on macOS Big Sur beta or Xcode 12.0
    on Sep 22, 2020
  10. Sjors commented at 10:41 am on September 22, 2020: member
    @BioMike I tried contrib/install_db4.sh . --enable-posixmutexes but it still fails for me with checking for mutexes... configure: error: unable to find POSIX 1003.1 mutex interfaces
  11. le2Ks commented at 8:12 pm on September 24, 2020: none
    @Sjors Did you solve it? I’m stuck as you at this same error after tried with –enable-posixmutexes
  12. BioMike commented at 10:04 am on September 25, 2020: none
    How about –with-mutex=Darwin/_spin_lock_try?
  13. Sjors commented at 3:00 pm on September 28, 2020: member

    Mmm, that’s at least a different error:

     0./libtool --mode=compile cc -c -I. -I/Users/sjors/dev/bitcoin/db4/db-4.8.30.NC/dist/..  -O3  /Users/sjors/dev/bitcoin/db4/db-4.8.30.NC/dist/../mutex/mut_tas.c
     1libtool: compile:  cc -c -I. -I/Users/sjors/dev/bitcoin/db4/db-4.8.30.NC/dist/.. -O3 /Users/sjors/dev/bitcoin/db4/db-4.8.30.NC/dist/../mutex/mut_tas.c  -fno-common -DPIC -o mut_tas.o
     2/Users/sjors/dev/bitcoin/db4/db-4.8.30.NC/dist/../mutex/mut_tas.c:140:34: error: implicit declaration of function 'atomic_compare_exchange' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
     3                if (MUTEXP_IS_BUSY(mutexp) || !MUTEXP_ACQUIRE(mutexp)) {
     4                                               ^
     5/Users/sjors/dev/bitcoin/db4/db-4.8.30.NC/dist/../dbinc/mutex_int.h:1056:2: note: expanded from macro 'MUTEXP_ACQUIRE'
     6        atomic_compare_exchange(env,                            \
     7        ^
     8/Users/sjors/dev/bitcoin/db4/db-4.8.30.NC/dist/../mutex/mut_tas.c:336:8: error: implicit declaration of function 'atomic_compare_exchange' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
     9                    !atomic_compare_exchange(env,
    10                     ^
    112 errors generated.
    12make: *** [mut_tas.o] Error 1
    
  14. fanquake added this to the milestone 0.21.0 on Sep 29, 2020
  15. fanquake added the label macOS on Sep 29, 2020
  16. willcl-ark commented at 7:26 pm on October 8, 2020: contributor

    @Sjors I just upgraded to Big Sur and saw this issue mentioned in the meeting…

    I can get this to compile by using brew-installed llvm like so:

    0brew install llvm
    1export LLVM_PREFIX=$(brew --prefix llvm)
    2CC=$LLVM_PREFIX/bin/clang CXX=$LLVM_PREFIX/bin/clang++ LDFLAGS="-L$LLVM_PREFIX/opt/llvm/lib -Wl,-rpath,$LLVM_PREFIX/opt/llvm/lib" ./contrib/install_db4.sh .
    
  17. Sjors commented at 8:58 am on October 9, 2020: member
    I assume you upgraded to the latest beta version 9? This workaround seems to work on macOS 10.15.7 Catalina as well, with Xcode 12.0.1 and llvm 10.0.1 via Homebrew. At least it doesn’t break any wallet tests.
  18. willcl-ark commented at 6:03 pm on October 11, 2020: contributor

    @Sjors yes I am on Version 11 Beta (20A5384c) and latest Xcode Beta.

    Not really a satisfying fix, but at least good to have some sort of workaround in the iterim. I will try a bit more tomorrow to see if I can find what the issue is with system compiler and libs…

  19. willcl-ark commented at 10:17 am on October 12, 2020: contributor

    Another (simpler) workaround:

    0./install_db4.sh . --disable-mutexsupport
    

    All wallet tests still pass, but the implications of no mutexes in the wallet db are, scary? EDIT: wallet tests do not pass (Was using the wrong db to build Bitcoin Core, had one in src/ and one in src/contrib/)

    I notice that Core has a specific pthread m4 in build-aux/m4/ax_pthread.m4, which seems to be the offending header in the BDB configure, so might investigate the differences if I don’t have any other luck.

    More promising I think might be to investigate this known issue of Big Sur:

    New in macOS Big Sur 11 beta, the system ships with a built-in dynamic linker cache of all system-provided libraries. As part of this change, copies of dynamic libraries are no longer present on the filesystem. Code that attempts to check for dynamic library presence by looking for a file at a path or enumerating a directory will fail. Instead, check for library presence by attempting to dlopen() the path, which will correctly check for the library in the cache. (62986286)

  20. willcl-ark commented at 11:26 am on October 13, 2020: contributor

    Some progress towards identifying a fix:

    • Modify ./contrib/install_db4.sh to break at line 91 then run once with ./contrib/install_db4.sh .

    • Modify db4/db-4.8.30.NC/dist/aclocal/mutex.m4 with the following patch (I believe AC_TRY_RUN… was silently failing without #include <stdlib.h>???):

     0--- mutex-orig.m4	2020-10-13 11:17:55.000000000 +0100
     1+++ mutex.m4	2020-10-13 11:15:56.000000000 +0100
     2@@ -4,6 +4,7 @@
     3 AC_DEFUN(AM_PTHREADS_SHARED, [
     4 AC_TRY_RUN([
     5 #include <pthread.h>
     6+#include <stdlib.h>
     7 main() {
     8 	pthread_cond_t cond;
     9 	pthread_mutex_t mutex;
    10@@ -24,7 +25,8 @@
    11 	pthread_mutexattr_destroy(&mutexattr));
    12 }], [db_cv_mutex="$1"],,
    13 AC_TRY_LINK([
    14-#include <pthread.h>],[
    15+#include <pthread.h>
    16+#include <stdlib.h>],[
    17 	pthread_cond_t cond;
    18 	pthread_mutex_t mutex;
    19 	pthread_condattr_t condattr;
    20@@ -46,6 +48,7 @@
    21 AC_DEFUN(AM_PTHREADS_PRIVATE, [
    22 AC_TRY_RUN([
    23 #include <pthread.h>
    24+#include <stdlib.h>
    25 main() {
    26 	pthread_cond_t cond;
    27 	pthread_mutex_t mutex;
    28@@ -65,6 +68,7 @@
    29 }], [db_cv_mutex="$1"],,
    30 AC_TRY_LINK([
    31 #include <pthread.h>],[
    32+#include <stdlib.h>
    33 	pthread_cond_t cond;
    34 	pthread_mutex_t mutex;
    35 	pthread_condattr_t condattr;
    
    • Next:
    0cd db4/db-4.8.30.NC/dist/
    1sudo rm -Rf autom4te.cache/ configure
    2sudo autoreconf -i
    

    This results in the following warnings: autoreconf_output.txt

    • Comment out lines 28-67 and 70-88 and re-run ./contrib/install_db4.sh .

    This gets us past configure mutex checks successfully:

    0checking for mutexes... POSIX/pthreads/library
    1checking pthread.h usability... yes
    2checking pthread.h presence... yes
    3checking for pthread.h... yes
    4checking for main in -lpthread... yes
    5...
    6checking for fcntl/F_SETFD... yes
    
    • Comment out lines 28-67 and 70-88 and re-run ./contrib/install_db4.sh .

    This however still results in the following error:

     0libtool: compile:  cc -c -I. -I/Users/will/src/bitcoin/db4/db-4.8.30.NC/dist/.. -O3 /Users/will/src/bitcoin/db4/db-4.8.30.NC/dist/../env/env_method.c  -fno-common -DPIC -o env_method.o
     1./libtool --mode=compile cc -c -I. -I/Users/will/src/bitcoin/db4/db-4.8.30.NC/dist/..  -O3  /Users/will/src/bitcoin/db4/db-4.8.30.NC/dist/../env/env_name.c
     2libtool: compile:  cc -c -I. -I/Users/will/src/bitcoin/db4/db-4.8.30.NC/dist/.. -O3 /Users/will/src/bitcoin/db4/db-4.8.30.NC/dist/../env/env_name.c  -fno-common -DPIC -o env_name.o
     3./libtool --mode=compile cc -c -I. -I/Users/will/src/bitcoin/db4/db-4.8.30.NC/dist/..  -O3  /Users/will/src/bitcoin/db4/db-4.8.30.NC/dist/../env/env_open.c
     4libtool: compile:  cc -c -I. -I/Users/will/src/bitcoin/db4/db-4.8.30.NC/dist/.. -O3 /Users/will/src/bitcoin/db4/db-4.8.30.NC/dist/../env/env_open.c  -fno-common -DPIC -o env_open.o
     5/Users/will/src/bitcoin/db4/db-4.8.30.NC/dist/../env/env_open.c:33:14: error: use of undeclared identifier
     6      '__EDIT_DB_VERSION_MAJOR__'
     7                *majverp = DB_VERSION_MAJOR;
     8                           ^
     9./db.h:45:26: note: expanded from macro 'DB_VERSION_MAJOR'
    10#define DB_VERSION_MAJOR        __EDIT_DB_VERSION_MAJOR__
    11                                ^
    12/Users/will/src/bitcoin/db4/db-4.8.30.NC/dist/../env/env_open.c:35:14: error: use of undeclared identifier
    13      '__EDIT_DB_VERSION_MINOR__'
    14                *minverp = DB_VERSION_MINOR;
    15                           ^
    16./db.h:46:26: note: expanded from macro 'DB_VERSION_MINOR'
    17#define DB_VERSION_MINOR        __EDIT_DB_VERSION_MINOR__
    18                                ^
    19/Users/will/src/bitcoin/db4/db-4.8.30.NC/dist/../env/env_open.c:37:13: error: use of undeclared identifier
    20      '__EDIT_DB_VERSION_PATCH__'
    21                *patchp = DB_VERSION_PATCH;
    22                          ^
    23./db.h:47:26: note: expanded from macro 'DB_VERSION_PATCH'
    24#define DB_VERSION_PATCH        __EDIT_DB_VERSION_PATCH__
    25                                ^
    263 errors generated.
    27make: *** [env_open.o] Error 1
    

    Running clang -x c -v -E /dev/null shows the default clang config:

     0Apple clang version 12.0.0 (clang-1200.0.32.6)
     1Target: x86_64-apple-darwin20.1.0
     2Thread model: posix
     3InstalledDir: /Library/Developer/CommandLineTools/usr/bin
     4 "/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx11.0.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name null -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=all -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=11.0 -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 609.5 -v -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Library/Developer/CommandLineTools/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -fdebug-compilation-dir /Users/will/src/bitcoin -ferror-limit 19 -fmessage-length 126 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fobjc-runtime=macosx-11.0.0 -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o - -x c /dev/null
     5clang -cc1 version 12.0.0 (clang-1200.0.32.6) default target x86_64-apple-darwin20.1.0
     6ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
     7ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
     8#include "..." search starts here:
     9#include <...> search starts here:
    10 /usr/local/include
    11 /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include
    12 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
    13 /Library/Developer/CommandLineTools/usr/include
    14 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
    15End of search list.
    16# 1 "/dev/null"
    17# 1 "<built-in>" 1
    18# 1 "<built-in>" 3
    19# 366 "<built-in>" 3
    20# 1 "<command line>" 1
    21# 1 "<built-in>" 2
    22# 1 "/dev/null" 2
    
  21. willcl-ark commented at 2:49 pm on October 13, 2020: contributor

    I can see that configure.ac is listing abort.o as a LIBOBJS, so configure thinks the system ones should be replaced:

    LIBOBJS=' ${LIBOBJDIR}abort$U.o ${LIBOBJDIR}atoi$U.o ${LIBOBJDIR}atol$U.o ${LIBOBJDIR}getenv$U.o ${LIBOBJDIR}qsort$U.o ${LIBOBJDIR}rand$U.o ${LIBOBJDIR}strtol$U.o ${LIBOBJDIR}strtoul$U.o'

    config.log shows:

     0configure:20634: checking for abort
     1configure:20634: cc -o conftest -O3  -include stdlib.h  conftest.c  -lpthread >&5
     2conftest.c:75:6: error: conflicting types for 'abort'
     3char abort ();
     4     ^
     5/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:131:7: note: previous declaration is here
     6void     abort(void) __cold __dead2;
     7         ^
     8conftest.c:86:8: error: returning 'void' from a function with incompatible result type 'int'
     9return abort ();
    10       ^~~~~~~~
    112 errors generated.
    

    …which is why I assume it want to replace it.

    (full log section: abort.txt)

  22. willcl-ark commented at 8:50 pm on October 13, 2020: contributor
    Command line tools for Xcode 12.2 Beta 3 (Oct 13th) does not solve the issue.
  23. willcl-ark commented at 8:47 am on October 14, 2020: contributor

    Brew-installed clang passes the same configure tests for abort, atoi, atol etc.:

     0configure:20634: checking for abort
     1configure:20634: /usr/local/opt/llvm/bin/clang -o conftest -O3   -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib conftest.c  -lpthread >&5
     2conftest.c:75:6: warning: incompatible redeclaration of library function 'abort' [-Wincompatible-library-redeclaration]
     3char abort ();
     4     ^
     5conftest.c:75:6: note: 'abort' is a builtin with type 'void (void) __attribute__((noreturn))'
     61 warning generated.
     7configure:20634: $? = 0
     8configure:20634: result: yes
     9configure:20634: checking for atoi
    10configure:20634: /usr/local/opt/llvm/bin/clang -o conftest -O3   -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib conftest.c  -lpthread >&5
    11configure:20634: $? = 0
    12configure:20634: result: yes
    

    vs system-installed clang (with CPPFLAGS="-include stdlib.h"):

      0configure:20634: checking for abort
      1configure:20634: cc -o conftest -O3  -I/usr/local/opt/llvm/include -include stdlib.h -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib conftest.c  -lpthread >&5
      2conftest.c:75:6: error: conflicting types for 'abort'
      3char abort ();
      4     ^
      5/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:131:7: note: previous declaration is here
      6void     abort(void) __cold __dead2;
      7         ^
      8conftest.c:86:8: error: returning 'void' from a function with incompatible result type 'int'
      9return abort ();
     10       ^~~~~~~~
     112 errors generated.
     12configure:20634: $? = 1
     13configure: failed program was:
     14| /* confdefs.h */
     15| #define PACKAGE_NAME "Berkeley DB"
     16| #define PACKAGE_TARNAME "db-4.8.30"
     17| #define PACKAGE_VERSION "4.8.30"
     18| #define PACKAGE_STRING "Berkeley DB 4.8.30"
     19| #define PACKAGE_BUGREPORT "Oracle Technology Network Berkeley DB forum"
     20| #define PACKAGE_URL ""
     21| #define HAVE_UPGRADE_SUPPORT 1
     22| #define STDC_HEADERS 1
     23| #define HAVE_SYS_TYPES_H 1
     24| #define HAVE_SYS_STAT_H 1
     25| #define HAVE_STDLIB_H 1
     26| #define HAVE_STRING_H 1
     27| #define HAVE_MEMORY_H 1
     28| #define HAVE_STRINGS_H 1
     29| #define HAVE_INTTYPES_H 1
     30| #define HAVE_STDINT_H 1
     31| #define HAVE_UNISTD_H 1
     32| #define HAVE_DLFCN_H 1
     33| #define LT_OBJDIR ".libs/"
     34| #define HAVE_SYSTEM_INCLUDE_FILES 1
     35| #define TIME_WITH_SYS_TIME 1
     36| #define HAVE_DIRENT_H 1
     37| #define HAVE_EXECINFO_H 1
     38| #define HAVE_SYS_SELECT_H 1
     39| #define HAVE_SYS_SOCKET_H 1
     40| #define HAVE_SYS_TIME_H 1
     41| #define HAVE_STRUCT_STAT_ST_BLKSIZE 1
     42| #define SIZEOF_CHAR 1
     43| #define SIZEOF_UNSIGNED_CHAR 1
     44| #define SIZEOF_SHORT 2
     45| #define SIZEOF_UNSIGNED_SHORT 2
     46| #define SIZEOF_INT 4
     47| #define SIZEOF_UNSIGNED_INT 4
     48| #define SIZEOF_LONG 8
     49| #define SIZEOF_UNSIGNED_LONG 8
     50| #define SIZEOF_LONG_LONG 8
     51| #define SIZEOF_UNSIGNED_LONG_LONG 8
     52| #define SIZEOF_CHAR_P 8
     53| #define SIZEOF_SIZE_T 8
     54| #define HAVE_EXIT_SUCCESS 1
     55| #define HAVE_GETOPT_OPTRESET 1
     56| #define HAVE_MUTEX_PTHREADS 1
     57| #define HAVE_MUTEX_X86_64_GCC_ASSEMBLY 1
     58| #define HAVE_MUTEX_SUPPORT 1
     59| #define HAVE_SHARED_LATCHES 1
     60| #define HAVE_MUTEX_HYBRID 1
     61| #define HAVE_SIMPLE_THREAD_TYPE 1
     62| #define HAVE_ATOMIC_SUPPORT 1
     63| #define HAVE_ATOMIC_X86_GCC_ASSEMBLY 1
     64| /* end confdefs.h.  */
     65| /* Define abort to an innocuous variant, in case <limits.h> declares abort.
     66|    For example, HP-UX 11i <limits.h> declares gettimeofday.  */
     67| #define abort innocuous_abort
     68| 
     69| /* System header to define __stub macros and hopefully few prototypes,
     70|     which can conflict with char abort (); below.
     71|     Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
     72|     <limits.h> exists even on freestanding compilers.  */
     73| 
     74| #ifdef __STDC__
     75| # include <limits.h>
     76| #else
     77| # include <assert.h>
     78| #endif
     79| 
     80| #undef abort
     81| 
     82| /* Override any GCC internal prototype to avoid an error.
     83|    Use char because int might match the return type of a GCC
     84|    builtin and then its argument prototype would still apply.  */
     85| #ifdef __cplusplus
     86| extern "C"
     87| #endif
     88| char abort ();
     89| /* The GNU C library defines this for functions which it implements
     90|     to always fail with ENOSYS.  Some functions are actually named
     91|     something starting with __ and the normal name is an alias.  */
     92| #if defined __stub_abort || defined __stub___abort
     93| choke me
     94| #endif
     95| 
     96| int
     97| main ()
     98| {
     99| return abort ();
    100|   ;
    101|   return 0;
    102| }
    103configure:20634: result: no
    104configure:20634: checking for atoi
    105configure:20634: cc -o conftest -O3  -I/usr/local/opt/llvm/include -include stdlib.h -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib conftest.c  -lpthread >&5
    106conftest.c:75:6: error: conflicting types for 'atoi'
    107char atoi ();
    108     ^
    109/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:135:6: note: previous declaration is here
    110int      atoi(const char *);
    111         ^
    112conftest.c:86:14: error: too few arguments to function call, expected 1, have 0
    113return atoi ();
    114       ~~~~  ^
    115/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:135:1: note: 'atoi' declared here
    116int      atoi(const char *);
    117^
    1182 errors generated.
    119configure:20634: $? = 1
    120configure: failed program was:
    121| /* confdefs.h */
    122| #define PACKAGE_NAME "Berkeley DB"
    123| #define PACKAGE_TARNAME "db-4.8.30"
    124| #define PACKAGE_VERSION "4.8.30"
    125| #define PACKAGE_STRING "Berkeley DB 4.8.30"
    126| #define PACKAGE_BUGREPORT "Oracle Technology Network Berkeley DB forum"
    127| #define PACKAGE_URL ""
    128| #define HAVE_UPGRADE_SUPPORT 1
    129| #define STDC_HEADERS 1
    130| #define HAVE_SYS_TYPES_H 1
    131| #define HAVE_SYS_STAT_H 1
    132| #define HAVE_STDLIB_H 1
    133| #define HAVE_STRING_H 1
    134| #define HAVE_MEMORY_H 1
    135| #define HAVE_STRINGS_H 1
    136| #define HAVE_INTTYPES_H 1
    137| #define HAVE_STDINT_H 1
    138| #define HAVE_UNISTD_H 1
    139| #define HAVE_DLFCN_H 1
    140| #define LT_OBJDIR ".libs/"
    141| #define HAVE_SYSTEM_INCLUDE_FILES 1
    142| #define TIME_WITH_SYS_TIME 1
    143| #define HAVE_DIRENT_H 1
    144| #define HAVE_EXECINFO_H 1
    145| #define HAVE_SYS_SELECT_H 1
    146| #define HAVE_SYS_SOCKET_H 1
    147| #define HAVE_SYS_TIME_H 1
    148| #define HAVE_STRUCT_STAT_ST_BLKSIZE 1
    149| #define SIZEOF_CHAR 1
    150| #define SIZEOF_UNSIGNED_CHAR 1
    151| #define SIZEOF_SHORT 2
    152| #define SIZEOF_UNSIGNED_SHORT 2
    153| #define SIZEOF_INT 4
    154| #define SIZEOF_UNSIGNED_INT 4
    155| #define SIZEOF_LONG 8
    156| #define SIZEOF_UNSIGNED_LONG 8
    157| #define SIZEOF_LONG_LONG 8
    158| #define SIZEOF_UNSIGNED_LONG_LONG 8
    159| #define SIZEOF_CHAR_P 8
    160| #define SIZEOF_SIZE_T 8
    161| #define HAVE_EXIT_SUCCESS 1
    162| #define HAVE_GETOPT_OPTRESET 1
    163| #define HAVE_MUTEX_PTHREADS 1
    164| #define HAVE_MUTEX_X86_64_GCC_ASSEMBLY 1
    165| #define HAVE_MUTEX_SUPPORT 1
    166| #define HAVE_SHARED_LATCHES 1
    167| #define HAVE_MUTEX_HYBRID 1
    168| #define HAVE_SIMPLE_THREAD_TYPE 1
    169| #define HAVE_ATOMIC_SUPPORT 1
    170| #define HAVE_ATOMIC_X86_GCC_ASSEMBLY 1
    171| /* end confdefs.h.  */
    172| /* Define atoi to an innocuous variant, in case <limits.h> declares atoi.
    173|    For example, HP-UX 11i <limits.h> declares gettimeofday.  */
    174| #define atoi innocuous_atoi
    175| 
    176| /* System header to define __stub macros and hopefully few prototypes,
    177|     which can conflict with char atoi (); below.
    178|     Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
    179|     <limits.h> exists even on freestanding compilers.  */
    180| 
    181| #ifdef __STDC__
    182| # include <limits.h>
    183| #else
    184| # include <assert.h>
    185| #endif
    186| 
    187| #undef atoi
    188| 
    189| /* Override any GCC internal prototype to avoid an error.
    190|    Use char because int might match the return type of a GCC
    191|    builtin and then its argument prototype would still apply.  */
    192| #ifdef __cplusplus
    193| extern "C"
    194| #endif
    195| char atoi ();
    196| /* The GNU C library defines this for functions which it implements
    197|     to always fail with ENOSYS.  Some functions are actually named
    198|     something starting with __ and the normal name is an alias.  */
    199| #if defined __stub_atoi || defined __stub___atoi
    200| choke me
    201| #endif
    202| 
    203| int
    204| main ()
    205| {
    206| return atoi ();
    207|   ;
    208|   return 0;
    209| }
    210configure:20634: result: no
    

    I think the mandatory include of <stdlib.h> in every function test is causing configure to fail on these functions where they should be replaced, perhaps patching mutex.m4 and fixing the DB_VERSION error might end up being “cleaner”?

  24. willcl-ark commented at 1:01 pm on October 14, 2020: contributor

    In absence of being able to fix the issue directly, I propose a workaround here:

    https://github.com/willcl-ark/bitcoin/tree/build_bdb_big_sur @fanquake is such a workaround likely to be an acceptable “solution” to this?

  25. fanquake commented at 2:09 am on October 15, 2020: member
    @willcl-ark I need to catch up here, but that would only be a partial fix, as depends builds would still be would still be broken. I’d like to make sure we understand what the issue is, and patch it pre-build, rather than filling up our db4 install script with a bunch of macOS specific hacks, and still have it broken in depends.
  26. willcl-ark commented at 8:57 am on October 15, 2020: contributor

    @fanquake I agree it’s not a real solution.

    I’ve just tested BDB18.1 and that compiles on stock Big Sur with Xcode 12, so perhaps I can finally hunt down the fix.

  27. willcl-ark commented at 1:23 pm on October 19, 2020: contributor

    I don’t see a way we can fix this on Big Sur which doesn’t involve either:

    a) using brew-installed LLVM or b) massively patching quite a number of the .m4 files, removing autom4te.cache and configure and then autoreconf -i-ing, all of which require permissions changes to the extracted files.

    Neither is ideal.

    There was another note in mutex.m4 from bdb v18 which might be of note to anyone else looking to pick this up, although it does seem like, if this was the (primary) issue, we would have picked it up earlier…:

    0		# Mac OS 10.7 Lion has broken pthread_*_setpshared() calls.
    1		# Most BSD-like operating systems have pointers in their mutex
    2		# and condition variables, and cannot be shared between
    3		# proceses.  Earlier Mac OS releases correctly returned EINVAL
    4		# from *_setpshared(PTHREAD_PROCESS_SHARED), but 10.7 returns
    5		# success. Since we can't trust those calls anymore we now
    6		# avoid these probes for multiprocess pthreads.
    
  28. fanquake commented at 8:54 am on October 20, 2020: member

    @willcl-ark thanks for the investigation. However I’ve taken a look and determined that the problem is actually that Apple has enabled -Werror=implicit-function-declaration by default in the Clang shipped with Xcode 12.0:

    Clang now reports an error when you use a function without an explicit declaration when building C or Objective-C code for macOS (-Werror=implicit-function-declaration flag is on). This additional error detection unifies Clang’s behavior for iOS/tvOS and macOS 64-bit targets for this diagnostic. (49917738)

    This causes warnings which were already present in the mutex related checks, i.e:

    0configure:18704: checking for mutexes
    1configure:18815: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -mmacosx-version-min=10.12 --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -o conftest -pipe -O2  -I/Users/michael/github/fanquake-bitcoin/depends/x86_64-apple-darwin19.6.0/include -L/Users/michael/github/fanquake-bitcoin/depends/x86_64-apple-darwin19.6.0/lib conftest.c  -lpthread >&5
    2conftest.c:46:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
    3main() {
    4^
    5conftest.c:51:2: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
    6        exit (
    7        ^
    8conftest.c:51:2: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
    91 warning and 1 error generated.
    

    to be converted into errors, and the hence the mutex check fails.

    I’ll open a PR with a fix shortly.

  29. awesome-doge commented at 9:38 am on October 20, 2020: none

    I encountered the same problem in “macos big sur beta 11.0” & “Command_Line_Tools_for_Xcode_12.2_beta_3”.

    Using your(@willcl-ark ) solution “https://github.com/willcl-ark/bitcoin/tree/build_bdb_big_sur" will cause an error.

     0Detected macOS Big Sur v11.0...
     1Error: No such keg: /usr/local/Cellar/llvm
     2Found brew-installed LLVM, using for compilation:
     3Using CC:
     4...
     5...
     6checking for a BSD-compatible install... /usr/bin/install -c
     7checking whether the C compiler works... no
     8configure: error: in `/Users/doge/git/bitcoin/db4/db-4.8.30.NC/build_unix':
     9configure: error: C compiler cannot create executables
    10See `config.log' for more details.
    

    After I reinstalled “brew install llvm” It works

  30. fanquake referenced this in commit 0729d1a025 on Oct 20, 2020
  31. willcl-ark referenced this in commit ccb338a3a0 on Oct 23, 2020
  32. fanquake referenced this in commit d0a829e963 on Oct 27, 2020
  33. laanwj closed this on Oct 29, 2020

  34. laanwj referenced this in commit 5b82f253b6 on Oct 29, 2020
  35. sidhujag referenced this in commit faf425a4f6 on Oct 29, 2020
  36. fanquake referenced this in commit 314e79581f on Oct 30, 2020
  37. MarkLTZ referenced this in commit 11254d49e6 on Nov 21, 2020
  38. xdustinface referenced this in commit 53ad08710c on Feb 17, 2021
  39. shuaaa commented at 5:11 pm on June 8, 2021: none
    it’s 1year later and I am having this problem, I have Catalan 10.15.4. Did anyone find a working solution to the error: Unable to find a mutex implementation
  40. hebasto commented at 5:32 pm on June 8, 2021: member

    @shuaaa

    it’s 1year later and I am having this problem, I have Catalan 10.15.4. Did anyone find a working solution to the error: Unable to find a mutex implementation

    Could you open a new issue, and describe all steps to reproduce your problem?

  41. fanquake commented at 1:17 am on June 9, 2021: member

    Did anyone find a working solution to the error: Unable to find a mutex implementation

    Yes. This was fixed in #20195, which is in master, the 0.21 and 0.20 branches.

  42. furszy referenced this in commit 07f08d4b3f on Jun 30, 2021
  43. Sjors commented at 2:17 pm on August 10, 2022: member

    It’s back! (or I forgot some critical step)

    On master @ a6fc293c0a1f27ba1e573bfa16fd76d5f58988b2, macOS 12.5 (Intel), Xcode 13.4.1.

    0git clean -dfx
    1contrib/install_db4.sh `pwd`
    2
    3
    4checking for ANSI C exit success/failure values... yes
    5checking for getopt optreset variable... yes
    6checking for mutexes... UNIX/fcntl
    7configure: WARNING: NO SHARED LATCH IMPLEMENTATION FOUND FOR THIS PLATFORM.
    8configure: error: Unable to find a mutex implementation
    

    (I’ll open a new issue if nobody reminds me of the stupid thing I forgot)

  44. fanquake commented at 2:18 pm on August 10, 2022: member

    It’s not!

    The contrib script doesn’t apply the same patch as depends.

  45. Sjors commented at 2:23 pm on August 10, 2022: member
    Ah yes, as I noticed in my own review: #20195 (comment)
  46. lyricidal referenced this in commit 942cc48eb6 on Mar 27, 2023
  47. lyricidal referenced this in commit c13f14d8e3 on Mar 27, 2023
  48. bitcoin locked this on Aug 10, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-03 10:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me