Bug 91110 - Bug in library path ordering of relink patch
Summary: Bug in library path ordering of relink patch
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: libtool
Version: 9
Hardware: All
OS: Linux
medium
high
Target Milestone: ---
Assignee: Jens Petersen
QA Contact: Jay Turner
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-05-18 21:25 UTC by Joe Orton
Modified: 2015-01-08 00:05 UTC (History)
2 users (show)

Fixed In Version: 1.5-3
Clone Of:
Environment:
Last Closed: 2003-06-24 12:13:56 UTC
Embargoed:


Attachments (Terms of Use)
Makefile to reproduce relink bug (556 bytes, text/plain)
2003-05-18 21:28 UTC, Joe Orton
no flags Details
Makefile #2 to reproduce relink bug (627 bytes, text/plain)
2003-05-18 21:39 UTC, Joe Orton
no flags Details
patch to fix libtool script (363 bytes, patch)
2003-05-18 21:47 UTC, Joe Orton
no flags Details | Diff
.la file for the libodbcinstQ library (1.95 KB, text/plain)
2003-06-19 15:38 UTC, Fernando Nasser
no flags Details
patch to unixODBS.spec to use and build with system libtool 1.5 (1.11 KB, patch)
2003-06-19 21:13 UTC, Jens Petersen
no flags Details | Diff

Description Joe Orton 2003-05-18 21:27:00 UTC
Description of problem:
There is a bug in the -relink patch included in the libtool RPM; the -L library
paths are added to the link line in the wrong order. This is mentioned in the
comment to the original bug:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=58664#c41

I've condensed the reproduction case down to a single Makefile, which I'll
attach.  The Makefile builds two libraries, libfoo and libbar; libbar depends on
libfoo.

The bug is that when libbar is relinked during installation, it will be linked
against /usr/lib/libfoo.a if that exists, rather than libfoo in the install
destination.  This is illustrated by making a bogus /usr/lib/libfoo.a, which the
linker barfs on.

Version-Release number of selected component (if applicable):
libtool-1.4.3-5

How reproducible:
Always

Steps to Reproduce:
1. $ su -
2. # mkdir test && cd test && cp /path/to/attached/Makefile .
3. # make

Actual results:
libbar is relinked using "-L/usr/lib -L/tmp/relink/usr/lib" which means it will
pick up /usr/lib/libfoo.a, and break.

Expected results:
libbar should be relinked using -L/tmp/relink/usr/lib before -L/usr/lib, or
-L/usr/lib should not be used at all.

Additional info:

Comment 1 Joe Orton 2003-05-18 21:28:09 UTC
Created attachment 91774 [details]
Makefile to reproduce relink bug

Comment 2 Joe Orton 2003-05-18 21:39:34 UTC
Created attachment 91775 [details]
Makefile #2 to reproduce relink bug

The previous Makefile was buggy, it would fail even when the libtool bug is
fixed.

Comment 3 Joe Orton 2003-05-18 21:47:33 UTC
Created attachment 91776 [details]
patch to fix libtool script

As suggested in the comment to bug 58664, the bug is fixed by switching the
order in which variables are added to add_dir.	 This patch illustrates the
necessary change.

Comment 5 Joe Orton 2003-05-29 17:07:20 UTC
This is really a duplicate of bug 71989 - the fix for that bug (don't add
-L/usr/lib when relinking) is a sufficient fix for this problem.

But note that this is not just a problem when cross-compiling.  As everyone
using libtool-1.5 is now discovering and reporting to bug-libtool ;)

Comment 6 Jens Petersen 2003-06-12 06:07:44 UTC
Thanks for the report.  Should be fixed in libtool-1.5-3.

Comment 7 Fernando Nasser 2003-06-12 22:29:25 UTC
Did this fix really make into libtool-1.5-3?  I still see the -L<rpath> when
trying to libtool mode=install a unixODBC library that depends on a previously
built one.

Comment 8 Jens Petersen 2003-06-13 03:43:56 UTC
Details, please. :)

