pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgreSQL.org
Subject: TRANSFORM modules vs. AIX
Date: Sun, 12 Jul 2015 12:17:19 -0400
Message-ID: <20150712161719.GA1087769@tornado.leadboat.com> (raw)
In-Reply-To: <55497B43.9000403@gmx.net>
References: <E1YmNw0-0002Kb-3Q@gemulon.postgresql.org>
	<18844.1430066190@sss.pgh.pa.us>
	<5544E5FB.5060705@gmx.net>
	<22061.1430677636@sss.pgh.pa.us>
	<55497B43.9000403@gmx.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

(was Re: [COMMITTERS] pgsql: Add transforms feature)

On Tue, May 05, 2015 at 10:24:03PM -0400, Peter Eisentraut wrote:
> Any dlopenable module will have undefined symbols, namely those that it
> uses to call back into the executable that loads the module.  The only
> way it can know to not complain about those symbols is if we tell it
> about that executable at build time.  Our current shared library build
> setup makes reference to the postgres executable only on three
> platforms: Windows, OS X, AIX.  All other platforms necessarily accept
> all undefined symbols at build time.  We already know that it can also
> be made to work on Windows and OS X.  I expect that we might need some
> tweaking on AIX, but I'm quite sure it can be made to work there also,

We can address AIX almost exactly like we address Windows, attached.
Relocating an AIX installation will then require adding $(pkglibdir) to
LD_LIBRARY_PATH.  Windows, too, must need the reference from ltree_plpython to
plpython; I'll add it separately.  (It is for PLyUnicode_FromStringAndSize(),
which we omit under Python 2.  The buildfarm's Windows+GCC+Python animal,
frogmouth, uses Python 2.)


contrib/hstore_plperl test coverage revealed a PL/Perl bug found in all
supported branches.  Any import of a native-code module crashes:

  create language plperlu;
  CREATE FUNCTION test1none() RETURNS int LANGUAGE plperlu
    AS $$ use IO; return 0; $$;

"man perlaix" gives the essential clue:

       Note that starting from Perl 5.7.2 (and consequently 5.8.0) and AIX
       4.3 or newer Perl uses the AIX native dynamic loading interface in
       the so called runtime linking mode instead of the emulated interface
       that was used in Perl releases 5.6.1 and earlier or, for AIX releases
       4.2 and earlier.  This change does break backward compatibility with
       compiled modules from earlier perl releases.  The change was made to
       make Perl more compliant with other applications like Apache/mod_perl
       which are using the AIX native interface. This change also enables
       the use of C++ code with static constructors and destructors in perl
       extensions, which was not possible using the emulated interface.

PostgreSQL uses AIX default linking, not AIX runtime linking.  Perl module
shared objects (e.g. IO.so) contain undefined symbols and rely on the runtime
linker to resolve them.  In an executable free from the runtime linker, those
symbols just remain NULL.  I am inclined to back-patch the following:

inline patch 1: src/backend/Makefile (+1/-1 lines) download inline-1.patch--- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -90,3 +90,3 @@ ifeq ($(PORTNAME), aix) postgres: $(POSTGRES_IMP) - $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(call expand_subsys,$(OBJS)) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -o $@ + $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(call expand_subsys,$(OBJS)) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -Wl,-brtllib -o $@
That allows the runtime linker to process modules dlopen()'ed within the postgres executable. To my knowledge, it changes nothing else. At some point, we might switch from AIX default linking to runtime linking. (Concretely, that entails building modules with -Wl,-G and the postgres executable with -Wl,-brtl.) Runtime linking treats undefined symbols and duplicate symbols much more like other modern systems treat them. I don't personally wish to rock this boat to that degree. "ld -lfoo" ignores foo.so, but "ld -brtl -lfoo" prefers foo.so over foo.a. Therefore, such a change wouldn't be back-patch material. Details on AIX shared library linking: http://www-01.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.genprogc/shared_object_runtime_... http://www-01.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.cmds3/ld.htm -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers Patches and attachments: download all (2 files, .tar.gz)
transforms-aix-link-v1.patch (text/plain, 3.5K) download diff --git a/contrib/hstore_plperl/Makefile b/contrib/hstore_plperl/Makefile index 19a8ab4..46ce424 100644 --- a/contrib/hstore_plperl/Makefile +++ b/contrib/hstore_plperl/Makefile @@ -23,12 +23,17 @@ include $(top_builddir)/src/Makefile.global include $(top_srcdir)/contrib/contrib-global.mk endif +# In configurations that forbid undefined symbols in libraries, link with each +# dependency. This does preclude pgxs builds. ifeq ($(PORTNAME), win32) # these settings are the same as for plperl override CPPFLAGS += -DPLPERL_HAVE_UID_GID -Wno-comment -# This means we need an in-tree build on Windows, not a pgxs build SHLIB_LINK += ../hstore/libhstore.a $(wildcard ../../src/pl/plperl/libperl*.a) endif +ifeq ($(PORTNAME), aix) +rpathdir = $(pkglibdir):$(perl_archlibexp)/CORE +SHLIB_LINK += ../hstore/libhstore.exp $(perl_embed_ldflags) +endif # As with plperl we need to make sure that the CORE directory is included # last, probably because it sometimes contains some header files with names diff --git a/contrib/hstore_plpython/Makefile b/contrib/hstore_plpython/Makefile index 6ee434b..9b53d06 100644 --- a/contrib/hstore_plpython/Makefile +++ b/contrib/hstore_plpython/Makefile @@ -23,10 +23,15 @@ include $(top_builddir)/src/Makefile.global include $(top_srcdir)/contrib/contrib-global.mk endif +# In configurations that forbid undefined symbols in libraries, link with each +# dependency. This does preclude pgxs builds. ifeq ($(PORTNAME), win32) -# This means we need an in-tree build on Windows, not a pgxs build SHLIB_LINK += ../hstore/libhstore.a $(wildcard ../../src/pl/plpython/libpython*.a) $(wildcard ../../src/pl/plpython/libplpython*.a) endif +ifeq ($(PORTNAME), aix) +rpathdir = $(pkglibdir):$(python_libdir) +SHLIB_LINK += ../hstore/libhstore.exp $(python_libspec) $(python_additional_libs) $(wildcard ../../src/pl/plpython/libplpython*.exp) +endif REGRESS_OPTS += --load-extension=hstore ifeq ($(python_majorversion),2) diff --git a/contrib/ltree_plpython/Makefile b/contrib/ltree_plpython/Makefile index 64ca127..2fafb8b 100644 --- a/contrib/ltree_plpython/Makefile +++ b/contrib/ltree_plpython/Makefile @@ -23,10 +23,15 @@ include $(top_builddir)/src/Makefile.global include $(top_srcdir)/contrib/contrib-global.mk endif +# In configurations that forbid undefined symbols in libraries, link with each +# dependency. This does preclude pgxs builds. ifeq ($(PORTNAME), win32) -# This means we need an in-tree build on Windows, not a pgxs build SHLIB_LINK += $(wildcard ../../src/pl/plpython/libpython*.a) endif +ifeq ($(PORTNAME), aix) +rpathdir = $(pkglibdir):$(python_libdir) +SHLIB_LINK += $(python_libspec) $(python_additional_libs) $(wildcard ../../src/pl/plpython/libplpython*.exp) +endif REGRESS_OPTS += --load-extension=ltree ifeq ($(python_majorversion),2) diff --git a/src/Makefile.shlib b/src/Makefile.shlib index 50c3805..86db52f 100644 --- a/src/Makefile.shlib +++ b/src/Makefile.shlib @@ -111,6 +111,7 @@ ifeq ($(PORTNAME), aix) shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) endif haslibarule = yes + # $(exports_file) is also usable as an import file exports_file = lib$(NAME).exp endif @@ -341,7 +342,7 @@ $(shlib) $(stlib): $(OBJS) | $(SHLIB_PREREQS) rm -f $(stlib) $(LINK.static) $(stlib) $^ $(RANLIB) $(stlib) - $(MKLDEXPORT) $(stlib) >$(exports_file) + $(MKLDEXPORT) $(stlib) $(shlib) >$(exports_file) $(COMPILER) -o $(shlib) $(stlib) -Wl,-bE:$(exports_file) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) rm -f $(stlib) $(AR) $(AROPT) $(stlib) $(shlib)

Message-ID: <20150712161719.GA1087769@tornado.leadboat.com>
Permalink:  ../20150712161719.GA1087769@tornado.leadboat.com/
Also on:    postgresql.org/message-id/20150712161719.GA1087769@tornado.leadboat.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: noah@leadboat.com, peter_e@gmx.net, tgl@sss.pgh.pa.us, pgsql-hackers@postgreSQL.org
  Subject: Re: TRANSFORM modules vs. AIX
  In-Reply-To: <20150712161719.GA1087769@tornado.leadboat.com>
  References: <E1YmNw0-0002Kb-3Q@gemulon.postgresql.org> <18844.1430066190@sss.pgh.pa.us> <5544E5FB.5060705@gmx.net> <22061.1430677636@sss.pgh.pa.us> <55497B43.9000403@gmx.net> <20150712161719.GA1087769@tornado.leadboat.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