Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZEJxq-0000i9-JY for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Jul 2015 16:18:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZEJxp-0006iB-T2 for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Jul 2015 16:18:49 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZEJwV-0005Fb-Bw for pgsql-hackers@postgresql.org; Sun, 12 Jul 2015 16:17:27 +0000 Received: from mail-pd0-x236.google.com ([2607:f8b0:400e:c02::236]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZEJwR-0001Sj-Vg for pgsql-hackers@postgresql.org; Sun, 12 Jul 2015 16:17:25 +0000 Received: by pdbep18 with SMTP id ep18so211106401pdb.1 for ; Sun, 12 Jul 2015 09:17:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=JH+l+K8+/TSD93MREv30gTTtLCx25izQETN32osMdgA=; b=fuPOhq3KgyugUtGmsyauH7pP0g5yz/x5tiZYVrzWzw7irG6+5zSuWnFcGklrci6zHd UvE0MiZDBUhkC3ZyBUY5Jch4ve6zFsCzTm5sq3gGVpGNwWmzKAiL8/ZczzSw5iHZiqfv ud3tdX6Z4snJ8K+3K9Q+82cz7RZ19bCJOt+5U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=JH+l+K8+/TSD93MREv30gTTtLCx25izQETN32osMdgA=; b=mYNo12GHOGPx9td+I23crEGGRaUfU3oPnOlB3bvmag3fsIOk3I54A7+Oqkhkj6Ulcx g4mUAUCkk6UL/ufoDOMiu+Y08Cj8RXm3rRtd/kZOx2NonjlDD9JkFlQFxeXxarMxBbyq 2aat6ihRmaUaH1J8FuWF/dANpNYuDEBJ3WOZOg87GROOsyW8yYNdlUmU0okgZzLgzUYd QAeqkXBZgCw+PSJpzZYiZfKkwceyyCk3qkZdoUvzeX0RbzCI+hSSjc78T0rPoHWfrvV8 i+OUT3M+mSNFKUccOXzzNge2+k2raNex4QRq+OxeA9J1suz07Fj2JjQ5s3uPYlaFilfi lawg== X-Gm-Message-State: ALoCoQmmI7jccF6unGrrv/VGn0ps1TXXAMYLsVRFQlM0qTNm9XgkU1QER/UYLQ3WDWKhqj8E2dwr X-Received: by 10.67.11.9 with SMTP id ee9mr61985076pad.83.1436717842847; Sun, 12 Jul 2015 09:17:22 -0700 (PDT) Received: from tornado.leadboat.com (c-98-248-47-228.hsd1.ca.comcast.net. [98.248.47.228]) by smtp.gmail.com with ESMTPSA id gp1sm15623223pbd.64.2015.07.12.09.17.21 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 12 Jul 2015 09:17:22 -0700 (PDT) Date: Sun, 12 Jul 2015 12:17:19 -0400 From: Noah Misch To: Peter Eisentraut Cc: Tom Lane , pgsql-hackers@postgreSQL.org Subject: TRANSFORM modules vs. AIX Message-ID: <20150712161719.GA1087769@tornado.leadboat.com> References: <18844.1430066190@sss.pgh.pa.us> <5544E5FB.5060705@gmx.net> <22061.1430677636@sss.pgh.pa.us> <55497B43.9000403@gmx.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="+g7M9IMkV8truYOl" Content-Disposition: inline In-Reply-To: <55497B43.9000403@gmx.net> User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --+g7M9IMkV8truYOl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline (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: --- 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_linking.htm http://www-01.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.cmds3/ld.htm --+g7M9IMkV8truYOl Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="transforms-aix-link-v1.patch" 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) --+g7M9IMkV8truYOl Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --+g7M9IMkV8truYOl--