You're quite sure that you're using the system libtool (say with "make
LIBTOOL=/usr/bin/libtool") and not any copy included in unixODBC?

Comment 9 Joe Orton 2003-06-13 06:54:54 UTC
Note that this patch only *reorders* the link line, so yes, -L<rpath> will still
appear, but *after* -L<destdir><rpath> which was the important thing for me,
though see comment 5 above.



Comment 10 Joe Orton 2003-06-17 13:43:46 UTC
Whilst I can't reproduce this on x86 any more with libtool-1.5-3, I'm still
seeing the same problem on x86_64 in the subversion build, unfortunately :(



Comment 11 Fernando Nasser 2003-06-18 17:40:06 UTC
Well, to make sure I've replaced unixODBC's own version of libtool with the
libtool-1.5-3.  Stil the same thing: -l/usr/lib is there before the reference to
the -lodbcinst library that just have been relinked in the previous make step. 
This causes either an error or the library that I am building being linked to
the one installed in /usr/lib (from a previous release of unixODBC).

Here is part of the log (please ask me if you need to see more).  Note how
../odbcinst/libodbcinst.la gets converted to -lodbcinst just after the -L/usr/lib.

Note that -inst-prefix-dir was correctly set in the generated relink command.

-inst-prefix-dir /home/fnasser/tmp/unixODBC-2.2.5-root)

If I understand you right, I should have seen:

-L/home/fnasser/tmp/unixODBC-2.2.5-root -lodbcinst -L/usr/lib -l.....


Is there anything else I must change in this package so that the fix is effective?


make[2]: Entering directory `/home/fnasser/topdir/BUILD/unixODBC-2.2.5/odbcinstQ'
/bin/sh ../mkinstalldirs /home/fnasser/tmp/unixODBC-2.2.5-root/usr/lib
 /bin/sh ../libtool --mode=install /usr/bin/install -c  libodbcinstQ.la
/home/fnasser/tmp/unixODBC-2.2.5-root/usr/lib/libodbcinstQ.la
(cd /home/fnasser/topdir/BUILD/unixODBC-2.2.5/odbcinstQ; /bin/sh ../libtool
--mode=relink g++ -O2 -g -pipe -march=i386 -mcpu=i686 -o libodbcinstQ.la -rpath
/usr/lib -version-info 1:0:0 -export-dynamic -export-symbols odbcinstQ.exp
-module CAbout.lo CCredits.lo CDLL.lo CDSNList.lo CDriverPrompt.lo CDrivers.lo
CFileDSN.lo CFileList.lo CFileSelector.lo CODBCConfig.lo CProperties.lo
CPropertiesFrame.lo CSplashDialog.lo CStatDetails.lo CStatSummary.lo CStats.lo
CSystemDSN.lo CTracing.lo CUserDSN.lo SQLManageDataSources.lo mCAbout.lo
mCCredits.lo mCDriverPrompt.lo mCDrivers.lo mCDSNList.lo mCFileDSN.lo
mCFileList.lo mCFileSelector.lo mCODBCConfig.lo mCProperties.lo
mCPropertiesFrame.lo mCStatDetails.lo mCStatSummary.lo mCStats.lo mCSystemDSN.lo
mCTracing.lo mCUserDSN.lo -L/usr/X11R6/lib -L/usr/lib/qt-3.1/lib -lqt-mt -lXext
-lX11 ../odbcinst/libodbcinst.la ../extras/libodbcextraslc.la
../DriverManager/libodbc.la -lpthread -inst-prefix-dir
/home/fnasser/tmp/unixODBC-2.2.5-root)
g++ -shared -nostdlib /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crti.o
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/crtbeginS.o  .libs/CAbout.o
.libs/CCredits.o .libs/CDLL.o .libs/CDSNList.o .libs/CDriverPrompt.o
.libs/CDrivers.o .libs/CFileDSN.o .libs/CFileList.o .libs/CFileSelector.o
.libs/CODBCConfig.o .libs/CProperties.o .libs/CPropertiesFrame.o
.libs/CSplashDialog.o .libs/CStatDetails.o .libs/CStatSummary.o .libs/CStats.o
.libs/CSystemDSN.o .libs/CTracing.o .libs/CUserDSN.o
.libs/SQLManageDataSources.o .libs/mCAbout.o .libs/mCCredits.o
.libs/mCDriverPrompt.o .libs/mCDrivers.o .libs/mCDSNList.o .libs/mCFileDSN.o
.libs/mCFileList.o .libs/mCFileSelector.o .libs/mCODBCConfig.o
.libs/mCProperties.o .libs/mCPropertiesFrame.o .libs/mCStatDetails.o
.libs/mCStatSummary.o .libs/mCStats.o .libs/mCSystemDSN.o .libs/mCTracing.o
.libs/mCUserDSN.o -Wl,--whole-archive ../extras/.libs/libodbcextraslc.a
-Wl,--no-whole-archive  -L/usr/X11R6/lib -L/usr/lib/qt-3.1/lib -lqt-mt -lXext
-lX11 -L/home/fnasser/tmp/unixODBC-2.2.5-root/usr/lib
-L/usr/lib -lodbcinst -lodbc -lpthread
-L/usr/lib/gcc-lib/i386-redhat-linux/3.2.2
-L/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../.. -lstdc++ -lm -lc -lgcc_s
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/crtendS.o
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crtn.o  -march=i386 -mcpu=i686
-Wl,-soname -Wl,libodbcinstQ.so.1 -Wl,-retain-symbols-file -Wl,odbcinstQ.exp -o
.libs/libodbcinstQ.so.1.0.0
/usr/bin/install -c .libs/libodbcinstQ.so.1.0.0T
/home/fnasser/tmp/unixODBC-2.2.5-root/usr/lib/libodbcinstQ.so.1.0.0


Comment 12 Fernando Nasser 2003-06-19 15:38:54 UTC
Created attachment 92490 [details]
.la file for the libodbcinstQ library

Comment 13 Fernando Nasser 2003-06-19 15:39:28 UTC
It occurred to me that you may want to look at the .la file. The .lai just has
installed=yes and the substitution of the library in the build directory with
some supposedly on /usr/lib.  See the 'dependency_libs' in the diff below:


[fnasser@novo odbcinstQ]$ diff .libs/libodbcinstQ.lai libodbcinstQ.la
17c17
< dependency_libs=' -L/usr/X11R6/lib -L/usr/lib/qt-3.1/lib -lqt-mt -lXext -lX11
/usr/lib/libodbcinst.la /usr/lib/libodbc.la -ldl -lpthread'
---
> dependency_libs=' -L/usr/X11R6/lib -L/usr/lib/qt-3.1/lib -lqt-mt -lXext -lX11
/home/fnasser/topdir/BUILD/unixODBC-2.2.5/odbcinst/libodbcinst.la
/home/fnasser/topdir/BUILD/unixODBC-2.2.5/DriverManager/libodbc.la -ldl
-lpthread   '
25c25
< installed=yes
---
> installed=no
35a36
> relink_command="(cd /home/fnasser/topdir/BUILD/unixODBC-2.2.5/odbcinstQ;
/bin/sh ../libtool --mode=relink g++ -O2 -g -pipe -march=i386 -mcpu=i686 -o
libodbcinstQ.la -rpath /usr/lib -version-info 1:0:0 -export-dynamic
-export-symbols odbcinstQ.exp -module CAbout.lo CCredits.lo CDLL.lo CDSNList.lo
CDriverPrompt.lo CDrivers.lo CFileDSN.lo CFileList.lo CFileSelector.lo
CODBCConfig.lo CProperties.lo
CPropertiesFrame.lo CSplashDialog.lo CStatDetails.lo CStatSummary.lo CStats.lo
CSystemDSN.lo CTracing.lo CUserDSN.lo SQLManageDataSources.lo mCAbout.lo
mCCredits.lo mCDriverPrompt.lo mCDrivers.lo mCDSNList.lo mCFileDSN.lo
mCFileList.lo mCFileSelector.lo mCODBCConfig.lo mCProperties.lo
mCPropertiesFrame.lo mCStatDetails.lo mCStatSummary.lo mCStats.lo mCSystemDSN.lo
mCTracing.lo mCUserDSN.lo -L/usr/X11R6/lib -L/usr/lib/qt-3.1/lib -lqt-mt -lXext
-lX11 ../odbcinst/libodbcinst.la
../extras/libodbcextraslc.la ../DriverManager/libodbc.la -lpthread
@inst_prefix_dir@)"

Comment 14 Jens Petersen 2003-06-19 21:13:22 UTC
Created attachment 92499 [details]
patch to unixODBS.spec to use and build with system libtool 1.5

Ok, I went to the trouble of looking into this a but further.

The current unixODBC-2.2.3-7 builds fine for me and the "-L/usr/lib"'s
appear *after* -L/var/tmp/unixODBC-2.2.3-root/usr/lib in the build log...

libtoolize --force is probably overwriting the libtool file for you.


/usr/bin/libtool  --mode=install /usr/bin/install -c libodbcinstQ.la
/var/tmp/unixODBC-2.2.3-root/usr/lib/libodbcinstQ.la
libtool: install: warning: relinking `libodbcinstQ.la'
(cd /home/petersen/mypkgs/rpms/unixODBC/unixODBC-2.2.3/odbcinstQ; /bin/sh
/usr/bin/libtool --mode=relink g++ -O2 -g -pipe -march=i386 -mcpu=i686 -o
libodbcinstQ.la -rpath /usr/lib -version-info 1:0:0 -export-dynamic
-export-symbols odbcinstQ.exp -module CAbout.lo CCredits.lo CDLL.lo CDSNList.lo
CDriverPrompt.lo CDrivers.lo CFileDSN.lo CFileList.lo CFileSelector.lo
CODBCConfig.lo CProperties.lo CPropertiesFrame.lo CSplashDialog.lo
CStatDetails.lo CStatSummary.lo CStats.lo CSystemDSN.lo CTracing.lo CUserDSN.lo
mCAbout.lo mCCredits.lo mCDSNList.lo mCDriverPrompt.lo mCDrivers.lo
mCFileDSN.lo mCFileList.lo mCFileSelector.lo mCODBCConfig.lo mCProperties.lo
mCPropertiesFrame.lo mCStatDetails.lo mCStatSummary.lo mCStats.lo
mCSystemDSN.lo mCTracing.lo mCUserDSN.lo SQLManageDataSources.lo
-L/usr/X11R6/lib -L/usr/lib/qt-3.1/lib -lqt-mt -lXext -lX11
../odbcinst/libodbcinst.la ../extras/libodbcextraslc.la
../DriverManager/libodbc.la -lm -lpthread -inst-prefix-dir
/var/tmp/unixODBC-2.2.3-root)
g++ -shared -nostdlib /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crti.o
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/crtbeginS.o  .libs/CAbout.o
.libs/CCredits.o .libs/CDLL.o .libs/CDSNList.o .libs/CDriverPrompt.o
.libs/CDrivers.o .libs/CFileDSN.o .libs/CFileList.o .libs/CFileSelector.o
.libs/CODBCConfig.o .libs/CProperties.o .libs/CPropertiesFrame.o
.libs/CSplashDialog.o .libs/CStatDetails.o .libs/CStatSummary.o .libs/CStats.o
.libs/CSystemDSN.o .libs/CTracing.o .libs/CUserDSN.o .libs/mCAbout.o
.libs/mCCredits.o .libs/mCDSNList.o .libs/mCDriverPrompt.o .libs/mCDrivers.o
.libs/mCFileDSN.o .libs/mCFileList.o .libs/mCFileSelector.o
.libs/mCODBCConfig.o .libs/mCProperties.o .libs/mCPropertiesFrame.o
.libs/mCStatDetails.o .libs/mCStatSummary.o .libs/mCStats.o .libs/mCSystemDSN.o
.libs/mCTracing.o .libs/mCUserDSN.o .libs/SQLManageDataSources.o
-Wl,--whole-archive ../extras/.libs/libodbcextraslc.a -Wl,--no-whole-archive 
-L/usr/X11R6/lib -L/usr/lib/qt-3.1/lib -lqt-mt -lXext -lX11
-L/var/tmp/unixODBC-2.2.3-root/usr/lib -L/usr/lib -lodbcinst -lodbc -lpthread
-L/usr/lib/gcc-lib/i386-redhat-linux/3.2.2
-L/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../.. -lstdc++ -lm -lc -lgcc_s
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/crtendS.o
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crtn.o  -march=i386
-mcpu=i686 -Wl,-soname -Wl,libodbcinstQ.so.1 -Wl,-retain-symbols-file
-Wl,odbcinstQ.exp -o .libs/libodbcinstQ.so.1.0.0

Comment 15 Jens Petersen 2003-06-19 21:16:04 UTC
Joe, did you sort out the subversion problem in comment 10?

Comment 16 Joe Orton 2003-06-20 11:50:04 UTC
No, I haven't had time to look into it further yet, sorry.  If you want to try
it yourself just try rebuilding the .src.rpm from CVS HEAD on an AMD64 box: it
will fail with relocation errors during relink since it picks up
/usr/lib/libsvn*.a before the installroot's libsvn*.so at some point.

Comment 17 Fernando Nasser 2003-06-23 16:06:31 UTC
Joe, you are correct.  The 1.5-3 version did solve the problem.
As I posted before, I now have:

-L/var/tmp/unixODBC-2.2.3-root/usr/lib -L/usr/lib -lodbcinst

which gets my recently built library before finding the installed one (if any).

So it is indeed fixed.

Thanks for all your help.

Comment 18 Joe Orton 2003-06-24 12:13:56 UTC
Great, the subversion build problem was not a libtool problem, -L/usr/lib64 had
slipped in from elsewhere.  I think this can be closed now.


Note You need to log in before you can comment on or make changes to this bug.