Thread: Re: [HACKERS] HEAD doesn't cope with libraries in non-default locations

Re: [HACKERS] HEAD doesn't cope with libraries in non-default locations

From
Bruce Momjian
Date:
Tom Lane wrote:
> CVS tip fails with
>   ./configure --with-openssl \
>     --with-includes=/usr/local/ssl/include --with-libs=/usr/local/ssl/lib
>
> ...
> make[3]: Entering directory `/home/postgres/pgsql/src/interfaces/libpq'
> ...
> /usr/ccs/bin/ld +h libpq.sl.4 -b +b /home/postgres/testversion/lib  fe-auth.o fe-connect.o fe-exec.o fe-misc.o
fe-print.ofe-lobj.o fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o md5.o ip.o wchar.o encnames.o
noblock.opgstrcasecmp.o thread.o getaddrinfo.o -lssl -lcrypto  `gcc -L../../../src/port -L/usr/local/ssl/lib -Wl,-z
-Wl,+b-Wl,/home/postgres/testversion/lib -print-libgcc-file-name` -L../../../src/port -L/usr/local/ssl/lib  -o
libpq.sl.4
> /usr/ccs/bin/ld: Can't find library for -lssl
> make[3]: *** [libpq.sl.4] Error 1
>
> It appears that somebody has changed things so that the -L switches
> appear after the -l switches (ie, too late).  I'm too tired to
> investigate now, but my money is on Autoconf 2.59 being the problem ...

I wonder if it was this commit.  I am attaching the patch so you can
test to see if it fixes it.  If it does, please let us know.

---------------------------------------------------------------------------

revision 1.91
date: 2005/07/02 23:28:22;  author: momjian;  state: Exp;  lines: +2 -2
> A quick look shows that when you use --with-libraries=/foo/bar the
> generated link line for libraries says
>
>  -L/foo/bar -lpq
>
> and it should probably be the other way around (as it is for the
> executables).
>
> So I suspect we need some makefile tuning.

You were correct. This patch fixes it.

Jim C. Nasby

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: Makefile.shlib
===================================================================
RCS file: /cvsroot/pgsql/src/Makefile.shlib,v
retrieving revision 1.90
retrieving revision 1.91
diff -c -c -r1.90 -r1.91
*** Makefile.shlib    20 Nov 2004 21:13:04 -0000    1.90
--- Makefile.shlib    2 Jul 2005 23:28:22 -0000    1.91
***************
*** 240,246 ****
    SHLIB_LINK        += -ltermcap -lstdc++.r4 -lbind -lsocket -L/boot/develop/lib/x86
  endif

! SHLIB_LINK := $(filter -L%, $(LDFLAGS)) $(SHLIB_LINK)
  ifeq ($(enable_rpath), yes)
  SHLIB_LINK += $(rpath)
  endif
--- 240,246 ----
    SHLIB_LINK        += -ltermcap -lstdc++.r4 -lbind -lsocket -L/boot/develop/lib/x86
  endif

! SHLIB_LINK := $(SHLIB_LINK) $(filter -L%, $(LDFLAGS))
  ifeq ($(enable_rpath), yes)
  SHLIB_LINK += $(rpath)
  endif

Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Tom Lane wrote:
>> It appears that somebody has changed things so that the -L switches
>> appear after the -l switches (ie, too late).  I'm too tired to
>> investigate now, but my money is on Autoconf 2.59 being the problem ...

> I wonder if it was this commit.  I am attaching the patch so you can
> test to see if it fixes it.  If it does, please let us know.

> ! SHLIB_LINK := $(filter -L%, $(LDFLAGS)) $(SHLIB_LINK)
> ...
> ! SHLIB_LINK := $(SHLIB_LINK) $(filter -L%, $(LDFLAGS))

Urgh.  This was considered a good idea why exactly?

            regards, tom lane

Re: [HACKERS] HEAD doesn't cope with libraries in non-default

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Tom Lane wrote:
> >> It appears that somebody has changed things so that the -L switches
> >> appear after the -l switches (ie, too late).  I'm too tired to
> >> investigate now, but my money is on Autoconf 2.59 being the problem ...
>
> > I wonder if it was this commit.  I am attaching the patch so you can
> > test to see if it fixes it.  If it does, please let us know.
>
> > ! SHLIB_LINK := $(filter -L%, $(LDFLAGS)) $(SHLIB_LINK)
> > ...
> > ! SHLIB_LINK := $(SHLIB_LINK) $(filter -L%, $(LDFLAGS))
>
> Urgh.  This was considered a good idea why exactly?

I didn't like it myself but it fixed a problem with a build farm
machine, and no one objected, so I applied it, but it seemed pretty
strange to be reversing those. I will reverse the patch.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: [HACKERS] HEAD doesn't cope with libraries in non-default

From
"Andrew Dunstan"
Date:
Bruce Momjian said:
> Tom Lane wrote:
>> Bruce Momjian <pgman@candle.pha.pa.us> writes:
>> > Tom Lane wrote:
>> >> It appears that somebody has changed things so that the -L switches
>> >> appear after the -l switches (ie, too late).  I'm too tired to
>> >> investigate now, but my money is on Autoconf 2.59 being the problem
>> >> ...
>>
>> > I wonder if it was this commit.  I am attaching the patch so you can
>> > test to see if it fixes it.  If it does, please let us know.
>>
>> > ! SHLIB_LINK := $(filter -L%, $(LDFLAGS)) $(SHLIB_LINK)
>> > ...
>> > ! SHLIB_LINK := $(SHLIB_LINK) $(filter -L%, $(LDFLAGS))
>>
>> Urgh.  This was considered a good idea why exactly?
>
> I didn't like it myself but it fixed a problem with a build farm
> machine, and no one objected, so I applied it, but it seemed pretty
> strange to be reversing those. I will reverse the patch.
>


I was also slightly dubious about it. However, we do still need to solve the
problem that the patch addressed. Buildfarm members platypus and cuckoo are
 currently failing because dblink is picking up the wrong libpq (and it
appears that incorrect libraries are also being picked up in the ecpg
libraries, although this isn't causing a buildfarm failure.)

Alternatively, if we can't say --with-libraries=/foo/bar when /foo/bar
contains possibly conflicting libraries, that should be tested for at
configure time.

cheers

andrew