(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
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)
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers