chriskohlhoff / asio

Asio C++ Library
http://think-async.com/Asio
4.86k stars 1.21k forks source link

No option to configure symbol visibility in asio #346

Open rahulj09 opened 5 years ago

rahulj09 commented 5 years ago

As of now all the symbols are exported by asio , since in push_options.hpp we always set symbol visibility to default i.e.https://github.com/chriskohlhoff/asio/blob/master/asio/include/asio/detail/push_options.hpp#L27

We have a requirement where we don't want to export symbols from our dylib but since asio always exports symbols we are facing issues. A simple fix for it to add a pre-processor macro which clients are configure to control symbol visibility. sample code could be like

# if !defined(ASIO_USE_CLIENT_VISIBILITY) && (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
#  pragma GCC visibility push (default)
# endif // (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)

Corresponding PR is https://github.com/chriskohlhoff/asio/pull/347

acmorrow commented 5 years ago

I too would like to see a fix for this. MongoDB vendors ASIO, but also builds some user facing shared libraries that should not export the ASIO symbols. To work around this, we are required to build the shared libraries with export files, rather than relying on visibility macros.

Shempp commented 3 years ago

I think what you are looking for is here: https://github.com/chriskohlhoff/asio/pull/347