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: Peter Eisentraut <peter.eisentraut@enterprisedb.com>, Laurenz Albe <laurenz.albe@cybertec.at>, pgsql-hackers@postgresql.org
Date: 2022-09-01T21:19:35Z
Lists: pgsql-hackers

Attachments

Hi,

On 2022-07-27 14:02:28 -0400, Tom Lane wrote:
> Andres Freund <andres@anarazel.de> writes:
> > On 2022-07-18 00:05:16 -0700, Andres Freund wrote:
> >> Given that that's just about all compilers we support using configure, perhaps
> >> we should just move that out of the compiler specific section? Doesn't look
> >> like there's much precedent for that so far...
> 
> > Here's a potential patch along those lines.
> 
> Now that the dust from the main patch is pretty well settled, +1
> for trying that.

Here's an updated patch for this (also shared recently on another thread). I
was wrong earlier saying that -fvisibility works for xlc - it is accepted, but
just as some sort of input file. We do need -qvisibility.

I tested it on aix and solaris, both with gcc and their proprietary compilers
and confirmed that it indeed does reduce the number of exposed symbols.

I also attached the aix patch to not use mkldexport for extension anymore, as
I tested the patches in that order. I plan to push the aix one as soon as as
hoverfly and sungazer ran once after e5484554ba9.


> > I wonder if we also should move the -fno-strict-aliasing, -fwrapv tests
> > out. But that'd be something for later.
> 
> Those seem less likely to be portable to non-gcc-alike compilers.
> On the other hand, maybe it'd be interesting to just remove the
> conditionality temporarily and try ALL the switches on all compilers,
> just to see what we can learn from the buildfarm.

Unfortunately, given the discovery of xlc accepting -f... silently that's
probably not feasible. We'd have to make it at least conditional on not being
xlc. Everything else we support does seem to be ok with -fxxx flags.

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