@@ -90,6 +90,12 @@ AC_ARG_ENABLE([hardening],
9090 [ use_hardening=$enableval] ,
9191 [ use_hardening=yes] )
9292
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+
9399AC_ARG_ENABLE ( [ ccache] ,
94100 [ AS_HELP_STRING ( [ --enable-ccache] ,
95101 [ use ccache for building (default is yes if ccache is found)] ) ] ,
@@ -396,6 +402,40 @@ AC_TRY_COMPILE([#include <sys/socket.h>],
396402
397403AC_SEARCH_LIBS ( [ clock_gettime] ,[ rt] )
398404
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+ if test x$use_reduce_exports != xno; then
434+ AX_CHECK_LINK_FLAG ( [ [ -Wl,--exclude-libs,ALL] ] , [ RELDFLAGS="-Wl,--exclude-libs,ALL"] )
435+ CXXFLAGS="$CXXFLAGS $RE_CXXFLAGS"
436+ fi
437+ fi
438+
399439LEVELDB_CPPFLAGS=
400440LIBLEVELDB=
401441LIBMEMENV=
420460
421461dnl Check for boost libs
422462AX_BOOST_BASE
463+
464+ if test x$use_reduce_exports != xno; then
465+ AC_MSG_CHECKING ( [ for working boost reduced exports] )
466+ TEMP_CPPFLAGS="$CPPFLAGS"
467+ CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS"
468+ AC_PREPROC_IFELSE ( [ AC_LANG_PROGRAM ( [ [
469+ @%:@ include <boost/version.hpp>
470+ ] ] , [ [
471+ #if BOOST_VERSION >= 104900
472+ // Everything is okay
473+ #else
474+ # error Boost version is too old
475+ #endif
476+ ] ] ) ] ,[
477+ AC_MSG_RESULT ( yes )
478+ ] ,[ :
479+ if test x$use_reduce_exports = xauto; then
480+ use_reduce_exports=no
481+ else
482+ if test x$use_reduce_exports = xyes; then
483+ AC_MSG_ERROR ( [ boost versions < 1.49 are known to be broken with reduced exports. Use --disable-reduced-exports.] )
484+ fi
485+ fi
486+ AC_MSG_RESULT ( no )
487+ AC_MSG_WARN ( [ boost versions < 1.49 are known to have symbol visibility issues. Disabling reduced exports.] )
488+ ] )
489+ CPPFLAGS="$TEMP_CPPFLAGS"
490+ fi
491+
423492AX_BOOST_SYSTEM
424493AX_BOOST_FILESYSTEM
425494AX_BOOST_PROGRAM_OPTIONS
@@ -672,6 +741,13 @@ else
672741 AC_MSG_RESULT ( [ no] )
673742fi
674743
744+ AC_MSG_CHECKING ( [ whether to reduce exports] )
745+ if test x$use_reduce_exports != xno; then
746+ AC_MSG_RESULT ( [ yes] )
747+ else
748+ AC_MSG_RESULT ( [ no] )
749+ fi
750+
675751if test "x$use_tests$build_bitcoind$use_qt" = "xnonono"; then
676752 AC_MSG_ERROR ( [ No targets! Please specify at least one of: --enable-cli --enable-daemon --enable-gui or --enable-tests] )
677753fi
@@ -704,6 +780,7 @@ AC_SUBST(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE)
704780AC_SUBST ( COPYRIGHT_YEAR , _COPYRIGHT_YEAR )
705781
706782
783+ AC_SUBST ( RELDFLAGS )
707784AC_SUBST ( LIBTOOL_LDFLAGS )
708785AC_SUBST ( USE_UPNP )
709786AC_SUBST ( USE_QRCODE )
0 commit comments