Re: [PATCHES] Linking on AIX (Was: Fix linking of OpenLDAP libraries )
The patch did not work for me :-(
My buildfarm members failed in local testing to execute the
install-check, because initdb failed to find libpq.so.Make check did succeed, so I think there is a possibility of
getting it
working, but it won't be as simple as adding -brtl to the template.
I suspect that up to now the buildfarm had a static build of
PostgreSQL. What is the output of 'ldd initdb' when it builds
and runs correctly?
Is libpq.so in a non-standard directory? If yes, one either
has to export LIBPATH in the environment or link with
-L/location/of/libpq for the executable to find it
(similar to RPATH in Linux).
Yours,
Laurenz Albe
"Albe Laurenz" <all@adv.magwien.gv.at> writes:
The patch did not work for me :-(
Is libpq.so in a non-standard directory? If yes, one either
has to export LIBPATH in the environment or link with
-L/location/of/libpq for the executable to find it
(similar to RPATH in Linux).
libpq will definitely be in a nonstandard directory in buildfarm usage.
It sounds like we should add the local equivalent of RPATH for AIX.
Now I'm pretty dubious that -L is what we want --- -L should have the
semantics of "this is where to find the library right now". RPATH is
used to point to an expected installation directory that might not
contain the library at the time of linking ... or worse, might contain
an old incompatible version of it. Does AIX have a true RPATH
equivalent?
regards, tom lane
I suspect that up to now the buildfarm had a static build of
PostgreSQL. What is the output of 'ldd initdb' when it builds
and runs correctly?Is libpq.so in a non-standard directory? If yes, one either
has to export LIBPATH in the environment or link with
-L/location/of/libpq for the executable to find it
(similar to RPATH in Linux).
Here is the working one:
initdb needs:
/usr/lib/libc.a(shr.o)
/unix
/usr/lib/libcrypt.a(shr.o)
Here is the broken one:
initdb needs:
../../../src/interfaces/libpq/libpq.so
/usr/lib/libc.a(shr.o)
/usr/lib/librtl.a(shr.o)
/unix
/usr/lib/libcrypt.a(shr.o)
When run it shows:
exec(): 0509-036 Cannot load program initdb because of the following
errors:
0509-150 Dependent module libpq.so could not be loaded.
0509-022 Cannot load module libpq.so.
0509-026 System error: A file or directory in the path name does
not exist.
Import Notes
Resolved by subject fallback
Rocco Altier wrote:
Here is the working one:
initdb needs:
/usr/lib/libc.a(shr.o)
/unix
/usr/lib/libcrypt.a(shr.o)Here is the broken one:
initdb needs:
../../../src/interfaces/libpq/libpq.so
/usr/lib/libc.a(shr.o)
/usr/lib/librtl.a(shr.o)
/unix
/usr/lib/libcrypt.a(shr.o)When run it shows:
exec(): 0509-036 Cannot load program initdb because of the following
errors:
0509-150 Dependent module libpq.so could not be loaded.
0509-022 Cannot load module libpq.so.
0509-026 System error: A file or directory in the
path name does
not exist.
Yup, that's as expected :^)
Up to now you have built against the static libpq.a
I didn't add the right -blibpath to this patch that
failed for you - the broken initdb is dynamically linked
but does not know where to look for its shared library.
The patch I just submitted to pgsql-patches should take
care of that. It makes the executables look in --libdir.
Yours,
Laurenz Albe
Import Notes
Resolved by subject fallback
"Albe Laurenz" <all@adv.magwien.gv.at> writes:
Up to now you have built against the static libpq.a
I didn't add the right -blibpath to this patch that
failed for you - the broken initdb is dynamically linked
but does not know where to look for its shared library.
The patch I just submitted to pgsql-patches should take
care of that. It makes the executables look in --libdir.
Mmm ... what of "make check"'s temporary installation? We need
to have the executables search in the temporary install's libdir,
*before* looking in the configured --libdir (which could easily
contain an incompatible back-version libpq ...)
pg_regress normally tries to handle this by setting LD_LIBRARY_PATH
... does AIX use that or a similar symbol?
regards, tom lane
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
"Albe Laurenz" <all@adv.magwien.gv.at> writes:Up to now you have built against the static libpq.a
I didn't add the right -blibpath to this patch that
failed for you - the broken initdb is dynamically linked
but does not know where to look for its shared library.The patch I just submitted to pgsql-patches should take
care of that. It makes the executables look in --libdir.Mmm ... what of "make check"'s temporary installation? We need
to have the executables search in the temporary install's libdir,
*before* looking in the configured --libdir (which could easily
contain an incompatible back-version libpq ...)pg_regress normally tries to handle this by setting LD_LIBRARY_PATH
... does AIX use that or a similar symbol?
The "make check" was successful in my previous testing of the last
patch, so it appears that AIX was paying attention to LD_LIBRARY_PATH.
I am testing the new version of the patch now, so will report back
shortly.
Thanks,
-rocco
Import Notes
Resolved by subject fallback
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Mmm ... what of "make check"'s temporary installation? We need
to have the executables search in the temporary install's libdir,
*before* looking in the configured --libdir (which could easily
contain an incompatible back-version libpq ...)pg_regress normally tries to handle this by setting LD_LIBRARY_PATH
... does AIX use that or a similar symbol?The "make check" was successful in my previous testing of the last
patch, so it appears that AIX was paying attention to LD_LIBRARY_PATH.I am testing the new version of the patch now, so will report back
shortly.From testing the new patch, it did not work for the regression tests in
the buildfarm.
Not sure why it did work before.
Anyhow, I have updated the patch to set LIBPATH (AIX's version of
LD_LIBRARY_PATH), in pg_regress and ecpg's pg_regress.
I have tested this with default config options (enable-shared,
enable-rpath). I am starting to test the other methods as well, but
wanted to get this out first.
-rocco
Import Notes
Resolved by subject fallback
With the patch attached this time...
-rocco
Show quoted text
-----Original Message-----
From: Rocco Altier
Sent: Friday, September 15, 2006 2:04 PM
To: Rocco Altier; 'Tom Lane'; 'Albe Laurenz'
Cc: 'pgsql-hackers@postgresql.org'
Subject: RE: [PATCHES] [HACKERS] Linking on AIX (Was: Fix
linking of OpenLDAP libraries )From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Mmm ... what of "make check"'s temporary installation? We need
to have the executables search in the temporary install's libdir,
*before* looking in the configured --libdir (which could easily
contain an incompatible back-version libpq ...)pg_regress normally tries to handle this by setting
LD_LIBRARY_PATH
... does AIX use that or a similar symbol?
The "make check" was successful in my previous testing of the last
patch, so it appears that AIX was paying attention toLD_LIBRARY_PATH.
I am testing the new version of the patch now, so will report back
shortly.From testing the new patch, it did not work for the
regression tests in the buildfarm.
Not sure why it did work before.Anyhow, I have updated the patch to set LIBPATH (AIX's
version of LD_LIBRARY_PATH), in pg_regress and ecpg's pg_regress.I have tested this with default config options
(enable-shared, enable-rpath). I am starting to test the
other methods as well, but wanted to get this out first.-rocco
Attachments:
aix.link.regression.patchapplication/octet-stream; name=aix.link.regression.patchDownload
Index: src/Makefile.global.in
===================================================================
RCS file: /projects/cvsroot/pgsql/src/Makefile.global.in,v
retrieving revision 1.229
diff -c -r1.229 Makefile.global.in
*** src/Makefile.global.in 11 Sep 2006 13:35:08 -0000 1.229
--- src/Makefile.global.in 15 Sep 2006 17:53:12 -0000
***************
*** 345,357 ****
ifeq ($(enable_shared), no)
libpq += $(filter -lintl -lssl -lcrypto -lkrb5 -lcrypt, $(LIBS)) \
$(LDAP_LIBS_FE) $(PTHREAD_LIBS)
- else
- # On AIX even shared libraries do not remember their required libs,
- # so again add in what libpq depends on.
- ifeq ($(PORTNAME), aix)
- libpq += $(filter -lintl -lssl -lcrypto -lkrb5 -lcrypt, $(LIBS)) \
- $(LDAP_LIBS_FE) $(PTHREAD_LIBS)
- endif
endif
# This macro is for use by client executables (not libraries) that use libpq.
--- 345,350 ----
Index: src/Makefile.shlib
===================================================================
RCS file: /projects/cvsroot/pgsql/src/Makefile.shlib,v
retrieving revision 1.104
diff -c -r1.104 Makefile.shlib
*** src/Makefile.shlib 28 Apr 2006 02:53:20 -0000 1.104
--- src/Makefile.shlib 15 Sep 2006 17:53:12 -0000
***************
*** 96,103 ****
soname = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
ifeq ($(PORTNAME), aix)
! shlib = lib$(NAME)$(DLSUFFIX)
! # SHLIB_LINK += -lc
endif
ifeq ($(PORTNAME), darwin)
--- 96,102 ----
soname = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
ifeq ($(PORTNAME), aix)
! shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
endif
ifeq ($(PORTNAME), darwin)
***************
*** 298,303 ****
--- 297,305 ----
$(shlib): lib$(NAME).a
$(MKLDEXPORT) lib$(NAME).a > lib$(NAME)$(EXPSUFF)
$(COMPILER) $(LDFLAGS_NO_L) $(LDFLAGS_SL) -o $@ $< -Wl,-bE:lib$(NAME)$(EXPSUFF) $(SHLIB_LINK)
+ rm -f $<
+ $(AR) $(AROPT) $< $@
+ touch $@
endif # PORTNAME == aix
***************
*** 349,354 ****
--- 351,359 ----
endif
ifeq ($(enable_shared), yes)
+ ifeq ($(PORTNAME), aix)
+ install-lib-shared: install-lib-static
+ else
install-lib-shared: $(shlib)
$(INSTALL_SHLIB) $< '$(DESTDIR)$(libdir)/$(shlib)'
ifneq ($(PORTNAME), cygwin)
***************
*** 365,370 ****
--- 370,376 ----
endif
endif # not win32
endif # not cygwin
+ endif # aix
endif # enable_shared
Index: src/interfaces/ecpg/test/Makefile.regress
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/ecpg/test/Makefile.regress,v
retrieving revision 1.4
diff -c -r1.4 Makefile.regress
*** src/interfaces/ecpg/test/Makefile.regress 28 Aug 2006 16:13:11 -0000 1.4
--- src/interfaces/ecpg/test/Makefile.regress 15 Sep 2006 17:53:13 -0000
***************
*** 3,9 ****
override CFLAGS += $(PTHREAD_CFLAGS)
override LDFLAGS := -L../../ecpglib -L../../pgtypeslib -L../../../libpq $(LDFLAGS)
! override LIBS := -lpgtypes -lecpg -lpq $(LIBS) $(PTHREAD_LIBS)
ECPG = ../../preproc/ecpg -I$(srcdir)/../../include
--- 3,9 ----
override CFLAGS += $(PTHREAD_CFLAGS)
override LDFLAGS := -L../../ecpglib -L../../pgtypeslib -L../../../libpq $(LDFLAGS)
! override LIBS := -lpgtypes -lecpg -lpq $(LIBS) $(LDAP_LIBS_FE) $(PTHREAD_LIBS)
ECPG = ../../preproc/ecpg -I$(srcdir)/../../include
Index: src/interfaces/ecpg/test/pg_regress.sh
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/ecpg/test/pg_regress.sh,v
retrieving revision 1.13
diff -c -r1.13 pg_regress.sh
*** src/interfaces/ecpg/test/pg_regress.sh 8 Sep 2006 13:32:27 -0000 1.13
--- src/interfaces/ecpg/test/pg_regress.sh 15 Sep 2006 17:53:13 -0000
***************
*** 332,337 ****
--- 332,344 ----
fi
export LD_LIBRARY_PATH
+ if [ -n "$LIBPATH" ]; then
+ LIBPATH="$libdir:$LIBPATH"
+ else
+ LIBPATH=$libdir
+ fi
+ export LIBPATH
+
if [ -n "$DYLD_LIBRARY_PATH" ]; then
DYLD_LIBRARY_PATH="$libdir:$DYLD_LIBRARY_PATH"
else
Index: src/makefiles/Makefile.aix
===================================================================
RCS file: /projects/cvsroot/pgsql/src/makefiles/Makefile.aix,v
retrieving revision 1.25
diff -c -r1.25 Makefile.aix
*** src/makefiles/Makefile.aix 19 Apr 2006 16:32:08 -0000 1.25
--- src/makefiles/Makefile.aix 15 Sep 2006 17:53:13 -0000
***************
*** 5,10 ****
--- 5,18 ----
RANLIB= touch
AROPT = crs
+ # -blibpath must contain ALL directories where we should look for libraries
+ libpath := $(shell echo $(subst -L,:,$(filter -L/%,$(subst -L , -L,$(strip $(LDFLAGS)))))|sed -e's/ //g'):/usr/lib:/lib
+ ifeq ($(host_os), aix3.2.5)
+ rpath = -L$(rpathdir)
+ else
+ rpath = -Wl,-blibpath:$(rpathdir)$(libpath)
+ endif
+
DLSUFFIX = .so
ifeq ($(host_os), aix3.2.5)
ifneq ($(GCC), yes)
Index: src/test/regress/pg_regress.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/test/regress/pg_regress.c,v
retrieving revision 1.20
diff -c -r1.20 pg_regress.c
*** src/test/regress/pg_regress.c 13 Aug 2006 20:39:07 -0000 1.20
--- src/test/regress/pg_regress.c 15 Sep 2006 17:53:13 -0000
***************
*** 512,517 ****
--- 512,518 ----
* dlopen'ed ones) Feel free to account for others as well.
*/
add_to_path("LD_LIBRARY_PATH", ':', libdir);
+ add_to_path("LIBPATH", ':', libdir);
add_to_path("DYLD_LIBRARY_PATH", ':', libdir);
#if defined(WIN32) || defined(__CYGWIN__)
add_to_path("PATH", ';', libdir);
Import Notes
Resolved by subject fallback
I would like to see some comments about AIX linking so we don't need to
relearn this in 1-2 years.
---------------------------------------------------------------------------
Rocco Altier wrote:
With the patch attached this time...
-rocco
-----Original Message-----
From: Rocco Altier
Sent: Friday, September 15, 2006 2:04 PM
To: Rocco Altier; 'Tom Lane'; 'Albe Laurenz'
Cc: 'pgsql-hackers@postgresql.org'
Subject: RE: [PATCHES] [HACKERS] Linking on AIX (Was: Fix
linking of OpenLDAP libraries )From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Mmm ... what of "make check"'s temporary installation? We need
to have the executables search in the temporary install's libdir,
*before* looking in the configured --libdir (which could easily
contain an incompatible back-version libpq ...)pg_regress normally tries to handle this by setting
LD_LIBRARY_PATH
... does AIX use that or a similar symbol?
The "make check" was successful in my previous testing of the last
patch, so it appears that AIX was paying attention toLD_LIBRARY_PATH.
I am testing the new version of the patch now, so will report back
shortly.From testing the new patch, it did not work for the
regression tests in the buildfarm.
Not sure why it did work before.Anyhow, I have updated the patch to set LIBPATH (AIX's
version of LD_LIBRARY_PATH), in pg_regress and ecpg's pg_regress.I have tested this with default config options
(enable-shared, enable-rpath). I am starting to test the
other methods as well, but wanted to get this out first.-rocco
Content-Description: aix.link.regression.patch
[ Attachment, skipping... ]
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings
--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
"Rocco Altier" <RoccoA@Routescape.com> writes:
With the patch attached this time...
The proposed patch to Makefile.shlib makes me gag :-( ... lying to make
about what's the purpose of a rule is seldom a good idea. Please try
as attached instead. Also, I am *really* dubious about the change to
ecpg/test/Makefile.regress --- if that's necessary then this whole
exercise is wrong.
regards, tom lane
Bruce Momjian wrote:
I would like to see some comments about AIX linking so we
don't need to
relearn this in 1-2 years.
Something like
http://archives.postgresql.org/pgsql-hackers/2006-09/msg00893.php
or something more comprehensive?
Maybe mentioning LIBPATH and -blibpath: might be good.
Yours,
Laurenz Albe
Import Notes
Resolved by subject fallback
Rocco Altier wrote:
pg_regress normally tries to handle this by setting LD_LIBRARY_PATH
... does AIX use that or a similar symbol?The "make check" was successful in my previous testing of the last
patch, so it appears that AIX was paying attention to
LD_LIBRARY_PATH.
Anyhow, I have updated the patch to set LIBPATH (AIX's version of
LD_LIBRARY_PATH), in pg_regress and ecpg's pg_regress.I have tested this with default config options (enable-shared,
enable-rpath). I am starting to test the other methods as well, but
wanted to get this out first.
LD_LIBRARY_PATH does not work on AIX - the AIX equivalent is LIBPATH.
"make check" does not seem to rely on LD_LIBRARY_PATH, and it should
work with my patch (it worked here).
If pg_regress relies on LD_LIBRARY_PATH, it would have to be changed
to set LIBPATH in the AIX case :^(
The reason why all these problems manifest now is that - up to now -
PostgreSQL used static linking on AIX and it was not necessary to
find the shared library.
Yours,
Laurenz Albe
Import Notes
Resolved by subject fallback
Tom Lane wrote:
The proposed patch to Makefile.shlib makes me gag :-( ...
It is ugly.
lying to make
about what's the purpose of a rule is seldom a good idea. Please try
as attached instead.
I will ASAP.
Also, I am *really* dubious about the change to
ecpg/test/Makefile.regress --- if that's necessary then this whole
exercise is wrong.
For a dynamic build you do not need the change.
Only a --disable-shared build will gag without it. I'll have a look
at that too.
Yours,
Laurenz Albe
Import Notes
Resolved by subject fallback
"Albe Laurenz" <all@adv.magwien.gv.at> writes:
Tom Lane wrote:
Also, I am *really* dubious about the change to
ecpg/test/Makefile.regress --- if that's necessary then this whole
exercise is wrong.
For a dynamic build you do not need the change.
Only a --disable-shared build will gag without it.
Ah. In that case I think the answer is that that makefile should be
using $(libpq) or possibly $(libpq_pgport) from Makefile.global,
rather than bare "-lpq".
regards, tom lane