Subject: Re: [boost] support for gcc hidden visibility in shared libraries
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2008-12-06 06:37:05
Stjepan Rajko wrote:
>> So it doesn't look like a trivial change in settings and macros to me.
>> What's worst, making such a change can trigger problems that are hardly
>> detected by unit tests. Perhaps, we should just mandate the
>> visibility=hidden mode not supported for now. Maybe
>> --fvisibility-ms-compat or --fvisibility-inlines-hidden would be a
>> better choice to support?
> Sounds good to me, like I said my understanding of this is limited.
> It looks like the list of possible changes, in the order of potential
> breakage danger are:
> 1. add BOOST_SYMBOL_EXPORT / IMPORT config macros [this breaks nothing]
> 2. modify existing boost libraries that use similar macros of their
> own to use the boost.config macros [if the functionality of the new
> macros is a superset of the old macros, shouldn't break anything]
> 3. modify the default boost build to use -fvisibility-ms-compat or
> --fvisibility-inlines-hidden [low risk?]
> 4. modify the default boost build to use -fvisibility-hidden [high risk?]
> The patch by Alexander Arhipenko does 1,2, and 4. Perhaps we can at
> least start with 1, or 1 and 2?
If we are targeting to support -fvisibility=hidden in the end, we should
provide two sets of macros for symbol exporting. One will have the
semantics near to dllexport on Windows and the second will only have the
impact when -fvisibility=hidden is in action. This is needed, for
example, for header-only exception classes. Such classes do not need
dllexport on Windows, but they do need default visibility on Linux.
Personally, I'd rather not support -fvisibility=hidden at all, since,
IMO, this mode is too dangerous and doesn't give much compared to
-fvisibility-ms-compat. I think, the patch from Alexander should be
modified to use -fvisibility-ms-compat on GCC 4.3 and up and
-fvisibility-inlines-hidden on GCC 4.1 to 4.3. It should not restrict
visibility at all on GCC prior to 4.1. This way we will make use of this
feature while being on the safe side.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk