pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ian Barwick <ian.barwick@2ndquadrant.com>
To: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: PG12, PGXS and linking pgfeutils
Date: Tue, 7 May 2019 14:24:19 +0900
Message-ID: <a912ffff-f6e4-778a-c86a-cf5c47a12933@2ndquadrant.com> (raw)

Hi

Commit cc8d4151 [*] introduced a dependency between some functions in
libpgcommon and libpgfeutils, which is not reflected in the linker options
provided when building an external program using PGXS, e.g. attempting to
build the attached (trivial) example results in:

     $ PATH=$PG_HEAD:$PATH USE_PGXS=1 make
     gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -ggdb -Og -g3 -fno-omit-frame-pointer -I. -I./ -I/home/ibarwick/devel/builds/HEAD/include/postgresql/server -I/home/ibarwick/devel/builds/HEAD/include/postgresql/internal  -D_GNU_SOURCE   -c -o pgxs-test.o pgxs-test.c
     gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -ggdb -Og -g3 -fno-omit-frame-pointer pgxs-test.o  -L/home/ibarwick/devel/builds/HEAD/lib   -Wl,--as-needed -Wl,-rpath,'/home/ibarwick/devel/builds/HEAD/lib',--enable-new-dtags  -L/home/ibarwick/devel/builds/HEAD/lib -lpgcommon -lpgport -L/home/ibarwick/devel/builds/HEAD/lib -lpq -lpgcommon -lpgport -lpthread -lssl -lcrypto -lgssapi_krb5 -lz -lreadline -lrt -lcrypt -ldl -lm  -o pgxs-test
     /home/ibarwick/devel/builds/HEAD/lib/libpgcommon.a(pgfnames.o): In function `pgfnames':
     /home/ibarwick/devel/postgresql/src/common/pgfnames.c:48: undefined reference to `__pg_log_level'
     /home/ibarwick/devel/postgresql/src/common/pgfnames.c:48: undefined reference to `pg_log_generic'
     /home/ibarwick/devel/postgresql/src/common/pgfnames.c:69: undefined reference to `__pg_log_level'
     /home/ibarwick/devel/postgresql/src/common/pgfnames.c:69: undefined reference to `pg_log_generic'
     /home/ibarwick/devel/postgresql/src/common/pgfnames.c:74: undefined reference to `__pg_log_level'
     /home/ibarwick/devel/postgresql/src/common/pgfnames.c:74: undefined reference to `pg_log_generic'
     collect2: error: ld returned 1 exit status
     make: *** [pgxs-test] Error 1

which is a regression compared to PG11 and earlier.

Workaround/possible fix is to include "pgfeutils" in the "libpq_pgport" definition, i.e.:

     *** a/src/Makefile.global.in
     --- b/src/Makefile.global.in
     *************** libpq = -L$(libpq_builddir) -lpq
     *** 561,567 ****
       # on client link lines, since that also appears in $(LIBS).
       # libpq_pgport_shlib is the same idea, but for use in client shared libraries.
       ifdef PGXS
     ! libpq_pgport = -L$(libdir) -lpgcommon -lpgport $(libpq)
       libpq_pgport_shlib = -L$(libdir) -lpgcommon_shlib -lpgport_shlib $(libpq)
       else
       libpq_pgport = -L$(top_builddir)/src/common -lpgcommon -L$(top_builddir)/src/port -lpgport $(libpq)
     --- 561,567 ----
       # on client link lines, since that also appears in $(LIBS).
       # libpq_pgport_shlib is the same idea, but for use in client shared libraries.
       ifdef PGXS
     ! libpq_pgport = -L$(libdir) -lpgcommon -lpgport -lpgfeutils $(libpq)
       libpq_pgport_shlib = -L$(libdir) -lpgcommon_shlib -lpgport_shlib $(libpq)
       else
       libpq_pgport = -L$(top_builddir)/src/common -lpgcommon -L$(top_builddir)/src/port -lpgport $(libpq)

I presume a similar modification may need to be added to the following lines in
that section but haven't had a chance to look in detail yet (and may be barking
up the wrong tree entirely of course).

[*] https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=cc8d41511721d25d557fc02a46c053c0a...


Regards


Ian Barwick

-- 
  Ian Barwick                   https://www.2ndQuadrant.com/
  PostgreSQL Development, 24x7 Support, Training & Services

Attachments:

Makefile (text/plain, 144B) download PROGRAM = pgxs-test OBJS = pgxs-test.o PG_CONFIG = pg_config PG_LIBS = $(libpq_pgport) PGXS := $(shell $(PG_CONFIG) --pgxs) include $(PGXS)
pgxs-test.c (text/x-csrc, 313B) download #include "postgres.h" #include "fmgr.h" int main(int argc, char **argv) { char **fnames = pgfnames("/tmp"); char *fname = fnames[0]; int total_names = 0; while (fname) { total_names++; fname = fnames[total_names]; } printf("total files: %i\n", total_names); pgfnames_cleanup(fnames); return 0; }

view thread (11+ messages)  latest in thread

Message-ID: <a912ffff-f6e4-778a-c86a-cf5c47a12933@2ndquadrant.com>
Permalink:  ../a912ffff-f6e4-778a-c86a-cf5c47a12933@2ndquadrant.com/
Also on:    postgresql.org/message-id/a912ffff-f6e4-778a-c86a-cf5c47a12933@2ndquadrant.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: ian.barwick@2ndquadrant.com
  Subject: Re: PG12, PGXS and linking pgfeutils
  In-Reply-To: <a912ffff-f6e4-778a-c86a-cf5c47a12933@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox