Browse Source

build: add option for reducing exports

Enabled automatically if boost >= 1.49.
See: https://svn.boost.org/trac/boost/ticket/2309

Also, check for a default visibility attribute, so that we can mark future
api functions correctly.
0.10
Cory Fields 10 years ago
parent
commit
4975ae1722
  1. 77
      configure.ac
  2. 3
      src/Makefile.am
  3. 2
      src/Makefile.qt.include
  4. 2
      src/Makefile.qttest.include
  5. 1
      src/Makefile.test.include

77
configure.ac

@ -90,6 +90,12 @@ AC_ARG_ENABLE([hardening],
[use_hardening=$enableval], [use_hardening=$enableval],
[use_hardening=yes]) [use_hardening=yes])
AC_ARG_ENABLE([reduce-exports],
[AS_HELP_STRING([--enable-reduce-exports],
[attempt to reduce exported symbols in the resulting executables (default is yes)])],
[use_reduce_exports=$enableval],
[use_reduce_exports=auto])
AC_ARG_ENABLE([ccache], AC_ARG_ENABLE([ccache],
[AS_HELP_STRING([--enable-ccache], [AS_HELP_STRING([--enable-ccache],
[use ccache for building (default is yes if ccache is found)])], [use ccache for building (default is yes if ccache is found)])],
@ -396,6 +402,40 @@ AC_TRY_COMPILE([#include <sys/socket.h>],
AC_SEARCH_LIBS([clock_gettime],[rt]) AC_SEARCH_LIBS([clock_gettime],[rt])
AC_MSG_CHECKING([for visibility attribute])
AC_LINK_IFELSE([AC_LANG_SOURCE([
int foo_def( void ) __attribute__((visibility("default")));
int main(){}
])],
[
AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE,1,[Define if the visibility attribute is supported.])
AC_MSG_RESULT(yes)
],
[
AC_MSG_RESULT(no)
if test x$use_reduce_exports = xyes; then
AC_MSG_ERROR([Cannot find a working visibility attribute. Use --disable-reduced-exports.])
fi
AC_MSG_WARN([Cannot find a working visibility attribute. Disabling reduced exports.])
use_reduce_exports=no
]
)
if test x$use_reduce_exports != xno; then
AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[RE_CXXFLAGS="-fvisibility=hidden"],
[
if test x$use_reduce_exports = xyes; then
AC_MSG_ERROR([Cannot set default symbol visibility. Use --disable-reduced-exports.])
fi
AC_MSG_WARN([Cannot set default symbol visibility. Disabling reduced exports.])
use_reduce_exports=no
])
if test x$use_reduce_exports != xno; then
AX_CHECK_LINK_FLAG([[-Wl,--exclude-libs,ALL]], [RELDFLAGS="-Wl,--exclude-libs,ALL"])
CXXFLAGS="$CXXFLAGS $RE_CXXFLAGS"
fi
fi
LEVELDB_CPPFLAGS= LEVELDB_CPPFLAGS=
LIBLEVELDB= LIBLEVELDB=
LIBMEMENV= LIBMEMENV=
@ -420,6 +460,35 @@ fi
dnl Check for boost libs dnl Check for boost libs
AX_BOOST_BASE AX_BOOST_BASE
if test x$use_reduce_exports != xno; then
AC_MSG_CHECKING([for working boost reduced exports])
TEMP_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS"
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
@%:@include <boost/version.hpp>
]], [[
#if BOOST_VERSION >= 104900
// Everything is okay
#else
# error Boost version is too old
#endif
]])],[
AC_MSG_RESULT(yes)
],[:
if test x$use_reduce_exports = xauto; then
use_reduce_exports=no
else
if test x$use_reduce_exports = xyes; then
AC_MSG_ERROR([boost versions < 1.49 are known to be broken with reduced exports. Use --disable-reduced-exports.])
fi
fi
AC_MSG_RESULT(no)
AC_MSG_WARN([boost versions < 1.49 are known to have symbol visibility issues. Disabling reduced exports.])
])
CPPFLAGS="$TEMP_CPPFLAGS"
fi
AX_BOOST_SYSTEM AX_BOOST_SYSTEM
AX_BOOST_FILESYSTEM AX_BOOST_FILESYSTEM
AX_BOOST_PROGRAM_OPTIONS AX_BOOST_PROGRAM_OPTIONS
@ -672,6 +741,13 @@ else
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
fi fi
AC_MSG_CHECKING([whether to reduce exports])
if test x$use_reduce_exports != xno; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
if test "x$use_tests$build_bitcoind$use_qt" = "xnonono"; then if test "x$use_tests$build_bitcoind$use_qt" = "xnonono"; then
AC_MSG_ERROR([No targets! Please specify at least one of: --enable-cli --enable-daemon --enable-gui or --enable-tests]) AC_MSG_ERROR([No targets! Please specify at least one of: --enable-cli --enable-daemon --enable-gui or --enable-tests])
fi fi
@ -704,6 +780,7 @@ AC_SUBST(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE)
AC_SUBST(COPYRIGHT_YEAR, _COPYRIGHT_YEAR) AC_SUBST(COPYRIGHT_YEAR, _COPYRIGHT_YEAR)
AC_SUBST(RELDFLAGS)
AC_SUBST(LIBTOOL_LDFLAGS) AC_SUBST(LIBTOOL_LDFLAGS)
AC_SUBST(USE_UPNP) AC_SUBST(USE_UPNP)
AC_SUBST(USE_QRCODE) AC_SUBST(USE_QRCODE)

