Re: Mark all GUC variable as PGDLLIMPORT

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Julien Rouhaud <rjuju123@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Michael Paquier <michael@paquier.xyz>, pgsql-hackers@lists.postgresql.org
Date: 2022-02-13T03:59:56Z
Lists: pgsql-hackers
Hi,


On 2021-08-23 14:53:34 +0800, Julien Rouhaud wrote:
> So since the non currently explicitly exported GUC global variables shouldn't
> be accessible by third-party code, I'm attaching a POC patch that does the
> opposite of v1: enforce that restriction using a new pg_attribute_hidden()
> macro, defined with GCC only, to start discussing that topic.

This fails on cfbot: https://cirrus-ci.com/task/6424663592009728?logs=build#L1


I'm not feeling a lot of enthusiasm for the change. But if we were to do this,
we'd have to have infrastructure to detect missing hidden declarations,
otherwise it's inevitable that they don't get added.

I kind of like the idea of hiding postgres symbols for other reasons than
win<->everything else parity. Namely that not exporting symbols can allow the
compiler to optimize more...

Greetings,

Andres Freund



Commits

  1. Remove PGDLLIMPORT marker from __pg_log_level

  2. Mark a few 'bbsink' related functions / variables static.

  3. Add some missing PGDLLIMPORT markings

  4. Apply PGDLLIMPORT markings broadly.

  5. Helper script to apply PGDLLIMPORT markings.

  6. Simplify declaring variables exported from libpgcommon and libpgport.