Opened 5 years ago

Last modified 4 years ago

#13048 new Bugs

Static libraries and visibility hidden

Reported by: Mark M <mememory359@…> Owned by:
Milestone: To Be Determined Component: Building Boost
Version: Boost Development Trunk Severity: Problem
Keywords: static library visibility hidden Cc: braden@…

Description

I've been told that I can compile the Boost libraries with "-fvisibility=hidden". But I think it will work only for shared libraries, and I am building static libraries.

If I'm wrong, please point out what I am missing. I will use the Filesystem library as an example, but I think this applies to Boost in general.

There are a number of functions that need to have default visibility to allow the libraries to link with other code without error. These functions have the BOOST_FILESYSTEM_DECL macro in their declaration. I am using Xcode. The config/compiler/clang.hpp file has defined BOOST_SYMBOL_EXPORT with the attribute-visibility-default setting. So I look for code that sets BOOST_FILESYSTEM_DECL to be BOOST_SYMBOL_EXPORT.

When I look at the filesystem/config.hpp file, BOOST_FILESYSTEM_DECL is blank, unless (BOOST_ALL_DYN_LINK or BOOST_FILESYSTEM_DYN_LINK) and BOOST_FILESYSTEM_SOURCE are set. But with static libraries, I don't want those settings, right?

There is another preprocessor macro called BOOST_SYMBOL_VISIBLE, but it is only used one place in filesystem (for the filesystem_error class).

Any help in the right direction would be appreciated. Or if this is an oversight, that would be helpful to know.

Change History (1)

comment:1 by Braden McDaniel <braden@…>, 4 years ago

Cc: braden@… added
Note: See TracTickets for help on using tickets.