Add central declarations for dlsym()ed symbols
authorAndres Freund <[email protected]>
Mon, 18 Jul 2022 00:23:42 +0000 (17:23 -0700)
committerAndres Freund <[email protected]>
Mon, 18 Jul 2022 00:23:42 +0000 (17:23 -0700)
This is in preparation for defaulting to -fvisibility=hidden in extensions,
instead of exporting all symbols. For that symbols intended to be exported
need to be tagged with PGDLLEXPORT. Most extensions only need to do so for
_PG_init() and functions defined with PG_FUNCTION_INFO_V1. Adding central
declarations avoids each extension having to add PGDLLEXPORT. Any existing
declarations in extensions will continue to work if fmgr.h is included before
them, otherwise compilation for Windows will fail.

Author: Andres Freund <[email protected]>
Reviewed-By: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/20211101020311[email protected]

src/include/fmgr.h
src/include/jit/jit.h
src/include/postmaster/pgarch.h
src/include/replication/output_plugin.h

index 5314b737052cdc42dc26e86399732fb9d61edc81..f251ac9ba2bc8de86dde4d33f367a050c0abccd7 100644 (file)
@@ -424,6 +424,17 @@ CppConcat(pg_finfo_,funcname) (void) \
 extern int no_such_variable
 
 
+/*
+ * Declare _PG_init/_PG_fini centrally. Historically each shared library had
+ * its own declaration; but now that we want to mark these PGDLLEXPORT, using
+ * central declarations avoids each extension having to add that.  Any
+ * existing declarations in extensions will continue to work if fmgr.h is
+ * included before them, otherwise compilation for Windows will fail.
+ */
+extern PGDLLEXPORT void _PG_init(void);
+extern PGDLLEXPORT void _PG_fini(void);
+
+
 /*-------------------------------------------------------------------------
  *     Support for verifying backend compatibility of loaded modules
  *
index d1940332094ab6d09626520d1853246045537035..600ddfc753939c86bac12167e5ba64bc041453c4 100644 (file)
@@ -63,7 +63,7 @@ typedef struct JitContext
 
 typedef struct JitProviderCallbacks JitProviderCallbacks;
 
-extern void _PG_jit_provider_init(JitProviderCallbacks *cb);
+extern PGDLLEXPORT void _PG_jit_provider_init(JitProviderCallbacks *cb);
 typedef void (*JitProviderInit) (JitProviderCallbacks *cb);
 typedef void (*JitProviderResetAfterErrorCB) (void);
 typedef void (*JitProviderReleaseContextCB) (JitContext *context);
index f366a159a8efa156f7b0fe6d2a6c3033e84921bf..2546e2ae8838391bb6a1623a2f7ee98e221d2925 100644 (file)
@@ -63,6 +63,8 @@ typedef struct ArchiveModuleCallbacks
  */
 typedef void (*ArchiveModuleInit) (ArchiveModuleCallbacks *cb);
 
+extern PGDLLEXPORT void _PG_archive_module_init(ArchiveModuleCallbacks *cb);
+
 /*
  * Since the logic for archiving via a shell command is in the core server
  * and does not need to be loaded via a shared library, it has a special
index 539dc8e6974a7b7d86635c437056976176a65c14..b7d28d7045ca5bb0a3830241f6fc455b5f54b1dd 100644 (file)
@@ -35,6 +35,8 @@ typedef struct OutputPluginOptions
  */
 typedef void (*LogicalOutputPluginInit) (struct OutputPluginCallbacks *cb);
 
+extern PGDLLEXPORT void _PG_output_plugin_init(struct OutputPluginCallbacks *cb);
+
 /*
  * Callback that gets called in a user-defined plugin. ctx->private_data can
  * be set to some private data.