Re: Use -fvisibility=hidden for shared libraries

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Justin Pryzby <pryzby@telsasoft.com>, Laurenz Albe <laurenz.albe@cybertec.at>, pgsql-hackers@postgresql.org
Date: 2022-01-11T20:54:19Z
Lists: pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> 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...

I still don't understand what are the conditions for MSVC to complain.
The rule is evidently not that every extern must agree with the function
definition, because for example you added

+extern PGDLLEXPORT void _PG_init(void);

in fmgr.h, but you didn't change any of the existing extern declarations
or definitions for _PG_init functions, and yet everything seems to work.

I had concluded that gcc/clang follow the rule "use an attribute if it
appears on at least one extern for the function", and this seems like
evidence that it works like that in MSVC too.

			regards, tom lane



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