Skip to content

Commit

Permalink
Fix: set visibility,exclude-libs options to CMAKE_CXX_FLAGS (apache#…
Browse files Browse the repository at this point in the history
…1997)

* Fix: set visibility,exclude-libs options to CMAKE_CXX_FLAGS

* Add GCC visibility push(default) for unit test

* Fix undefined reference to auth plugin methods

* Build _pulsar.so without exclude-libs
  • Loading branch information
hrsakai authored and merlimat committed Jun 21, 2018
1 parent a545c2e commit ef92062
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 56 deletions.
12 changes: 8 additions & 4 deletions pulsar-client-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ endif(NOT CXX_STANDARD)

set(CMAKE_CXX_FLAGS " -msse4.2 -mpclmul -Wno-deprecated-declarations ${CXX_STANDARD} ${CMAKE_CXX_FLAGS}")

if (!APPLE)
# Hide all non-exported symbols to avoid conflicts
set(CMAKE_CXX_FLAGS " -fvisibility=hidden -Wl,--exclude-libs,ALL ${CMAKE_CXX_FLAGS}")
endif ()

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Expand Down Expand Up @@ -164,6 +160,14 @@ else (NOT JSON_INCLUDE_PATH)
set(JSON_INCLUDE_PATH ${JSON_INCLUDE_PATH}/jsoncpp/)
endif (NOT JSON_INCLUDE_PATH)

if (NOT APPLE)
# we don't set options below to build _pulsar.so
set(CMAKE_CXX_FLAGS_PYTHON "${CMAKE_CXX_FLAGS}")
# Hide all non-exported symbols to avoid conflicts
set(CMAKE_CXX_FLAGS " -fvisibility=hidden -Wl,--exclude-libs,ALL ${CMAKE_CXX_FLAGS}")
endif ()


set(ADDITIONAL_LIBRARIES $ENV{PULSAR_ADDITIONAL_LIBRARIES})
link_directories( $ENV{PULSAR_ADDITIONAL_LIBRARY_PATH} )

Expand Down
3 changes: 2 additions & 1 deletion pulsar-client-cpp/lib/BoostHash.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <string>
#include <boost/functional/hash.hpp>

