[fix][build] Hide non-exported symbols from the dependencies#155
Merged
BewareMyPower merged 1 commit intoapache:mainfrom Dec 26, 2022
Merged
Conversation
### 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.
Contributor
Author
|
I tried to build the x64 deb package in my local env, it does not include the symbols from libcurl or openssl. $ nm -D /usr/lib/libpulsar.so | grep curl
0000000000bab180 B _ZN6pulsar9TopicName15curlHandleMutexE
0000000000bab1a8 B _ZN6pulsar9TopicName4curlE
$ nm -D /usr/lib/libpulsar.so | grep SSL |
shibd
approved these changes
Dec 26, 2022
tisonkun
approved these changes
Dec 26, 2022
BewareMyPower
added a commit
that referenced
this pull request
Jan 23, 2023
### 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Currently the released libraries don't hide the symbols from the dependencies, it can be verified by the following steps on Ubuntu:
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 curlYou will see lots of symbols from libcurl are included in
libpulsar.so:The root cause is that
-Wl,--exclude-libs,ALLis added as the compile option, but it should work as a link option.Modifications
Use
add_link_optionsto add-Wl,--exclude-libs=ALLas the link option. It seems that=ALLshould be correct but,ALLalso works.