diff --git a/CMakeLists.txt b/CMakeLists.txt index ce6e97247..9d249d16b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ set(sources web_connection_base alert allocator + asio assert bandwidth_limit bandwidth_manager @@ -142,6 +143,7 @@ else (dht) endif (dht) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") +set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fvisibility-inlines-hidden") if (shared) add_library(torrent-rasterbar SHARED ${sources2}) @@ -157,7 +159,7 @@ include_directories(${Boost_INCLUDE_DIR}) target_link_libraries(torrent-rasterbar ${Boost_LIBRARIES}) # this works around a bug in asio in boost-1.39 -add_definitions(-DBOOST_ASIO_HASH_MAP_BUCKETS=1021) +add_definitions(-DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_ASIO_DYN_LINK) if (WIN32) target_link_libraries(torrent-rasterbar wsock32 ws2_32) diff --git a/Jamfile b/Jamfile index 32a51cd18..3d11e1ed7 100755 --- a/Jamfile +++ b/Jamfile @@ -31,6 +31,13 @@ rule linking ( properties * ) { local result ; + if shared in $(properties) + { + # make sure asio symbols are properly exported + # and imported + result += BOOST_ASIO_DYN_LINK ; + } + # openssl libraries, if enabled if openssl in $(properties) { @@ -61,7 +68,6 @@ rule linking ( properties * ) # linker library on linux, required when using openssl result += dl ; } - } if windows in $(properties) @@ -83,11 +89,6 @@ rule linking ( properties * ) result += gcrypt /opt/local/include ; } - if tommath in $(properties) - { - result += src/mpi.c ; - } - if shared in $(properties) { result += GeoIP ; @@ -210,6 +211,11 @@ rule building ( properties * ) result += src/assert.cpp ; } + if tommath in $(properties) + { + result += src/mpi.c ; + } + if static in $(properties) { result += src/GeoIP.c ; @@ -226,6 +232,19 @@ rule building ( properties * ) result += src/pe_crypto.cpp ; } + if ( darwin in $(properties) + || gcc in $(properties) + || clang in $(propertoes) ) + && shared in $(properties) + { + # hide non-external symbols + # use ms-compat because boost.asio (as of 1.47.0 + # appears to have some types not fulle exported) + result += -fvisibility-ms-compat ; + result += -fvisibility-inlines-hidden ; + result += -W1,-Bsymbolic ; + } + return $(result) ; } @@ -406,6 +425,7 @@ lib iphlpapi : : iphlpapi shared ; SOURCES = alert allocator + asio assert bandwidth_limit bandwidth_manager @@ -550,16 +570,8 @@ lib torrent @building system:$(CXXFLAGS) -# hide non-external symbols - darwin:-fvisibility=hidden - darwin:-fvisibility-inlines-hidden - darwin:-W1,-Bsymbolic - gcc:-fvisibility=hidden - gcc:-fvisibility-inlines-hidden - gcc:-W1,-Bsymbolic - llvm:-fvisibility=hidden - llvm:-fvisibility-inlines-hidden - llvm:-W1,-Bsymbolic + # tell asio to export its symbols + shared:BOOST_ASIO_SOURCE $(usage-requirements) diff --git a/configure.ac b/configure.ac index 0901f532b..fb3feb36f 100644 --- a/configure.ac +++ b/configure.ac @@ -98,7 +98,7 @@ AX_PTHREAD() LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$PTHREAD_CFLAGS $CFLAGS -fvisibility=hidden" -CXXFLAGS="$CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden" +CXXFLAGS="$CXXFLAGS -fvisibility-inlines-hidden" CC="$PTHREAD_CC" AS_ECHO @@ -159,7 +159,7 @@ AC_CHECK_FUNCS([clock_gettime], [], dnl Pass some build options to setup.py and .pc file -COMPILETIME_OPTIONS="" +COMPILETIME_OPTIONS="-DBOOST_ASIO_DYN_LINK " ############################################################################### diff --git a/include/libtorrent/utp_stream.hpp b/include/libtorrent/utp_stream.hpp index deada24ab..10726e703 100644 --- a/include/libtorrent/utp_stream.hpp +++ b/include/libtorrent/utp_stream.hpp @@ -44,6 +44,10 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#ifndef BOOST_NO_EXCEPTIONS +#include +#endif + #define CCONTROL_TARGET 100 namespace libtorrent diff --git a/src/Makefile.am b/src/Makefile.am index 0ac812152..357077ac9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,6 +20,7 @@ libtorrent_rasterbar_la_SOURCES = \ web_connection_base.cpp \ alert.cpp \ allocator.cpp \ + asio.cpp \ assert.cpp \ bandwidth_limit.cpp \ bandwidth_manager.cpp \ diff --git a/src/asio.cpp b/src/asio.cpp new file mode 100644 index 000000000..2fa5ef975 --- /dev/null +++ b/src/asio.cpp @@ -0,0 +1,3 @@ +// builds all boost.asio source as a separate compilation unit +#include + diff --git a/test/Jamfile b/test/Jamfile index 9826d1324..34bc97646 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -9,7 +9,7 @@ explicit test_natpmp ; project : requirements - /torrent//torrent + /torrent//torrent/shared main.cpp setup_transfer.cpp : default-build