813
813
dnl Check for endianness
814
814
AC_C_BIGENDIAN
815
815
816
- dnl Check for pthread compile/link requirements
817
- AX_PTHREAD
818
-
819
- dnl Check if -latomic is required for <std::atomic>
820
- CHECK_ATOMIC
821
-
822
- dnl The following macro will add the necessary defines to bitcoin-config.h, but
823
- dnl they also need to be passed down to any subprojects. Pull the results out of
824
- dnl the cache and add them to CPPFLAGS.
825
- AC_SYS_LARGEFILE
826
- dnl detect POSIX or GNU variant of strerror_r
827
- AC_FUNC_STRERROR_R
828
-
829
- if test "$ac_cv_sys_file_offset_bits" != "" &&
830
- test "$ac_cv_sys_file_offset_bits" != "no" &&
831
- test "$ac_cv_sys_file_offset_bits" != "unknown"; then
832
- CORE_CPPFLAGS="$CORE_CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
833
- fi
834
-
835
- if test "$ac_cv_sys_large_files" != "" &&
836
- test "$ac_cv_sys_large_files" != "no" &&
837
- test "$ac_cv_sys_large_files" != "unknown"; then
838
- CORE_CPPFLAGS="$CORE_CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files"
839
- fi
840
-
841
- if test "$TARGET_OS" != "windows"; then
842
- dnl All windows code is PIC, forcing it on just adds useless compile warnings
843
- AX_CHECK_COMPILE_FLAG ( [ -fPIC] , [ PIC_FLAGS="-fPIC"] )
844
- fi
845
-
846
- if test "$use_hardening" != "no"; then
847
- AX_CHECK_COMPILE_FLAG ( [ -Wstack-protector] , [ HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"] )
848
- AX_CHECK_COMPILE_FLAG ( [ -fstack-protector-all] , [ HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"] )
849
-
850
- AX_CHECK_COMPILE_FLAG ( [ -fcf-protection=full] , [ HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fcf-protection=full"] )
851
-
852
- case $host in
853
- *mingw*)
854
- dnl stack-clash-protection doesn't compile with GCC 10 and earlier.
855
- dnl In any case, it is a no-op for Windows.
856
- dnl See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90458 for more details.
857
- ;;
858
- *)
859
- AX_CHECK_COMPILE_FLAG ( [ -fstack-clash-protection] , [ HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-clash-protection"] , [ ] , [ $CXXFLAG_WERROR] )
860
- ;;
861
- esac
862
-
863
- case $host in
864
- *aarch64*)
865
- AX_CHECK_COMPILE_FLAG ( [ -mbranch-protection=bti] , [ HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -mbranch-protection=bti"] )
866
- ;;
867
- esac
868
-
869
- dnl When enable_debug is yes, all optimizations are disabled.
870
- dnl However, FORTIFY_SOURCE requires that there is some level of optimization, otherwise it does nothing and just creates a compiler warning.
871
- dnl Since FORTIFY_SOURCE is a no-op without optimizations, do not enable it when enable_debug is yes.
872
- if test "$enable_debug" != "yes"; then
873
- AX_CHECK_PREPROC_FLAG ( [ -D_FORTIFY_SOURCE=3] ,[
874
- AX_CHECK_PREPROC_FLAG ( [ -U_FORTIFY_SOURCE] ,[
875
- HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE"
876
- ] )
877
- HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=3"
878
- ] )
816
+ AC_ARG_ENABLE ( tests ,
817
+ AS_HELP_STRING ( [ --enable-tests] ,[ compile tests [ default=yes] ] ) , [ ] ,
818
+ [ SECP_SET_DEFAULT([ enable_tests] , [ yes] , [ yes] )] )
819
+
820
+ AC_ARG_ENABLE ( ctime_tests ,
821
+ AS_HELP_STRING ( [ --enable-ctime-tests] ,[ compile constant-time tests [ default=yes if valgrind enabled] ] ) , [ ] ,
822
+ [ SECP_SET_DEFAULT([ enable_ctime_tests] , [ auto] , [ auto] )] )
823
+
824
+ AC_ARG_ENABLE ( experimental ,
825
+ AS_HELP_STRING ( [ --enable-experimental] ,[ allow experimental configure options [ default=no] ] ) , [ ] ,
826
+ [ SECP_SET_DEFAULT([ enable_experimental] , [ no] , [ yes] )] )
827
+
828
+ AC_ARG_ENABLE ( exhaustive_tests ,
829
+ AS_HELP_STRING ( [ --enable-exhaustive-tests] ,[ compile exhaustive tests [ default=yes] ] ) , [ ] ,
830
+ [ SECP_SET_DEFAULT([ enable_exhaustive_tests] , [ yes] , [ yes] )] )
831
+
832
+ AC_ARG_ENABLE ( examples ,
833
+ AS_HELP_STRING ( [ --enable-examples] ,[ compile the examples [ default=no] ] ) , [ ] ,
834
+ [ SECP_SET_DEFAULT([ enable_examples] , [ no] , [ yes] )] )
835
+
836
+ AC_ARG_ENABLE ( module_ecdh ,
837
+ AS_HELP_STRING ( [ --enable-module-ecdh] ,[ enable ECDH module [ default=yes] ] ) , [ ] ,
838
+ [ SECP_SET_DEFAULT([ enable_module_ecdh] , [ yes] , [ yes] )] )
839
+
840
+ AC_ARG_ENABLE ( module_recovery ,
841
+ AS_HELP_STRING ( [ --enable-module-recovery] ,[ enable ECDSA pubkey recovery module [ default=no] ] ) , [ ] ,
842
+ [ SECP_SET_DEFAULT([ enable_module_recovery] , [ no] , [ yes] )] )
843
+
844
+ AC_ARG_ENABLE ( module_extrakeys ,
845
+ AS_HELP_STRING ( [ --enable-module-extrakeys] ,[ enable extrakeys module [ default=yes] ] ) , [ ] ,
846
+ [ SECP_SET_DEFAULT([ enable_module_extrakeys] , [ yes] , [ yes] )] )
847
+
848
+ AC_ARG_ENABLE ( module_schnorrsig ,
849
+ AS_HELP_STRING ( [ --enable-module-schnorrsig] ,[ enable schnorrsig module [ default=yes] ] ) , [ ] ,
850
+ [ SECP_SET_DEFAULT([ enable_module_schnorrsig] , [ yes] , [ yes] )] )
851
+
852
+ AC_ARG_ENABLE ( module_ellswift ,
853
+ AS_HELP_STRING ( [ --enable-module-ellswift] ,[ enable ElligatorSwift module [ default=yes] ] ) , [ ] ,
854
+ [ SECP_SET_DEFAULT([ enable_module_ellswift] , [ yes] , [ yes] )] )
855
+
856
+ AC_ARG_ENABLE ( external_default_callbacks ,
857
+ AS_HELP_STRING ( [ --enable-external-default-callbacks] ,[ enable external default callback functions [ default=no] ] ) , [ ] ,
858
+ [ SECP_SET_DEFAULT([ enable_external_default_callbacks] , [ no] , [ no] )] )
859
+
860
+ # Test-only override of the (autodetected by the C code) "widemul" setting.
861
+ # Legal values are:
862
+ # * int64 (for [u]int64_t),
863
+ # * int128 (for [unsigned] __int128),
864
+ # * int128_struct (for int128 implemented as a structure),
865
+ # * and auto (the default).
866
+ AC_ARG_WITH ( [ test-override-wide-multiply] , [ ] ,[ set_widemul=$withval] , [ set_widemul=auto] )
867
+
868
+ AC_ARG_WITH ( [ asm] , [ AS_HELP_STRING ( [ --with-asm=x86_64|arm32|no|auto] ,
869
+ [ assembly to use (experimental: arm32) [ default=auto] ] ) ] ,[ req_asm=$withval] , [ req_asm=auto] )
870
+
871
+ AC_ARG_WITH ( [ ecmult-window] , [ AS_HELP_STRING ( [ --with-ecmult-window=SIZE] ,
872
+ [ window size for ecmult precomputation for verification, specified as integer in range [ 2..24] .]
873
+ [ Larger values result in possibly better performance at the cost of an exponentially larger precomputed table.]
874
+ [ The table will store 2^(SIZE-1) * 64 bytes of data but can be larger in memory due to platform-specific padding and alignment.]
875
+ [ A window size larger than 15 will require you delete the prebuilt precomputed_ecmult.c file so that it can be rebuilt.]
876
+ [ For very large window sizes, use "make -j 1" to reduce memory use during compilation.]
877
+ [ The default value is a reasonable setting for desktop machines (currently 15). [ default=15] ]
878
+ ) ] ,
879
+ [ set_ecmult_window=$withval] , [ set_ecmult_window=15] )
880
+
881
+ AC_ARG_WITH ( [ ecmult-gen-kb] , [ AS_HELP_STRING ( [ --with-ecmult-gen-kb=2|22|86] ,
882
+ [ The size of the precomputed table for signing in multiples of 1024 bytes (on typical platforms).]
883
+ [ Larger values result in possibly better signing/keygeneration performance at the cost of a larger table.]
884
+ [ The default value is a reasonable setting for desktop machines (currently 22). [ default=22] ]
885
+ ) ] ,
886
+ [ set_ecmult_gen_kb=$withval] , [ set_ecmult_gen_kb=22] )
887
+
888
+ AC_ARG_WITH ( [ valgrind] , [ AS_HELP_STRING ( [ --with-valgrind=yes|no|auto] ,
889
+ [ Build with extra checks for running inside Valgrind [ default=auto] ]
890
+ ) ] ,
891
+ [ req_valgrind=$withval] , [ req_valgrind=auto] )
892
+
893
+ # ##
894
+ # ## Handle config options (except for modules)
895
+ # ##
896
+
897
+ if test x"$req_valgrind" = x"no"; then
898
+ enable_valgrind=no
899
+ else
900
+ SECP_VALGRIND_CHECK
901
+ if test x"$has_valgrind" != x"yes"; then
902
+ if test x"$req_valgrind" = x"yes"; then
903
+ AC_MSG_ERROR ( [ Valgrind support explicitly requested but valgrind/memcheck.h header not available] )
904
+ fi
905
+ enable_valgrind=no
906
+ else
907
+ enable_valgrind=yes
879
908
fi
880
909
881
910
AX_CHECK_LINK_FLAG ( [ -Wl,--enable-reloc-section] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--enable-reloc-section"] , [ ] , [ $LDFLAG_WERROR] )
@@ -897,64 +926,28 @@ if test "$TARGET_OS" = "darwin"; then
897
926
AX_CHECK_LINK_FLAG ( [ -Wl,-fixup_chains] , [ HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-fixup_chains"] , [ ] , [ $LDFLAG_WERROR] )
898
927
fi
899
928
900
- AC_CHECK_HEADERS ( [ sys/select.h sys/prctl.h vm/vm_param.h sys/vmmeter.h sys/resources.h] )
901
-
902
- AC_CHECK_DECLS ( [ getifaddrs, freeifaddrs] ,[ CHECK_SOCKET] ,,
903
- [ #include <sys/types.h>
904
- #include <ifaddrs.h>]
905
- )
906
-
907
- dnl These are used for daemonization in BGLd
908
- AC_CHECK_DECLS ( [ fork] )
909
- AC_CHECK_DECLS ( [ setsid] )
910
-
911
- AC_CHECK_DECLS ( [ pipe2] )
912
-
913
- dnl Check for malloc_info (for memory statistics information in getmemoryinfo)
914
- AC_MSG_CHECKING ( [ for getmemoryinfo] )
915
- AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ [ #include <malloc.h>] ] ,
916
- [ [ int f = malloc_info(0, NULL); ] ] ) ] ,
917
- [ AC_MSG_RESULT ( [ yes] ) ; AC_DEFINE ( [ HAVE_MALLOC_INFO] , [ 1] , [ Define this symbol if you have malloc_info] ) ] ,
918
- [ AC_MSG_RESULT ( [ no] ) ]
919
- )
920
-
921
- dnl Check for mallopt(M_ARENA_MAX) (to set glibc arenas)
922
- AC_MSG_CHECKING ( [ for mallopt M_ARENA_MAX] )
923
- AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ [ #include <malloc.h>] ] ,
924
- [ [ mallopt(M_ARENA_MAX, 1); ] ] ) ] ,
925
- [ AC_MSG_RESULT ( [ yes] ) ; AC_DEFINE ( [ HAVE_MALLOPT_ARENA_MAX] , [ 1] , [ Define this symbol if you have mallopt with M_ARENA_MAX] ) ] ,
926
- [ AC_MSG_RESULT ( [ no] ) ]
927
- )
928
-
929
- dnl Check for posix_fallocate
930
- AC_MSG_CHECKING ( [ for posix_fallocate] )
931
- AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ [
932
- // same as in src/util/fs_helpers.cpp
933
- #ifdef __linux__
934
- #ifdef _POSIX_C_SOURCE
935
- #undef _POSIX_C_SOURCE
936
- #endif
937
- #define _POSIX_C_SOURCE 200112L
938
- #endif // __linux__
939
- #include <fcntl.h>] ] ,
940
- [ [ int f = posix_fallocate(0, 0, 0); ] ] ) ] ,
941
- [ AC_MSG_RESULT ( [ yes] ) ; AC_DEFINE ( [ HAVE_POSIX_FALLOCATE] , [ 1] , [ Define this symbol if you have posix_fallocate] ) ] ,
942
- [ AC_MSG_RESULT ( [ no] ) ]
943
- )
929
+ print_msan_notice=no
930
+ if test x"$enable_ctime_tests" = x"yes"; then
931
+ SECP_MSAN_CHECK
932
+ # MSan on Clang >=16 reports unitialized memory in function parameters and return values, even if
933
+ # the uninitalized variable is never actually "used". This is called "eager" checking, and it's
934
+ # sounds like good idea for normal use of MSan. However, it yields many false positives in the
935
+ # ctime_tests because many return values depend on secret (i.e., "uninitialized") values, and
936
+ # we're only interested in detecting branches (which count as "uses") on secret data.
937
+ if test x"$msan_enabled" = x"yes"; then
938
+ SECP_TRY_APPEND_CFLAGS([ -fno-sanitize-memory-param-retval] , SECP_CFLAGS)
939
+ print_msan_notice=yes
940
+ fi
941
+ fi
944
942
945
- AC_MSG_CHECKING ( [ for default visibility attribute] )
946
- AC_COMPILE_IFELSE ( [ AC_LANG_SOURCE ( [
947
- int foo(void) __attribute__((visibility("default")));
948
- int main(){}
949
- ] ) ] ,
950
- [
951
- AC_DEFINE ( [ HAVE_DEFAULT_VISIBILITY_ATTRIBUTE] , [ 1] , [ Define if the visibility attribute is supported.] )
952
- AC_MSG_RESULT ( [ yes] )
953
- ] ,
954
- [
955
- AC_MSG_RESULT ( [ no] )
956
- if test "$use_reduce_exports" = "yes"; then
957
- AC_MSG_ERROR ( [ Cannot find a working visibility attribute. Use --disable-reduce-exports.] )
943
+ if test x"$enable_coverage" = x"yes"; then
944
+ SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DCOVERAGE=1"
945
+ SECP_CFLAGS="-O0 --coverage $SECP_CFLAGS"
946
+ # If coverage is enabled, and the user has not overridden CFLAGS,
947
+ # override Autoconf's value "-g -O2" with "-g". Otherwise we'd end up
948
+ # with "-O0 --coverage -g -O2".
949
+ if test "$CFLAGS_overridden" = "no"; then
950
+ CFLAGS="-g"
958
951
fi
959
952
]
960
953
)
@@ -1269,42 +1262,30 @@ if test "$use_natpmp" != "no"; then
1269
1262
AC_CHECK_LIB ( [ natpmp] , [ initnatpmp] , [ NATPMP_LIBS="$NATPMP_LIBS -lnatpmp"] , [ have_natpmp=no] , [ $NATPMP_LIBS] )
1270
1263
fi
1271
1264
1272
- CPPFLAGS="$TEMP_CPPFLAGS"
1273
- fi
1274
-
1275
- if test "$build_BGL_wallet$build_BGL_cli$build_BGL_tx$build_BGL_util$build_BGLd$BGL_enable_qt$use_tests$use_bench$enable_fuzz_binary" = "nonononononononono"; then
1276
- use_boost=no
1277
- else
1278
- use_boost=yes
1279
- fi
1280
-
1281
- if test "$use_boost" = "yes"; then
1282
-
1283
- dnl Check for Boost headers
1284
- AX_BOOST_BASE ( [ 1.73.0] ,[ ] ,[ AC_MSG_ERROR ( [ Boost is not available!] ) ] )
1285
- if test "$want_boost" = "no"; then
1286
- AC_MSG_ERROR ( [ Boost is required] )
1287
- fi
1288
-
1289
- dnl we don't use multi_index serialization
1290
- BOOST_CPPFLAGS="$BOOST_CPPFLAGS -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION"
1291
-
1292
- dnl Prevent use of std::unary_function, which was removed in C++17,
1293
- dnl and will generate warnings with newer compilers for Boost
1294
- dnl older than 1.80.
1295
- dnl See: https://github.com/boostorg/config/pull/430.
1296
- AX_CHECK_PREPROC_FLAG ( [ -DBOOST_NO_CXX98_FUNCTION_BASE] , [ BOOST_CPPFLAGS="$BOOST_CPPFLAGS -DBOOST_NO_CXX98_FUNCTION_BASE"] , [ ] , [ $CXXFLAG_WERROR] ,
1297
- [ AC_LANG_PROGRAM ( [ [ #include <boost/config.hpp>] ] ) ] )
1298
-
1299
- if test "$suppress_external_warnings" != "no"; then
1300
- BOOST_CPPFLAGS=SUPPRESS_WARNINGS($BOOST_CPPFLAGS)
1265
+ error_window_size=[ 'window size for ecmult precomputation not an integer in range [ 2..24] ']
1266
+ case $set_ecmult_window in
1267
+ ''|*[ [ !0-9] ] *)
1268
+ # no valid integer
1269
+ AC_MSG_ERROR ( $error_window_size )
1270
+ ;;
1271
+ *)
1272
+ if test "$set_ecmult_window" -lt 2 -o "$set_ecmult_window" -gt 24 ; then
1273
+ # not in range
1274
+ AC_MSG_ERROR ( $error_window_size )
1301
1275
fi
1302
- fi
1303
1276
1304
- case $host in
1305
- dnl Re-enable it after enabling Windows support in cpp-subprocess.
1306
- *mingw*)
1307
- use_external_signer="no"
1277
+ case $set_ecmult_gen_kb in
1278
+ 2)
1279
+ SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DCOMB_BLOCKS=2 -DCOMB_TEETH=5"
1280
+ ;;
1281
+ 22)
1282
+ SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DCOMB_BLOCKS=11 -DCOMB_TEETH=6"
1283
+ ;;
1284
+ 86)
1285
+ SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DCOMB_BLOCKS=43 -DCOMB_TEETH=6"
1286
+ ;;
1287
+ *)
1288
+ AC_MSG_ERROR ( [ 'ecmult gen table size not 2, 22 or 86'] )
1308
1289
;;
1309
1290
esac
1310
1291
if test "$use_external_signer" = "yes"; then
@@ -1514,24 +1495,9 @@ else
1514
1495
fi
1515
1496
fi
1516
1497
1517
- dnl Enable NAT-PMP support.
1518
- AC_MSG_CHECKING ( [ whether to build with support for NAT-PMP] )
1519
- if test "$have_natpmp" = "no"; then
1520
- if test "$use_natpmp" = "yes"; then
1521
- AC_MSG_ERROR ( [ NAT-PMP requested but cannot be built. Use --without-natpmp] )
1522
- fi
1523
- AC_MSG_RESULT ( [ no] )
1524
- use_natpmp=no
1525
- else
1526
- if test "$use_natpmp" != "no"; then
1527
- AC_MSG_RESULT ( [ yes] )
1528
- use_natpmp=yes
1529
- AC_DEFINE ( [ USE_NATPMP] , [ 1] , [ Define to 1 if UPnP support should be compiled in.] )
1530
- if test "$TARGET_OS" = "windows"; then
1531
- NATPMP_CPPFLAGS="$NATPMP_CPPFLAGS -DSTATICLIB -DNATPMP_STATICLIB"
1532
- fi
1533
- else
1534
- AC_MSG_RESULT ( [ no] )
1498
+ if test x"$enable_experimental" = x"no"; then
1499
+ if test x"$set_asm" = x"arm32"; then
1500
+ AC_MSG_ERROR ( [ ARM32 assembly is experimental. Use --enable-experimental to allow.] )
1535
1501
fi
1536
1502
fi
1537
1503
@@ -1784,3 +1750,23 @@ echo " LDFLAGS = $PTHREAD_LIBS $HARDENED_LDFLAGS $SANITIZER_LDFLAGS $CO
1784
1750
echo " AR = $AR"
1785
1751
echo " ARFLAGS = $ARFLAGS"
1786
1752
echo
1753
+ echo " valgrind = $enable_valgrind"
1754
+ echo " CC = $CC"
1755
+ echo " CPPFLAGS = $CPPFLAGS"
1756
+ echo " SECP_CFLAGS = $SECP_CFLAGS"
1757
+ echo " CFLAGS = $CFLAGS"
1758
+ echo " LDFLAGS = $LDFLAGS"
1759
+
1760
+ if test x"$print_msan_notice" = x"yes"; then
1761
+ echo
1762
+ echo "Note:"
1763
+ echo " MemorySanitizer detected, tried to add -fno-sanitize-memory-param-retval to SECP_CFLAGS"
1764
+ echo " to avoid false positives in ctime_tests. Pass --disable-ctime-tests to avoid this."
1765
+ fi
1766
+
1767
+ if test x"$enable_experimental" = x"yes"; then
1768
+ echo
1769
+ echo "WARNING: Experimental build"
1770
+ echo " Experimental features do not have stable APIs or properties, and may not be safe for"
1771
+ echo " production use."
1772
+ fi
0 commit comments