Re: Use -fvisibility=hidden for shared libraries

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Justin Pryzby <pryzby@telsasoft.com>, Laurenz Albe <laurenz.albe@cybertec.at>, pgsql-hackers@postgresql.org
Date: 2022-01-11T05:42:52Z
Lists: pgsql-hackers
Hi,

On 2022-01-10 23:44:06 -0500, Tom Lane wrote:
> Andres Freund <andres@anarazel.de> writes:
> > On 2022-01-10 21:11:07 -0600, Justin Pryzby wrote:
> >> Without the patch, it fails under windows like:
> 
> > Ah, yea. It's about matching the declarations in ltree.h with the
> > PG_FUNCTION_INFO_V1() one.
> 
> > What is bugging me is that I am fairly sure that my local compilers at some
> > point complained about such mismatches on linux as well. But I can't reproduce
> > that right now :/

Now I wonder if I just saw it when cross compiling locally...


> Ah, I wondered about that.  I'd sort of expected warnings from
> mismatched declarations, but I didn't see any on Linux or macOS.

There are warnings when the declarations "explicitly" mismatch, e.g. one with
__attribute__((visibility("hidden"))) and one with
__attribute__((visibility("default"))). But -fvisibility=hidden isn't
sufficient.

Which makes sense to some degree, because of -fvisibility not applying to
extern declarations... But it's still annoying.

Greetings,

Andres Freund



Commits

  1. Mark all symbols exported from extension libraries PGDLLEXPORT.

  2. Default to hidden visibility for extension libraries where possible

  3. Remove now superfluous declarations of dlsym()ed symbols.

  4. Add central declarations for dlsym()ed symbols