Skip to content

Comments

[fix][build] Hide non-exported symbols from the dependencies#155

Merged
BewareMyPower merged 1 commit intoapache:mainfrom
BewareMyPower:bewaremypower/fix-symbol-hidden
Dec 26, 2022
Merged

[fix][build] Hide non-exported symbols from the dependencies#155
BewareMyPower merged 1 commit intoapache:mainfrom
BewareMyPower:bewaremypower/fix-symbol-hidden

Conversation

@BewareMyPower
Copy link
Contributor

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 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.

### 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.
@BewareMyPower BewareMyPower added this to the 3.2.0 milestone Dec 23, 2022
@BewareMyPower BewareMyPower self-assigned this Dec 23, 2022
@BewareMyPower
Copy link
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

@BewareMyPower BewareMyPower merged commit 3a3e973 into apache:main Dec 26, 2022
@BewareMyPower BewareMyPower deleted the bewaremypower/fix-symbol-hidden branch January 23, 2023 13:37
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants