[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: BUG: library type search order
From: |
Scott James Remnant |
Subject: |
Re: BUG: library type search order |
Date: |
Wed, 04 Feb 2004 15:38:46 +0000 |
On Wed, 2004-02-04 at 15:02, Peter O'Gorman wrote:
> Gary V. Vaughan wrote:
> |
> | I still don't see how this can help with the original search path vs. .la
> | files bug though (unless it was reported from a darwin box)...
>
> Well, the original bug report was against 1.5, I think, so that was broken
> on all platforms.
>
> I am curious about how Scott reproduced it on 1.5.2, unless he secretly
> switched from debian to darwin :)
>
> Peter (running away)
>
A DOUBTER!! GET HIM BOYS!
Okay, I'm going to cheat and borrow libxml2 (my favourite test library)
and demonstrate this...
First we copy it into /opt/libxml/lib and make sure the paths in the .la
file are correct:
----8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<----
descent ltsearchpatch% mkdir -p /opt/libxml/lib
descent ltsearchpatch% cp -a /usr/lib/libxml2.* /opt/libxml/lib
descent ltsearchpatch% sed -i -e "s,/usr/lib,/opt/libxml/lib,g"
/opt/libxml/lib/libxml2.la
---->8-------->8-------->8-------->8-------->8-------->8-------->8-------->8----
What version of libtool am I running?
----8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<----
descent ltsearchpatch% libtool --version
ltmain.sh (GNU libtool) 1.5.2 (1.1220.2.60 2004/01/25 12:25:08) Debian: 192 $
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
---->8-------->8-------->8-------->8-------->8-------->8-------->8-------->8----
Let's create a small test program and test-compile it, note that
/opt/libxml/lib/libxml2.la exists so this *should work* as expected.
----8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<----
descent ltsearchpatch% echo "int main() { return 0; }" > test.c
descent ltsearchpatch% libtool --mode=compile gcc -c test.c
mkdir .libs
gcc -c test.c -fPIC -DPIC -o .libs/test.o
gcc -c test.c -o test.o >/dev/null 2>&1
descent ltsearchpatch% libtool --mode=link gcc -o test test.lo
-L/opt/libxml/lib -lxml2
gcc -o test .libs/test.o -L/opt/libxml/lib /opt/libxml/lib/libxml2.so
-lpthread -lz -lm -Wl,--rpath -Wl,/opt/libxml/lib -Wl,--rpath
-Wl,/opt/libxml/lib
---->8-------->8-------->8-------->8-------->8-------->8-------->8-------->8----
And it does, good, everything's sane. We might as well create a test
library as well and make sure that works too...
----8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<----
descent ltsearchpatch% echo "frobnitz() { }" > libtest.c descent ltsearchpatch%
libtool --mode=compile gcc -c libtest.c
gcc -c libtest.c -fPIC -DPIC -o .libs/libtest.o
gcc -c libtest.c -o libtest.o >/dev/null 2>&1
descent ltsearchpatch% libtool --mode=link gcc -o libtest.la libtest.lo -rpath
/usr/local/lib -L/opt/libxml/lib -lxml2
gcc -shared .libs/libtest.o -Wl,--rpath -Wl,/opt/libxml/lib -Wl,--rpath
-Wl,/opt/libxml/lib -L/opt/libxml/lib /opt/libxml/lib/libxml2.so -Wl,-soname
-Wl,libtest.so.0 -o .libs/libtest.so.0.0.0
(cd .libs && rm -f libtest.so.0 && ln -s libtest.so.0.0.0 libtest.so.0)
(cd .libs && rm -f libtest.so && ln -s libtest.so.0.0.0 libtest.so)
ar cru .libs/libtest.a libtest.o
ranlib .libs/libtest.a
creating libtest.la
(cd .libs && rm -f libtest.la && ln -s ../libtest.la libtest.la)
---->8-------->8-------->8-------->8-------->8-------->8-------->8-------->8----
Good, all is right with the world; let's clean up and then REMOVE the
.la file in /opt/libxml/lib but leave the one in /usr/lib
----8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<----
descent ltsearchpatch% libtool --mode=clean rm test libtest.la rm test
rm libtest.la .libs/libtest.so.0.0.0 .libs/libtest.so.0 .libs/libtest.so
.libs/libtest.a .libs/libtest.la .libs/libtest.lai
rmdir .libs
descent ltsearchpatch% rm /opt/libxml/lib/libxml2.la
---->8-------->8-------->8-------->8-------->8-------->8-------->8-------->8----
Now let's build our test program again, you say this'll work, I say
this'll fail (ie. link /usr/lib/libxml2.so).
----8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<----
descent ltsearchpatch% libtool --mode=link gcc -o test test.lo
-L/opt/libxml/lib -lxml2
gcc -o test .libs/test.o -L/opt/libxml/lib /usr/lib/libxml2.so
---->8-------->8-------->8-------->8-------->8-------->8-------->8-------->8----
nyah-nah nyah-nah-nah, told ya so! ;-)
What about linking with a library (which is, I have a feeling, what you
tested).
----8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<----
descent ltsearchpatch% libtool --mode=link gcc -o libtest.la libtest.lo -rpath
/usr/local/lib -L/opt/libxml/lib -lxml2
gcc -shared .libs/libtest.o -L/opt/libxml/lib -lxml2 -Wl,-soname
-Wl,libtest.so.0 -o .libs/libtest.so.0.0.0
(cd .libs && rm -f libtest.so.0 && ln -s libtest.so.0.0.0 libtest.so.0)
(cd .libs && rm -f libtest.so && ln -s libtest.so.0.0.0 libtest.so)
ar cru .libs/libtest.a libtest.o
ranlib .libs/libtest.a
creating libtest.la
(cd .libs && rm -f libtest.la && ln -s ../libtest.la libtest.la)
---->8-------->8-------->8-------->8-------->8-------->8-------->8-------->8----
An interesting result ... it actually doesn't specify *EITHER* full path
this time, and just passes -lxml2 to the linker this time round. This
sounds like it might work, but you'll note it's also not passing
-Wl,-rpath -Wl,/opt/libxml/lib so although the compiler linked it with
the right thing, the runtime path hasn't taken effect.
Just to verify this isn't a 1.5-specific problem, we'll do all of the
above with a 1.6 from a few weeks back (we've not changed anything since
then that should affect this):
----8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<----
descent ltsearchpatch% libtool --version
ltmain.sh (GNU libtool 1.1370 2004/01/08 10:34:52) 1.5a
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
descent ltsearchpatch% libtool --mode=clean rm test libtest.la test.lo
libtest.lo
rm test
rm libtest.la .libs/libtest.so.0.0.0 .libs/libtest.so.0 .libs/libtest.so
.libs/libtest.a .libs/libtest.la .libs/libtest.lai
rm test.lo ./.libs/test.o ./test.o
rm libtest.lo ./.libs/libtest.o ./libtest.o
rmdir .libs
descent ltsearchpatch% cp /usr/lib/libxml2.la /opt/libxml/lib
descent ltsearchpatch% sed -i -e "s,/usr/lib,/opt/libxml/lib,g"
/opt/libxml/lib/libxml2.la
descent ltsearchpatch% libtool --mode=compile gcc -c test.c mkdir .libs
gcc -c test.c -fPIC -DPIC -o .libs/test.o
gcc -c test.c -o test.o >/dev/null 2>&1
descent ltsearchpatch% libtool --mode=link gcc -o test test.lo
-L/opt/libxml/lib -lxml2
gcc -o test .libs/test.o -L/opt/libxml/lib /opt/libxml/lib/libxml2.so
-lpthread -lz -lm -Wl,--rpath -Wl,/opt/libxml/lib -Wl,--rpath
-Wl,/opt/libxml/lib
descent ltsearchpatch% libtool --mode=compile gcc -c libtest.c gcc -c
libtest.c -fPIC -DPIC -o .libs/libtest.o
gcc -c libtest.c -o libtest.o >/dev/null 2>&1
descent ltsearchpatch% libtool --mode=link gcc -o libtest.la libtest.lo -rpath
/usr/local/lib -L/opt/libxml/lib -lxml2
gcc -shared .libs/libtest.o -Wl,--rpath -Wl,/opt/libxml/lib -Wl,--rpath
-Wl,/opt/libxml/lib -L/opt/libxml/lib /opt/libxml/lib/libxml2.so -Wl,-soname
-Wl,libtest.so.0 -o .libs/libtest.so.0.0.0
(cd .libs && rm -f libtest.so.0 && ln -s libtest.so.0.0.0 libtest.so.0)
(cd .libs && rm -f libtest.so && ln -s libtest.so.0.0.0 libtest.so)
ar cru .libs/libtest.a libtest.o
ranlib .libs/libtest.a
creating libtest.la
(cd .libs && rm -f libtest.la && ln -s ../libtest.la libtest.la)
descent ltsearchpatch% libtool --mode=clean rm test libtest.la rm test
rm libtest.la .libs/libtest.so.0.0.0 .libs/libtest.so.0 .libs/libtest.so
.libs/libtest.a .libs/libtest.la .libs/libtest.lai
rmdir .libs
descent ltsearchpatch% rm /opt/libxml/lib/libxml2.la
descent ltsearchpatch% libtool --mode=link gcc -o test test.lo
-L/opt/libxml/lib -lxml2
gcc -o test .libs/test.o -L/opt/libxml/lib /usr/lib/libxml2.so
descent ltsearchpatch% libtool --mode=link gcc -o libtest.la libtest.lo -rpath
/usr/local/lib -L/opt/libxml/lib -lxml2
gcc -shared .libs/libtest.o -L/opt/libxml/lib -lxml2 -Wl,-soname
-Wl,libtest.so.0 -o .libs/libtest.so.0.0.0
(cd .libs && rm -f libtest.so.0 && ln -s libtest.so.0.0.0 libtest.so.0)
(cd .libs && rm -f libtest.so && ln -s libtest.so.0.0.0 libtest.so)
ar cru .libs/libtest.a libtest.o
ranlib .libs/libtest.a
creating libtest.la
(cd .libs && rm -f libtest.la && ln -s ../libtest.la libtest.la)
---->8-------->8-------->8-------->8-------->8-------->8-------->8-------->8----
HEAD exhibits the same declared-wrong behaviour for the program, and the
same wrong-whichever-way-you-look-at-it behaviour for the library.
Scott
--
Have you ever, ever felt like this?
Had strange things happen? Are you going round the twist?
signature.asc
Description: This is a digitally signed message part
- Re: BUG: library type search order, Scott James Remnant, 2004/02/03
- Re: BUG: library type search order, Gary V . Vaughan, 2004/02/03
- Re: BUG: library type search order, Peter O'Gorman, 2004/02/03
- Re: BUG: library type search order, Gary V . Vaughan, 2004/02/03
- Re: BUG: library type search order, Scott James Remnant, 2004/02/03
- Re: BUG: library type search order, Peter O'Gorman, 2004/02/04
- Re: BUG: library type search order, Gary V . Vaughan, 2004/02/04
- Re: BUG: library type search order, Peter O'Gorman, 2004/02/04
- Re: BUG: library type search order, Gary V. Vaughan, 2004/02/04
- Re: BUG: library type search order, Peter O'Gorman, 2004/02/04
- Re: BUG: library type search order,
Scott James Remnant <=
- Re: BUG: library type search order, Peter O'Gorman, 2004/02/04
- Re: BUG: library type search order, Gary V. Vaughan, 2004/02/05
- Re: BUG: library type search order, Peter O'Gorman, 2004/02/05
- Re: BUG: library type search order, Markus Diesmann, 2004/02/12