|
Boost : |
Subject: Re: [boost] [config] GCC symbol visibility across shared libraries
From: Beman Dawes (bdawes_at_[hidden])
Date: 2010-05-19 09:30:24
On Thu, May 6, 2010 at 12:42 PM, Jürgen Hunold <juergen.hunold_at_[hidden]> wrote:
> I've got a working patch set lying around. Please find it attached.
> Real life got in the way (as usual)...
Your patch has been VERY helpful, and I've used it as the starting
point! Thanks!
> The patch introduces two Boost.Config macros
> - BOOST_SYMBOL_EXPORT
> - BOOST_SYMBOL_IMPORT
AFAICT, a third macro is needed for GCC. I've named it
BOOST_SYMBOL_VISIBLE and define it as
__attribute__((visibility("default")))
The need for this macro arises in header only classes like this:
class BOOST_SYMBOL_VISIBLE my_exception : public std::runtime_error { ... };
If you use BOOST_SYMBOL_EXPORT, VC++ will warn because
__declspec(dllexport) isn't valid in this context. If you don't
decorate my_exception at all, VC++ is happy, but GCC shared libraries
compiled with -fvisibility=hidden can't successfully throw exceptions
up to callers outside the shared library. The only way around that I
can see is to use a separate macro that is only defined for GCC.
In addition to that change, I've moved the definitions from win32.hpp
into the specific compilers involved. These visibility macros are
compiler extensions to C++, and are starting to show up in platforms
other than Windows.
I've also edited the docs changes somewhat.
So far, I've only made changes to Boost.System. See the attached.
(I've also made a lot of tweaks to Boost.System tests, but those are
of limited interest so aren't included in the attached diff.)
Unless there are objections, I'll commit these to trunk, and wait
until tests have cycled for several days before doing anything with
other libraries. We will want to alert developers of other libraries,
as some of them will prefer to make their own changes. Others will be
happy if someone else makes the changes.
Comments appreciated!
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk