Boost logo

Boost :

Subject: Re: [boost] [all] Request for out of the box visibility support
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2018-08-17 08:10:33


On 08/17/18 09:21, Antony Polukhin via Boost wrote:
> I'd like to draw attention to a problem with Boost binaries for Linux.
>
> There's an awesome -fvisibility=hidden flag for Linux compilers that
> improves load times, performance, size of binaries and reduces the
> chance of symbol collisions. More info at
> https://gcc.gnu.org/wiki/Visibility .
>
> Unfortunately, most of the Boost libraries do not set it by default:
> - atomic
> - chrono
> - container
> - context
> - contract
> - coroutine
> - date_time
> - exception
> - fiber
> - filesystem
> - graph
> - graph_parallel
> - iostreams
> - locale
> - mpi
> - program_options
> - python
> - random
> - regex
> - signals
> - system
> - test
> - thread
> - timer
> - type_erasure
> - wave
>
> Moreover minority of the above libraries just do not work with the
> flag. Users just can not run ./b2 cxxflags="-fvisibility=hidden"
> because there's a chance that some library could stop linking.
> Actually things are even more ugly. Linux distributions usually do not
> tune the build flags for each package so at least Debian based
> distributions build Boost with default flags. Users get suboptimal
> builds.
>
>
>
> If you're a maintainer of one of the above libraries *please do* the
> following steps:
> * Make sure that all the public symbols are accordingly marked with
> appropriate BOOST_SYMBOL_* macro. Instruction is available here:
> https://www.boost.org/doc/libs/1_68_0/libs/config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_for_libraries_with_separate_source_code.macros_controlling_shared_library_symbol_visibility
> * Turn on the visibility=hidden by default:
> * by adding <target-os>linux:<cxxflags>"-fvisibility=hidden" to
> the Jamfile if you do not care much for antique compilers (Example
> https://github.com/boostorg/stacktrace/blob/819f2b1c861dec7530372a990ecabab7f5fef48f/build/Jamfile.v2#L11
> )
> * by using a more advanced technique for detecting the flag
> availability (For example see
> https://github.com/boostorg/math/blob/develop/build/Jamfile.v2#L20 or
> https://github.com/boostorg/log/blob/develop/build/Jamfile.v2#L24 )
>
>
> P.S.: I would appreciate any comments or updates on the feature request.
> P.P.S.: Log, Math, Serialization (and Stacktrace) libraries already
> use that flag by default. Many thanks!

I wonder if we should update Boost.Build instead and set visibility to
hidden by default. For libraies that need other visibility we could
offer a property.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk