Re: Use -fvisibility=hidden for shared libraries

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: Use -fvisibility=hidden for shared libraries
Дата
Msg-id 20220716001319.xcu2gecs64mz62a5@awork3.anarazel.de
обсуждение исходный текст
Ответ на Re: Use -fvisibility=hidden for shared libraries  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Jonathan S. Katz"
Дата:
Сообщение: Re: PG15 beta1 sort performance regression due to Generation context change
Следующее
От: Jacob Champion
Дата:
Сообщение: Re: Commitfest Update