3
src/Makefile.am

@ -262,6 +262,7 @@ endif
bitcoind_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) bitcoind_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS)
bitcoind_CPPFLAGS = $(BITCOIN_INCLUDES) bitcoind_CPPFLAGS = $(BITCOIN_INCLUDES)
bitcoind_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS)
# bitcoin-cli binary # # bitcoin-cli binary #
bitcoin_cli_LDADD = \ bitcoin_cli_LDADD = \
@ -299,10 +300,12 @@ endif
bitcoin_tx_SOURCES = bitcoin-tx.cpp bitcoin_tx_SOURCES = bitcoin-tx.cpp
bitcoin_tx_CPPFLAGS = $(BITCOIN_INCLUDES) bitcoin_tx_CPPFLAGS = $(BITCOIN_INCLUDES)
# #
bitcoin_tx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS)
if TARGET_WINDOWS if TARGET_WINDOWS
bitcoin_cli_SOURCES += bitcoin-cli-res.rc bitcoin_cli_SOURCES += bitcoin-cli-res.rc
endif endif
bitcoin_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS)
CLEANFILES = leveldb/libleveldb.a leveldb/libmemenv.a *.gcda *.gcno CLEANFILES = leveldb/libleveldb.a leveldb/libmemenv.a *.gcda *.gcno

2
src/Makefile.qt.include

@ -362,7 +362,7 @@ qt_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL)
if USE_LIBSECP256K1 if USE_LIBSECP256K1
qt_bitcoin_qt_LDADD += secp256k1/libsecp256k1.la qt_bitcoin_qt_LDADD += secp256k1/libsecp256k1.la
endif endif
qt_bitcoin_qt_LDFLAGS = $(AM_LDFLAGS) $(QT_LDFLAGS) qt_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS)
#locale/foo.ts -> locale/foo.qm #locale/foo.ts -> locale/foo.qm
QT_QM=$(QT_TS:.ts=.qm) QT_QM=$(QT_TS:.ts=.qm)

2
src/Makefile.qttest.include

@ -36,7 +36,7 @@ qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBIT
if USE_LIBSECP256K1 if USE_LIBSECP256K1
qt_test_test_bitcoin_qt_LDADD += secp256k1/libsecp256k1.la qt_test_test_bitcoin_qt_LDADD += secp256k1/libsecp256k1.la
endif endif
qt_test_test_bitcoin_qt_LDFLAGS = $(AM_LDFLAGS) $(QT_LDFLAGS) qt_test_test_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS)
CLEAN_BITCOIN_QT_TEST = $(TEST_QT_MOC_CPP) qt/test/*.gcda qt/test/*.gcno CLEAN_BITCOIN_QT_TEST = $(TEST_QT_MOC_CPP) qt/test/*.gcda qt/test/*.gcno

1
src/Makefile.test.include

@ -75,6 +75,7 @@ if USE_LIBSECP256K1
endif endif
test_test_bitcoin_LDADD += $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) test_test_bitcoin_LDADD += $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS)
test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS)
nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES) nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES)

Loading…
Cancel
Save