Hi, On 2023-10-05 13:17:25 -0400, Tom Lane wrote: > I wrote: > > So I experimented with fixing things so that the versions of these > > functions exported by libpq have physically different names from those > > that you'd get from linking to libpgcommon.a or libpgcommon_srv.a. > > Then, there's certainty about which one a given usage will link to, > > based on what the #define environment is when the call is compiled.
I think that's a good plan. IIRC I previously complained about the symbols existing in multiple places... Don't remember the details, IIRCI I saw warnings about symbol conflicts in extensions using libpq. > > This leads to a pleasingly small patch, at least in the Makefile > > universe (I've not attempted to sync the meson or MSVC infrastructure > > with this yet). > > Here's a v2 that addresses the meson infrastructure as well. > (This is my first attempt at writing meson code, so feel free > to critique.) I propose not bothering to fix src/tools/msvc/, > on the grounds that (a) that infrastructure will likely be gone > before v17 ships, and (b) the latent problem with version > skew between libpq.dll and calling programs seems much less > likely to matter in the Windows world in the first place. Makes sense. > +# Note: it's important that we link to encnames.o from libpgcommon, not > +# from libpq, else we have risks of version skew if we run with a libpq > +# shared library from a different PG version. Define > +# USE_PRIVATE_ENCODING_FUNCS to ensure that that happens. > +c_args = default_bin_args.get('c_args', []) + > ['-DUSE_PRIVATE_ENCODING_FUNCS'] > + > initdb = executable('initdb', > initdb_sources, > include_directories: [timezone_inc], > dependencies: [frontend_code, libpq, icu, icu_i18n], > - kwargs: default_bin_args, > + kwargs: default_bin_args + { > + 'c_args': c_args, > + }, I think you can just pass c_args directly to executable() here, I think adding c_args to default_bin_args would be a bad idea. Greetings, Andres Freund