PG12, PGXS and linking pgfeutils - Mailing list pgsql-hackers

From Ian Barwick
Subject PG12, PGXS and linking pgfeutils
Date
Msg-id a912ffff-f6e4-778a-c86a-cf5c47a12933@2ndquadrant.com
Whole thread Raw
Responses Re: PG12, PGXS and linking pgfeutils  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
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-pointerpgxs-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=cc8d41511721d25d557fc02a46c053c0a602fed


Regards


Ian Barwick

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

Attachment

pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: accounting for memory used for BufFile during hash joins
Next
From: Michael Paquier
Date:
Subject: Re: reindexdb & clusterdb broken against pre-7.3 servers