Bug 91110 - Bug in library path ordering of relink patch
Bug in library path ordering of relink patch
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: libtool (Show other bugs)
9
All Linux
medium Severity high
: ---
: ---
Assigned To: Jens Petersen
Jay Turner
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-05-18 17:25 EDT by Joe Orton
Modified: 2015-01-07 19:05 EST (History)
2 users (show)

See Also:
Fixed In Version: 1.5-3
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-06-24 08:13:56 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Makefile to reproduce relink bug (556 bytes, text/plain)
2003-05-18 17:28 EDT, Joe Orton
no flags Details
Makefile #2 to reproduce relink bug (627 bytes, text/plain)
2003-05-18 17:39 EDT, Joe Orton
no flags Details
patch to fix libtool script (363 bytes, patch)
2003-05-18 17:47 EDT, Joe Orton
no flags Details | Diff
.la file for the libodbcinstQ library (1.95 KB, text/plain)
2003-06-19 11:38 EDT, 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 17:13 EDT, Jens Petersen
no flags Details | Diff

  None (edit)
Description Joe Orton 2003-05-18 17:27:00 EDT
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 17:28:09 EDT
Created attachment 91774 [details]
Makefile to reproduce relink bug
Comment 2 Joe Orton 2003-05-18 17:39:34 EDT
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 17:47:33 EDT
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 13:07:20 EDT
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@gnu.org ;)
Comment 6 Jens Petersen 2003-06-12 02:07:44 EDT
Thanks for the report.  Should be fixed in libtool-1.5-3.
Comment 7 Fernando Nasser 2003-06-12 18:29:25 EDT
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-12 23:43:56 EDT
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 02:54:54 EDT
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 09:43:46 EDT
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 13:40:06 EDT
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 11:38:54 EDT
Created attachment 92490 [details]
.la file for the libodbcinstQ library
Comment 13 Fernando Nasser 2003-06-19 11:39:28 EDT
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 17:13:22 EDT
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 17:16:04 EDT
Joe, did you sort out the subversion problem in comment 10?
Comment 16 Joe Orton 2003-06-20 07:50:04 EDT
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 12:06:31 EDT
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 08:13:56 EDT
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.