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-07-16T00:13:19Z
Lists: pgsql-hackers
Hi, On 2022-01-11 15:54:19 -0500, Tom Lane wrote: > 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 think I figured that part out now: https://godbolt.org/z/qYqo95fYs It works as long as the *first* declaration has the declspec, later ones don't need it. If the first one does *not* have the declspec but later ones don't, you get "error C2375: 'msvc_fail': redefinition; different linkage". That makes some sort of sense. > 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. So it's not quite the same as with gcc / clang... Greetings, Andres Freund
Commits
-
Mark all symbols exported from extension libraries PGDLLEXPORT.
- 8cf64d35eacc 16.0 landed
-
Default to hidden visibility for extension libraries where possible
- 089480c07705 16.0 landed
-
Remove now superfluous declarations of dlsym()ed symbols.
- fd4bad165539 16.0 landed
-
Add central declarations for dlsym()ed symbols
- f2b73c8d75d5 16.0 landed