All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Durgin <josh.durgin@inktank.com>
To: Noah Watkins <noah.watkins@inktank.com>,
	"ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>,
	James Harper <james.harper@bendigoit.com.au>,
	Alan Somers <asomers@gmail.com>
Subject: Re: Shared library symbol visibility
Date: Mon, 30 Dec 2013 15:22:13 -0800	[thread overview]
Message-ID: <52C20025.1000204@inktank.com> (raw)
In-Reply-To: <CA+Hcz59Z3_4_je=DfRKeg_SF9kEuusdi9t7TrdA8KeokuqCqpg@mail.gmail.com>

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

      reply	other threads:[~2013-12-30 23:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-30 17:56 Shared library symbol visibility Noah Watkins
2013-12-30 23:22 ` Josh Durgin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52C20025.1000204@inktank.com \
    --to=josh.durgin@inktank.com \
    --cc=asomers@gmail.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=james.harper@bendigoit.com.au \
    --cc=noah.watkins@inktank.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.