#pragma GCC visibility push(default)
namespace pulsar {
class BoostHash : public Hash {
public:
Expand All @@ -35,5 +36,5 @@ class BoostHash : public Hash {
boost::hash<std::string> hash;
};
} // namespace pulsar

#pragma GCC visibility pop
#endif /* BOOST_HASH_HPP_ */
8 changes: 3 additions & 5 deletions pulsar-client-cpp/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# under the License.
#

file(GLOB PULSAR_SOURCES *.cc lz4/*.c checksum/*.cc stats/*.cc c/*.cc)
file(GLOB PULSAR_SOURCES *.cc lz4/*.c checksum/*.cc stats/*.cc c/*.cc auth/*.cc auth/athenz/*.cc)

execute_process(COMMAND cat ../pom.xml COMMAND xmllint --format - COMMAND sed "s/xmlns=\".*\"//g" COMMAND xmllint --stream --pattern /project/version --debug - COMMAND grep -A 2 "matches pattern" COMMAND grep text COMMAND sed "s/.* [0-9] //g" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE PV)
set (CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -D_PULSAR_VERSION_=\\\"${PV}\\\"")
Expand All @@ -42,8 +42,6 @@ endif(NOT LIBRARY_VERSION)
set_target_properties(pulsarStatic PROPERTIES OUTPUT_NAME ${LIB_NAME} VERSION ${LIBRARY_VERSION})
set_target_properties(pulsarShared PROPERTIES OUTPUT_NAME ${LIB_NAME} VERSION ${LIBRARY_VERSION})

add_subdirectory(auth)

target_link_libraries(pulsarStatic ${COMMON_LIBS} authTls authAthenz ztsClientStatic)
target_link_libraries(pulsarShared ${COMMON_LIBS} authTls authAthenz ztsClientStatic)
target_link_libraries(pulsarStatic ${COMMON_LIBS})
target_link_libraries(pulsarShared ${COMMON_LIBS})

3 changes: 2 additions & 1 deletion pulsar-client-cpp/lib/JavaStringHash.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
#include <string>
#include <boost/functional/hash.hpp>

#pragma GCC visibility push(default)
namespace pulsar {
class JavaStringHash : public Hash {
public:
JavaStringHash();
int32_t makeHash(const std::string &key);
};
} // namespace pulsar

#pragma GCC visibility pop
#endif /* JAVA_DEFAULT_HASH_HPP_ */
2 changes: 2 additions & 0 deletions pulsar-client-cpp/lib/Murmur3_32Hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <cstdint>
#include <string>

#pragma GCC visibility push(default)
namespace pulsar {

class Murmur3_32Hash : public Hash {
Expand All @@ -47,5 +48,6 @@ class Murmur3_32Hash : public Hash {
uint32_t makeHash(const void* key, const int64_t len);
};
} // namespace pulsar
#pragma GCC visibility pop

#endif /* MURMUR3_32_HASH_HPP_ */
2 changes: 2 additions & 0 deletions pulsar-client-cpp/lib/RoundRobinMessageRouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "Hash.h"
#include "MessageRouterBase.h"

#pragma GCC visibility push(default)
namespace pulsar {
class RoundRobinMessageRouter : public MessageRouterBase {
public:
Expand All @@ -39,4 +40,5 @@ class RoundRobinMessageRouter : public MessageRouterBase {
};
typedef boost::unique_lock<boost::mutex> Lock;
} // namespace pulsar
#pragma GCC visibility pop
#endif // PULSAR_RR_MESSAGE_ROUTER_HEADER_
2 changes: 2 additions & 0 deletions pulsar-client-cpp/lib/SinglePartitionMessageRouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <pulsar/TopicMetadata.h>
#include "MessageRouterBase.h"

#pragma GCC visibility push(default)
namespace pulsar {

class SinglePartitionMessageRouter : public MessageRouterBase {
Expand All @@ -39,4 +40,5 @@ class SinglePartitionMessageRouter : public MessageRouterBase {
};

} // namespace pulsar
#pragma GCC visibility pop
#endif // PULSAR_SINGLE_PARTITION_MESSAGE_ROUTER_HEADER_
4 changes: 3 additions & 1 deletion pulsar-client-cpp/lib/TopicMetadataImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <pulsar/TopicMetadata.h>

#pragma GCC visibility push(default)
namespace pulsar {
class TopicMetadataImpl : public TopicMetadata {
public:
Expand All @@ -31,5 +32,6 @@ class TopicMetadataImpl : public TopicMetadata {
int numPartitions_;
};
} // namespace pulsar
#pragma GCC visibility pop

#endif /* TOPIC_METADATA_IMPL_HPP_ */
#endif /* TOPIC_METADATA_IMPL_HPP_ */
23 changes: 0 additions & 23 deletions pulsar-client-cpp/lib/auth/CMakeLists.txt

This file was deleted.

20 changes: 0 additions & 20 deletions pulsar-client-cpp/lib/auth/athenz/CMakeLists.txt

This file was deleted.

4 changes: 3 additions & 1 deletion pulsar-client-cpp/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ ADD_LIBRARY(_pulsar SHARED src/pulsar.cc src/producer.cc src/consumer.cc
SET(CMAKE_SHARED_LIBRARY_PREFIX )
SET(CMAKE_SHARED_LIBRARY_SUFFIX .so)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_PYTHON}")

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup")
endif()

set(PYTHON_WRAPPER_LIBS ${Boost_PYTHON_LIBRARY} ${Boost_PYTHON3_LIBRARY} authTls authAthenz)
set(PYTHON_WRAPPER_LIBS ${Boost_PYTHON_LIBRARY} ${Boost_PYTHON3_LIBRARY})

if (APPLE)
target_link_libraries(_pulsar -Wl,-all_load pulsarStatic ${PYTHON_WRAPPER_LIBS})
Expand Down

0 comments on commit ef92062

Please sign in to comment.