[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fix for prefixed installs requiring relink
From: |
Wesley W. Terpstra |
Subject: |
Fix for prefixed installs requiring relink |
Date: |
Sun, 22 Oct 2000 02:22:20 -0600 |
User-agent: |
Mutt/1.2.5i |
At present in the cvs head libtool revision, installing a library which
depends on another un-installed library forces the dependent library to be
relinked at install time. This mechanism has a bug however in the situation
where both libraries are installed to something other than their libdir.
Example:
libtool gcc -o foo.lo -c foo.c
libtool gcc -o bar.lo -c bar.c
libtool gcc -o libfoo.la foo.lo -rpath /usr/lib
libtool gcc -o libbar.la bar.lo libfoo.la -rpath /usr/lib
--- All good so far; the libraries have correct inter-depends and will run
in the current dir.
libtool install -D libfoo.la /usr/lib/libfoo.la
libtool install -D libbar.la /usr/lib/libbar.la
--- This will also work fine, libbar.la is relinked using -L/usr/lib and
-lfoo
libtool install -D libfoo.la `pwd`/tmp/usr/lib/libfoo.la
libtool install -D libbar.la `pwd`/tmp/usr/lib/libbar.la
Here's where we get slammed. The relink of libbar.la uses -L/usr/lib and
-lfoo. Assuming that you are compiling the package in your home directory
and there is no /usr/lib/libfoo.*, the relink will fail. Further, libtool
does not return an error value, thus an automatic build can continue far
beyond this problem.
This is unacceptable b/c when building packages for a distribution (rpm,
deb, ..) one needs to install to a location other than the root directory,
yet have these libraries linked as though they were installed into the root
directory.
My included patch solves this problem with one stipulation:
You can install dependent libraries anywhere as long as the complete libdir
path is on the end. Hence the above example would work, while
`pwd`/tmp/lib/libfoo.la would not as there is no usr/lib on the end.
How it works:
---
We add a secret command-line option "-inst-prefix-dir" which can be passed
at relink time:
libtool --mode=relink gcc -o libbar.la bar.lo libfoo.la rpath /usr/lib
-inst-prefix-dir `pwd`/tmp
This arguement is prefixed onto the library search paths given to gcc.
So -L/usr/lib above becomes '-L/home/terpstra/foo/tmp/usr/lib -L/usr/lib'.
Note that I leave the installed location as a second chance.
When outputing the relink_command='...' into a .la file, the very end of the
command has a @inst_prefix_dir@ appended to it.
During the installation of a library, we strip off the libdir from the
target dir, thus in my example, we end up with `pwd`/tmp for the prefix. If
a relink is required, we replace @inst_prefix_dir@ in the relink_command
with '-inst_prefix_dir <value>'
My patch also includes a test which shows relink failing without my patch
and suceeding with it.
Please thoroughly audit my patch b/c I am very new to libtool and have
likely missed some boundary conditions.
--
Wesley W. Terpstra <address@hidden>
Javien Canada Inc. - Linux Developer
libtool-fix-prefixed-install-relink.diff.gz
Description: Binary data
pgpZUuHrlh2i2.pgp
Description: PGP signature
- Fix for prefixed installs requiring relink,
Wesley W. Terpstra <=