Skip to content

Commit f28a1c8

Browse files
committed
[fix][build] Hide non-exported symbols from the dependencies (#155)
### Motivation Currently the released libraries don't hide the symbols from the dependencies, it can be verified by the following steps on Ubuntu: ```bash curl -O -L https://archive.apache.org/dist/pulsar/pulsar-client-cpp-3.1.0/deb-x86_64/apache-pulsar-client.deb apt install ./apache-pulsar-client.deb nm -D /usr/lib/libpulsar.so | grep curl ``` You will see lots of symbols from libcurl are included in `libpulsar.so`: ``` 0000000000709f50 T curl_easy_cleanup 000000000070a000 T curl_easy_duphandle ... ``` The root cause is that `-Wl,--exclude-libs,ALL` is added as the compile option, but it should work as a link option. ### Modifications Use `add_link_options` to add `-Wl,--exclude-libs=ALL` as the link option. It seems that `=ALL` should be correct but `,ALL` also works. (cherry picked from commit 3a3e973)
1 parent 9350d1b commit f28a1c8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# under the License.
1818
#
1919

20-
cmake_minimum_required(VERSION 3.4)
20+
cmake_minimum_required(VERSION 3.13)
2121

2222
project (pulsar-cpp)
2323
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake_modules")
@@ -290,7 +290,7 @@ if (NOT APPLE AND NOT MSVC)
290290
# Hide all non-exported symbols to avoid conflicts
291291
add_compile_options(-fvisibility=hidden)
292292
if (CMAKE_COMPILER_IS_GNUCC)
293-
add_compile_options(-Wl,--exclude-libs,ALL)
293+
add_link_options(-Wl,--exclude-libs=ALL)
294294
endif ()
295295
endif ()
296296

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Pulsar C++ client uses [doxygen](https://www.doxygen.nl) to build API documents.
3030
## Requirements
3131

3232
* A C++ compiler that supports C++11, like GCC >= 4.8
33-
* CMake >= 3.4
33+
* CMake >= 3.13
3434
* [Boost](http://www.boost.org/)
3535
* [Protocol Buffer](https://developers.google.com/protocol-buffers/) >= 3
3636
* [libcurl](https://curl.se/libcurl/)

0 commit comments

Comments
 (0)