Fix for HP-UX shared library builds

Started by Giles Leanover 23 years ago9 messagespatches
Jump to latest
#1Giles Lean
giles@nemeton.com.au

[ Take #3: send the mail *with* the patch (problem #1), send
if *from* an address that is subscribed to the list (problem #2).
It's time for me to shut my brain down for Christmas. --giles ]

Hi,

Below is a patch against 7.3.1 that makes shared library major numbers
useful on HP-UX.

Without this patch PostgreSQL builds on HP-UX install libraries
without internal names, with the result that applications link to
'libpq.sl' without a version number.

With the patch below the following changes are made:

1. libraries have an internal name set with ld +h

2. a symbolic link is created from the non-version name to the
version name, that is (on a patched 7.3.1 install):

$ ls -l libpq*
-rw-r--r-- 1 root sys 164330 Dec 24 08:43 libpq.a
lrwxrwxrwx 1 root sys 10 Dec 24 08:43 libpq.sl -> libpq.sl.3
-r-xr-xr-x 1 root sys 159744 Dec 24 08:43 libpq.sl.3

instead of (on an unpatched 7.2.3 install):

$ ls -l libpq*
-rw-r--r-- 1 root users 103544 Oct 6 14:54 libpq.a
-r-xr-xr-x 1 root users 102400 Oct 6 14:54 libpq.sl
lrwxr-xr-x 1 root users 8 Oct 6 14:54 libpq.sl.2 -> libpq.sl

3. applications link to the versioned library

$ /usr/ccs/bin/ldd psql
/usr/lib/libm.2 => /usr/lib/libm.2
/usr/lib/libnsl.1 => /usr/lib/libnsl.1
/usr/lib/libxti.2 => /usr/lib/libxti.2
/usr/lib/libdld.2 => /usr/lib/libdld.2
/usr/lib/libc.2 => /usr/lib/libc.2
/usr/lib/libdld.2 => /usr/lib/libdld.2
/usr/lib/libgen.2 => /usr/lib/libgen.2
/usr/lib/libc.2 => /usr/lib/libc.2
../../../src/interfaces/libpq/libpq.sl.3 => /opt/pgsql-7.3.1/lib/libpq.sl.3
/usr/lib/libnsl.1 => /usr/lib/libnsl.1

instead of:

$ /usr/ccs/bin/ldd psql
/usr/lib/libm.2 => /usr/lib/libm.2
/usr/lib/libnsl.1 => /usr/lib/libnsl.1
/usr/lib/libxti.2 => /usr/lib/libxti.2
/usr/lib/libdld.2 => /usr/lib/libdld.2
/usr/lib/libc.2 => /usr/lib/libc.2
/usr/lib/libdld.2 => /usr/lib/libdld.2
/usr/lib/libgen.2 => /usr/lib/libgen.2
/usr/lib/libc.2 => /usr/lib/libc.2
../../../src/interfaces/libpq/libpq.sl => /opt/pgsql-7.2.3/lib/libpq.sl
/usr/lib/libnsl.1 => /usr/lib/libnsl.1

I have tested this patch on:

HP-UX 11.11, HP ANSI C compiler, 64 bit and 32 bit builds
HP-UX 11.11, gcc, 32 bit build
HP-UX 11.00, HP ANSI C compiler, 32 bit build
HP-UX 10.20, HP ANSI C compiler

'gmake check' passed in all cases, and the installed library paths
were correct. Having checked 10.20, 11.00, 11.11 and both gcc and the
HP ANSI C compiler I think this patch is safe to commit, and I request
that it be applied both to the HEAD and the 7.3.x branch.

Regards,

Giles

*** src/Makefile.shlib-orig	Wed Oct  9 09:21:54 2002
--- src/Makefile.shlib	Sun Dec 22 21:07:43 2002
***************
*** 126,134 ****
  endif

ifeq ($(PORTNAME), hpux)
! # HPUX doesn't believe in version numbers for shlibs
! shlib := lib$(NAME)$(DLSUFFIX)
! LINK.shared = $(LD) -b +b $(libdir)
endif

  ifeq ($(PORTNAME), irix5)
--- 126,133 ----
  endif

ifeq ($(PORTNAME), hpux)
! shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
! LINK.shared = $(LD) +h $(shlib) -b +b $(libdir)
endif

ifeq ($(PORTNAME), irix5)

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Giles Lean (#1)
Re: Fix for HP-UX shared library builds

Giles Lean writes:

*** src/Makefile.shlib-orig	Wed Oct  9 09:21:54 2002
--- src/Makefile.shlib	Sun Dec 22 21:07:43 2002
***************
*** 126,134 ****
endif

ifeq ($(PORTNAME), hpux)
! # HPUX doesn't believe in version numbers for shlibs

Once upon the time this was true. When did it change, and do we still
care about the pre-change versions?

! shlib := lib$(NAME)$(DLSUFFIX)
! LINK.shared = $(LD) -b +b $(libdir)
endif

ifeq ($(PORTNAME), irix5)
--- 126,133 ----
endif

ifeq ($(PORTNAME), hpux)
! shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
! LINK.shared = $(LD) +h $(shlib) -b +b $(libdir)

This should probably be +h $(soname).

endif

ifeq ($(PORTNAME), irix5)

--
Peter Eisentraut peter_e@gmx.net

#3Giles Lean
giles@nemeton.com.au
In reply to: Peter Eisentraut (#2)
Re: Fix for HP-UX shared library builds

Peter Eisentraut writes:

ifeq ($(PORTNAME), hpux)
! # HPUX doesn't believe in version numbers for shlibs

Once upon the time this was true. When did it change, and do we still
care about the pre-change versions?

The releases of HP-UX that HP support are 11.X (the current release)
and 10.X, supported until 2003-06-30. Certainly these releases both
have versioned shared libraries, and I tested the patch on them.

The previous HP-UX release 9.X ended support by the end of 1999. I
doubt if anyone cares about PostgreSQL on HP-UX 9.X, but if they do
speaking up and putting themselves on record in the archives would
be a Good Idea. :-)

I don't know if the comment was ever true; it may have been. I can't
say when (if) it changed although I can find out if anyone's really
curious.

! shlib := lib$(NAME)$(DLSUFFIX)
! LINK.shared = $(LD) -b +b $(libdir)
endif

ifeq ($(PORTNAME), irix5)
--- 126,133 ----
endif

ifeq ($(PORTNAME), hpux)
! shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
! LINK.shared = $(LD) +h $(shlib) -b +b $(libdir)

This should probably be +h $(soname).

I wasn't sure which was preferred. The values of $(soname) and
$(shlib) in this case are identical.

Regards,

Giles

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Giles Lean (#3)
Re: Fix for HP-UX shared library builds

Giles Lean <giles@nemeton.com.au> writes:

Peter Eisentraut writes:

ifeq ($(PORTNAME), hpux)
! # HPUX doesn't believe in version numbers for shlibs

Once upon the time this was true. When did it change, and do we still
care about the pre-change versions?

I don't know if the comment was ever true; it may have been.

I believe I put in the comment, back when I was running HPUX
9.something. I concur with Giles that it's unlikely anyone cares
about 9.x anymore. Even if someone does, altering our makefile
to install under both names should not break anything, I'd think...

regards, tom lane

#5Giles Lean
giles@nemeton.com.au
In reply to: Giles Lean (#1)
Re: Fix for HP-UX shared library builds

I wrote:

Below is a patch against 7.3.1 that makes shared library major numbers
useful on HP-UX.

Here is a revised version of the patch, changed per a suggestion of
Peter Eisentraut's to use +h $(soname) instead of +h $(shlib) in the
link command.

Peter's other question about old HP-UX versions was answered by Tom
Lane:

ifeq ($(PORTNAME), hpux)
! # HPUX doesn't believe in version numbers for shlibs

Peter> Once upon the time this was true. When did it change, and do we still
Peter> care about the pre-change versions?

Tom> I believe I put in the comment, back when I was running HPUX
Tom> 9.something. I concur with Giles that it's unlikely anyone cares
Tom> about 9.x anymore.

Nobody has spoken up to say they use HP-UX 9.X.

Will someone apply this patch please? I recommend it be applied to
the 7.3.x branch as well as HEAD as it will ease upgrading to 7.4
if there is ever a 7.3.2 release.

Regards,

Giles

*** src/Makefile.shlib-7.3.1	Thu Oct 10 02:21:54 2002
--- src/Makefile.shlib	Tue Jan  7 09:25:40 2003
***************
*** 126,134 ****
  endif

ifeq ($(PORTNAME), hpux)
! # HPUX doesn't believe in version numbers for shlibs
! shlib := lib$(NAME)$(DLSUFFIX)
! LINK.shared = $(LD) -b +b $(libdir)
endif

  ifeq ($(PORTNAME), irix5)
--- 126,133 ----
  endif

ifeq ($(PORTNAME), hpux)
! shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
! LINK.shared = $(LD) +h $(soname) -b +b $(libdir)
endif

ifeq ($(PORTNAME), irix5)

--
Giles Lean

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Giles Lean (#5)
Re: Fix for HP-UX shared library builds

Giles Lean <giles@nemeton.com.au> writes:

Will someone apply this patch please? I recommend it be applied to
the 7.3.x branch as well as HEAD as it will ease upgrading to 7.4
if there is ever a 7.3.2 release.

I am hesitant to apply it to 7.3 since that would mean (I think) an
incompatible renaming of the shlib, which we'd best avoid on a minor
release, no? What will happen for existing users of 7.3 if we do put
this in 7.3.2?

regards, tom lane

#7Giles Lean
giles@nemeton.com.au
In reply to: Tom Lane (#6)
Re: Fix for HP-UX shared library builds

Tom Lane wrote:

I am hesitant to apply it to 7.3 since that would mean (I think) an
incompatible renaming of the shlib, which we'd best avoid on a minor
release, no? What will happen for existing users of 7.3 if we do put
this in 7.3.2?

I had been thinking that HP-UX PostgreSQL users had a flag day every
time they upgraded PostgreSQL, but it's not that bad: they only have a
flag day when the library major version changes (or should have, in
the 7.3 case :-) when all clients need to be rebuilt.

I'll investigate and find out what happens when a client linked
against libpq.sl finds that has turned into a symbolic link. I think
the dynamic loader will follow the link, but I'm guessing. :-(

As an alternative to risking change on the 7.3.x branch, perhaps a
note in FAQ_HPUX noting the problem and that an upgrade to 7.4 will
require (like all releases to date) recompiling all clients would be
better.

Ciao,

Giles

#8Giles Lean
giles@nemeton.com.au
In reply to: Giles Lean (#7)
Re: Fix for HP-UX shared library builds

I wrote:

Tom Lane wrote:

I am hesitant to apply it to 7.3 since that would mean (I think) an
incompatible renaming of the shlib, which we'd best avoid on a minor
release, no? What will happen for existing users of 7.3 if we do put
this in 7.3.2?

I'll investigate and find out what happens when a client linked
against libpq.sl finds that has turned into a symbolic link. I think
the dynamic loader will follow the link, but I'm guessing. :-(

I have now tested this.

A binary linked against a libpq.sl will still run after libpq.sl is
updated to be a symbolic link to libpq.sl.3. This makes the change
safe to apply to the 7.3.x branch, I believe:

1. 7.3.1 clients will continue to work for 7.3.2 and later

2. clients re-linked against 7.3.2 or later will avoid the flag day
when the library major number is increased, probably with the 7.4
release. This is the advantage of applying the patch.

3. 7.3.1 clients that are not relinked will fail if they are not
relinked when the library major number is incremented, but that's
the case if the patch is not applied, too.

4. since the HP-UX port didn't use library major numbers the library
version bump in the 7.3.1 release made no difference, so 7.3
clients are in the same position as 7.3.1 clients for #1-#3 above.

Tom -- in your court now. Please do apply the change to HEAD (which I
think you were planning to do) and 7.3.x if you think it appropriate.

*** src/Makefile.shlib-7.3.1	Thu Oct 10 02:21:54 2002
--- src/Makefile.shlib	Tue Jan  7 09:25:40 2003
***************
*** 126,134 ****
  endif

ifeq ($(PORTNAME), hpux)
! # HPUX doesn't believe in version numbers for shlibs
! shlib := lib$(NAME)$(DLSUFFIX)
! LINK.shared = $(LD) -b +b $(libdir)
endif

  ifeq ($(PORTNAME), irix5)
--- 126,133 ----
  endif

ifeq ($(PORTNAME), hpux)
! shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
! LINK.shared = $(LD) +h $(soname) -b +b $(libdir)
endif

ifeq ($(PORTNAME), irix5)

Regards,

Giles

#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: Giles Lean (#8)
Re: Fix for HP-UX shared library builds

Giles Lean <giles@nemeton.com.au> writes:

Tom -- in your court now. Please do apply the change to HEAD (which I
think you were planning to do) and 7.3.x if you think it appropriate.

Applied in both branches. Thanks for the follow-up.

regards, tom lane