[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ceph-devel
Subject:    Re: Shared library symbol visibility
From:       Josh Durgin <josh.durgin () inktank ! com>
Date:       2013-12-30 23:22:13
Message-ID: 52C20025.1000204 () inktank ! com
[Download RAW message or body]

On 12/30/2013 09:56 AM, Noah Watkins wrote:
> It looks like we may be outgrowing the use of export-symbols-regex and
> friends to control symbol visibility for published shared libraries.
> On Linux, ld seems to be quite content linking against hidden symbols,
> but at least on OSX with Clang it seems the visibility is strictly
> enforced.
>
> For instance, librados exports only the prefix "rados_", but that
> regex hides everything in the C++ interface. Unfortunately,
> export-symbols-regex doesn't play nice with C++ name mangling.
>
> Large projects that I've been looking at for examples (chromium, v8,
> Java) seem to use a different approach based on the compiler flag
> "-fvisibility=hidden" that hides everything by default and uses
> explicit exporting.
>
> These are the basics, and there are variants that work on Windows for
> DLL's as well with more macro magic.
>
> #define CEPH_EXPORT __attribute__((__visibility__("default")))
>
>    class CEPH_EXPORT ObjectOperation {
>      public:
>        ObjectOperation();
>        virtual ~ObjectOperation();
>        ...
>
> There is a sample branch up with this approach at:
>
>     http://github.com/ceph/ceph port/visibility
>
> More info
>
> https://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html
> http://gcc.gnu.org/wiki/Visibility

This is great! It serves as a good reminder when you're touching public
interfaces as well. It may be annoying to add it to everything
initially, but it seems quite nice once it's in place!

Josh
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic