@@ -90,6 +90,12 @@ AC_ARG_ENABLE([hardening],
90
90
[ use_hardening=$enableval] ,
91
91
[ use_hardening=yes] )
92
92
93
+ AC_ARG_ENABLE ( [ reduce-exports] ,
94
+ [ AS_HELP_STRING ( [ --enable-reduce-exports] ,
95
+ [ attempt to reduce exported symbols in the resulting executables (default is yes)] ) ] ,
96
+ [ use_reduce_exports=$enableval] ,
97
+ [ use_reduce_exports=auto] )
98
+
93
99
AC_ARG_ENABLE ( [ ccache] ,
94
100
[ AS_HELP_STRING ( [ --enable-ccache] ,
95
101
[ use ccache for building (default is yes if ccache is found)] ) ] ,
@@ -396,6 +402,36 @@ AC_TRY_COMPILE([#include <sys/socket.h>],
396
402
397
403
AC_SEARCH_LIBS ( [ clock_gettime] ,[ rt] )
398
404
405
+ AC_MSG_CHECKING ( [ for visibility attribute] )
406
+ AC_LINK_IFELSE ( [ AC_LANG_SOURCE ( [
407
+ int foo_def( void ) __attribute__((visibility("default")));
408
+ int main(){}
409
+ ] ) ] ,
410
+ [
411
+ AC_DEFINE ( HAVE_VISIBILITY_ATTRIBUTE ,1 ,[ Define if the visibility attribute is supported.] )
412
+ AC_MSG_RESULT ( yes )
413
+ ] ,
414
+ [
415
+ AC_MSG_RESULT ( no )
416
+ if test x$use_reduce_exports = xyes; then
417
+ AC_MSG_ERROR ( [ Cannot find a working visibility attribute. Use --disable-reduced-exports.] )
418
+ fi
419
+ AC_MSG_WARN ( [ Cannot find a working visibility attribute. Disabling reduced exports.] )
420
+ use_reduce_exports=no
421
+ ]
422
+ )
423
+
424
+ if test x$use_reduce_exports != xno; then
425
+ AX_CHECK_COMPILE_FLAG ( [ -fvisibility=hidden] ,[ RE_CXXFLAGS="-fvisibility=hidden"] ,
426
+ [
427
+ if test x$use_reduce_exports = xyes; then
428
+ AC_MSG_ERROR ( [ Cannot set default symbol visibility. Use --disable-reduced-exports.] )
429
+ fi
430
+ AC_MSG_WARN ( [ Cannot set default symbol visibility. Disabling reduced exports.] )
431
+ use_reduce_exports=no
432
+ ] )
433
+ fi
434
+
399
435
LEVELDB_CPPFLAGS=
400
436
LIBLEVELDB=
401
437
LIBMEMENV=
@@ -426,6 +462,40 @@ AX_BOOST_PROGRAM_OPTIONS
426
462
AX_BOOST_THREAD
427
463
AX_BOOST_CHRONO
428
464
465
+
466
+ if test x$use_reduce_exports != xno; then
467
+ AC_MSG_CHECKING ( [ for working boost reduced exports] )
468
+ TEMP_CPPFLAGS="$CPPFLAGS"
469
+ CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS"
470
+ AC_PREPROC_IFELSE ( [ AC_LANG_PROGRAM ( [ [
471
+ @%:@ include <boost/version.hpp>
472
+ ] ] , [ [
473
+ #if BOOST_VERSION >= 104900
474
+ // Everything is okay
475
+ #else
476
+ # error Boost version is too old
477
+ #endif
478
+ ] ] ) ] ,[
479
+ AC_MSG_RESULT ( yes )
480
+ ] ,[ :
481
+ if test x$use_reduce_exports = xauto; then
482
+ use_reduce_exports=no
483
+ else
484
+ if test x$use_reduce_exports = xyes; then
485
+ AC_MSG_ERROR ( [ boost versions < 1.49 are known to be broken with reduced exports. Use --disable-reduced-exports.] )
486
+ fi
487
+ fi
488
+ AC_MSG_RESULT ( no )
489
+ AC_MSG_WARN ( [ boost versions < 1.49 are known to have symbol visibility issues. Disabling reduced exports.] )
490
+ ] )
491
+ CPPFLAGS="$TEMP_CPPFLAGS"
492
+ fi
493
+
494
+ if test x$use_reduce_exports != xno; then
495
+ CXXFLAGS="$CXXFLAGS $RE_CXXFLAGS"
496
+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--exclude-libs,ALL] ] , [ RELDFLAGS="-Wl,--exclude-libs,ALL"] )
497
+ fi
498
+
429
499
if test x$use_tests = xyes; then
430
500
431
501
if test x$HEXDUMP = x; then
@@ -672,6 +742,13 @@ else
672
742
AC_MSG_RESULT ( [ no] )
673
743
fi
674
744
745
+ AC_MSG_CHECKING ( [ whether to reduce exports] )
746
+ if test x$use_reduce_exports != xno; then
747
+ AC_MSG_RESULT ( [ yes] )
748
+ else
749
+ AC_MSG_RESULT ( [ no] )
750
+ fi
751
+
675
752
if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests = xnononono; then
676
753
AC_MSG_ERROR ( [ No targets! Please specify at least one of: --with-utils --with-daemon --with-gui or --enable-tests] )
677
754
fi
@@ -704,6 +781,7 @@ AC_SUBST(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE)
704
781
AC_SUBST ( COPYRIGHT_YEAR , _COPYRIGHT_YEAR )
705
782
706
783
784
+ AC_SUBST ( RELDFLAGS )
707
785
AC_SUBST ( LIBTOOL_LDFLAGS )
708
786
AC_SUBST ( USE_UPNP )
709
787
AC_SUBST ( USE_QRCODE )
0 commit comments