[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: libtool "no symlinked libs" patch
From: |
Jacob Meuser |
Subject: |
Re: libtool "no symlinked libs" patch |
Date: |
Sun, 27 Nov 2005 16:03:56 -0800 |
User-agent: |
Mutt/1.4.2i |
On Sun, Nov 27, 2005 at 09:06:09AM +0100, Ralf Wildenhues wrote:
> Hi Jacob,
>
> * Jacob Meuser wrote on Sun, Nov 27, 2005 at 05:42:07AM CET:
> > On Wed, Nov 23, 2005 at 05:04:07PM +0000, Ralf Wildenhues wrote:
> > > Marc Espie <espie <at> nerim.net> writes:
> >
> > > > I'm very annoyed at
> > > > libtool --mode=link cc -L/usr/local/lib -o foo foo.o ./libbar.la
> > > > expanding into some stuff like:
> > > > cc -L/usr/local/lib -L. -o foo foo.o -lbar
> > > > which gets us the libbar installed under /usr/local/lib instead of the
> > > > one
> > > > we just built...
> > >
> > > Genuine bug in Libtool's OpenBSD support, most likely some wrong
> > > assumption
> > > about which path overrides which. Current branch-1-5 does not do this on
> > > GNU/Linux nor on FreeBSD -- sorry, I don't currently have access to
> > > OpenBSD.
> > >
> > > For static libbar, it creates on both systems
> > > gcc -o foo foo.o ./.libs/libbar.a
> > > and for shared libbar it creates
> > > gcc -o .libs/foo foo.o ./.libs/libbar.so -Wl,--rpath -Wl,/tmp/inst
> >
> > I think you are not understanding Marc's point.
>
> No, but I pasted the output in a misleading way.
>
> > what happens with -L/usr/local/lib?
>
> Libtool knows that the library is uninstalled, because this information
> is encoded in libbar.la
yes, it winds up in $notinst_path. I disconvered that last night.
> , hence knows to hardcode it _even_ when the
> installed path is given first.
I don't think that is the issue, or even what is wanted, though.
> Attached an example. Please modify so
> it fails on OpenBSD. Elsewhere it creates
>
> gcc -o .libs/main main.o -L/tmp/inst/lib ./.libs/liba.so \
> -Wl,--rpath -Wl,/tmp/inst/lib
>
> Now please: be specific in the bug report, and state exactly which
> libtool version you are using (including which patches you have
> applied) and post all output. Also please show 'libtool --config'.
libtool-1.5.20 w/o any patches: ./configure; make; sudo make install
here's the change to run.sh. as I said earlier, this is a
lot closer to what automake produces:
--- run.sh.orig Sun Nov 27 15:37:42 2005
+++ run.sh Sun Nov 27 15:23:00 2005
@@ -1,5 +1,6 @@
: ${LIBTOOL=libtool}
: ${CC=gcc}
+: ${LDFLAGS=-L/usr/local/lib}
instdir=`pwd`/inst
libdir=$instdir/lib
@@ -7,15 +8,15 @@
echo 'int a() { return 1; }' > a.c
$LIBTOOL --mode=compile --tag=CC $CC -c a.c
-$LIBTOOL --mode=link --tag=CC $CC -o liba.la a.lo -rpath "$libdir"
+$LIBTOOL --mode=link --tag=CC $CC ${LDFLAGS} -o liba.la a.lo -rpath "$libdir"
$LIBTOOL --mode=install cp liba.la "$libdir"/liba.la
$LIBTOOL --mode=clean rm -f liba.la
echo 'int a() { return 2; }' > a.c
$LIBTOOL --mode=compile --tag=CC $CC -c a.c
-$LIBTOOL --mode=link --tag=CC $CC -o liba.la a.lo -rpath "$libdir"
+$LIBTOOL --mode=link --tag=CC $CC ${LDFLAGS} -o liba.la a.lo -rpath "$libdir"
echo 'extern int a(); int main() { return a(); }' > main.c
$CC -c main.c
-$LIBTOOL --mode=link --tag=CC $CC -o main main.o -L"$libdir" ./liba.la
+$LIBTOOL --mode=link --tag=CC $CC ${LDFLAGS} -o main main.o -L"$libdir"
./liba.la
./main; echo $?
puff:~/tmp/lt% ./run.sh
gcc -c a.c -fPIC -DPIC -o .libs/a.o
gcc -c a.c -o a.o >/dev/null 2>&1
rm -fr .libs/liba.a .libs/liba.la .libs/liba.lai .libs/liba.so.0.0
gcc -shared -fPIC -DPIC -o .libs/liba.so.0.0 .libs/a.o -L/usr/local/lib
ar cru .libs/liba.a a.o
ranlib .libs/liba.a
creating liba.la
(cd .libs && rm -f liba.la && ln -s ../liba.la liba.la)
cp .libs/liba.so.0.0 /home/jakemsr/tmp/lt/inst/lib/liba.so.0.0
cp .libs/liba.lai /home/jakemsr/tmp/lt/inst/lib/liba.la
cp .libs/liba.a /home/jakemsr/tmp/lt/inst/lib/liba.a
ranlib -t /home/jakemsr/tmp/lt/inst/lib/liba.a
chmod 644 /home/jakemsr/tmp/lt/inst/lib/liba.a
PATH="$PATH:/sbin" ldconfig -m /home/jakemsr/tmp/lt/inst/lib
ldconfig: /var/run/ld.so.hints.HRcWH27055: Permission denied
----------------------------------------------------------------------
Libraries have been installed in:
/home/jakemsr/tmp/lt/inst/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- use the `-Wl,-rpath,LIBDIR' linker flag
- have your system administrator run these commands:
PATH="$PATH:/sbin" ldconfig -m /home/jakemsr/tmp/lt/inst/lib
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
rm -f liba.la .libs/liba.so.0.0 .libs/liba.so.0.0 .libs/liba.a .libs/liba.la
.libs/liba.lai
rmdir .libs
gcc -c a.c -fPIC -DPIC -o .libs/a.o
gcc -c a.c -o a.o >/dev/null 2>&1
gcc -shared -fPIC -DPIC -o .libs/liba.so.0.0 .libs/a.o -L/usr/local/lib
ar cru .libs/liba.a a.o
ranlib .libs/liba.a
creating liba.la
(cd .libs && rm -f liba.la && ln -s ../liba.la liba.la)
gcc -o .libs/main main.o -L/usr/local/lib -L/home/jakemsr/tmp/lt/inst/lib
-L./.libs -la -Wl,-rpath,/home/jakemsr/tmp/lt/inst/lib
creating main
2
puff:~/tmp/lt%
see, if there is a liba.so.0.0 in /usr/local/lib it will get used
instead of the one in /home/jakemsr/tmp/lt/inst/lib. quoting
cc(1):
... Order does matter when you use several options of the same
kind; for example, if you specify -L more than once, the
directories are searched for in the specified order.
> I am pretty sure our testsuite covers this, too. Any failures on
> OpenBSD? (Please run with VERBOSE=x so one can see actually useful
> output.)
i have previously reported all testsuite failures to the libtool lists.
IIRC there were two, one I understood why and the other I didn't.
no one seemed interested.
for completeness:
puff:~/tmp/lt% libtool --config
# Libtool was configured on host puff.jakemsr.gom:
# Shell to use when invoking shell scripts.
SHELL="/bin/sh"
# Whether or not to build shared libraries.
build_libtool_libs=yes
# Whether or not to build static libraries.
build_old_libs=yes
# Whether or not to add -lc for building shared libraries.
build_libtool_need_lc=yes
# Whether or not to disallow shared libs when runtime libs are static
allow_libtool_libs_with_static_runtimes=no
# Whether or not to optimize for fast installation.
fast_install=needless
# The host system.
host_alias=
host=x86_64-unknown-openbsd3.8
host_os=openbsd3.8
# The build system.
build_alias=
build=x86_64-unknown-openbsd3.8
build_os=openbsd3.8
# An echo program that does not interpret backslashes.
echo="/bin/echo"
# The archiver.
AR="ar"
AR_FLAGS="cru"
# A C compiler.
LTCC="gcc"
# A language-specific compiler.
CC="gcc"
# Is the compiler the GNU C compiler?
with_gcc=yes
# An ERE matcher.
EGREP="grep -E"
# The linker used to build libraries.
LD="/usr/bin/ld"
# Whether we need hard or soft links.
LN_S="ln -s"
# A BSD-compatible nm program.
NM="/usr/bin/nm -B"
# A symbol stripping program
STRIP="strip"
# Used to examine libraries when file_magic_cmd begins "file"
MAGIC_CMD=file
# Used on cygwin: DLL creation program.
DLLTOOL="dlltool"
# Used on cygwin: object dumper.
OBJDUMP="objdump"
# Used on cygwin: assembler.
AS="as"
# The name of the directory that contains temporary libtool files.
objdir=.libs
# How to create reloadable object files.
reload_flag=" -r"
reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs"
# How to pass a linker flag through the compiler.
wl="-Wl,"
# Object file suffix (normally "o").
objext="o"
# Old archive suffix (normally "a").
libext="a"
# Shared library suffix (normally ".so").
shrext_cmds='.so'
# Executable file suffix (normally "").
exeext=""
# Additional compiler flags for building library objects.
pic_flag=" -fPIC -DPIC"
pic_mode=default
# What is the maximum length of a command?
max_cmd_len=196608
# Does compiler simultaneously support -c and -o options?
compiler_c_o="yes"
# Must we lock files when doing compilation?
need_locks="no"
# Do we need the lib prefix for modules?
need_lib_prefix=no
# Do we need a version for libraries?
need_version=no
# Whether dlopen is supported.
dlopen_support=yes
# Whether dlopen of programs is supported.
dlopen_self=yes
# Whether dlopen of statically linked programs is supported.
dlopen_self_static=yes
# Compiler flag to prevent dynamic linking.
link_static_flag="-static"
# Compiler flag to turn off builtin functions.
no_builtin_flag=" -fno-builtin"
# Compiler flag to allow reflexive dlopens.
export_dynamic_flag_spec="\${wl}-E"
# Compiler flag to generate shared objects directly from archives.
whole_archive_flag_spec=""
# Compiler flag to generate thread-safe objects.
thread_safe_flag_spec=""
# Library versioning type.
version_type=sunos
# Format of library name prefix.
libname_spec="lib\$name"
# List of archive names. First name is the real one, the rest are links.
# The last name is the one that the linker finds with -lNAME.
library_names_spec="\${libname}\${release}\${shared_ext}\$versuffix
\${libname}\${shared_ext}\$versuffix"
# The coded name of the library, if different from the real name.
soname_spec=""
# Commands used to build and install an old-style archive.
RANLIB="ranlib"
old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs\$old_deplibs~\$RANLIB
\$oldlib"
old_postinstall_cmds="\$RANLIB -t \$oldlib~chmod 644 \$oldlib"
old_postuninstall_cmds=""
# Create an old-style archive from a shared archive.
old_archive_from_new_cmds=""
# Create a temporary old-style archive to link instead of a shared archive.
old_archive_from_expsyms_cmds=""
# Commands used to build and install a shared archive.
archive_cmds="\$CC -shared \$pic_flag -o \$lib \$libobjs \$deplibs
\$compiler_flags"
archive_expsym_cmds="\$CC -shared \$pic_flag -o \$lib \$libobjs \$deplibs
\$compiler_flags \${wl}-retain-symbols-file,\$export_symbols"
postinstall_cmds=""
postuninstall_cmds=""
# Commands used to build a loadable module (assumed same as above if empty)
module_cmds=""
module_expsym_cmds=""
# Commands to strip libraries.
old_striplib="strip --strip-debug"
striplib="strip --strip-unneeded"
# Dependencies to place before the objects being linked to create a
# shared library.
predep_objects=""
# Dependencies to place after the objects being linked to create a
# shared library.
postdep_objects=""
# Dependencies to place before the objects being linked to create a
# shared library.
predeps=""
# Dependencies to place after the objects being linked to create a
# shared library.
postdeps=""
# The library search path used internally by the compiler when linking
# a shared library.
compiler_lib_search_path=""
# Method to check whether dependent libraries are shared objects.
deplibs_check_method="match_pattern
/lib[^/]+(\\.so\\.[0-9]+\\.[0-9]+|\\.so|_pic\\.a)\$"
# Command to use when deplibs_check_method == file_magic.
file_magic_cmd="\$MAGIC_CMD"
# Flag that allows shared libraries with undefined symbols to be built.
allow_undefined_flag=""
# Flag that forces no undefined symbols.
no_undefined_flag=""
# Commands used to finish a libtool library installation in a directory.
finish_cmds="PATH=\\\"\\\$PATH:/sbin\\\" ldconfig -m \$libdir"
# Same as above, but a single script fragment to be evaled but not shown.
finish_eval=""
# Take the output of nm and produce a listing of raw symbols and C names.
global_symbol_pipe="sed -n -e 's/^.*[ ]\\([BCDEGRST][BCDEGRST]*\\)[ ][
]*\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 \\2 \\2/p'"
# Transform the output of nm in a proper C declaration
global_symbol_to_cdecl="sed -n -e 's/^. .* \\(.*\\)\$/extern int \\1;/p'"
# Transform the output of nm in a C name address pair
global_symbol_to_c_name_address="sed -n -e 's/^: \\([^ ]*\\) \$/ {\\\"\\1\\\",
(lt_ptr) 0},/p' -e 's/^[BCDEGRST] \\([^ ]*\\) \\([^ ]*\\)\$/ {\"\\2\",
(lt_ptr) \\&\\2},/p'"
# This is the shared library runtime path variable.
runpath_var=
# This is the shared library path variable.
shlibpath_var=LD_LIBRARY_PATH
# Is shlibpath searched before the hard-coded library search path?
shlibpath_overrides_runpath=yes
# How to hardcode a shared library path into an executable.
hardcode_action=immediate
# Whether we should hardcode library paths into libraries.
hardcode_into_libs=no
# Flag to hardcode $libdir into a binary during linking.
# This must work even if $libdir does not exist.
hardcode_libdir_flag_spec="\${wl}-rpath,\$libdir"
# If ld is used when linking, flag to hardcode $libdir into
# a binary during linking. This must work even if $libdir does
# not exist.
hardcode_libdir_flag_spec_ld=""
# Whether we need a single -rpath flag with a separated argument.
hardcode_libdir_separator=""
# Set to yes if using DIR/libNAME during linking hardcodes DIR into the
# resulting binary.
hardcode_direct=yes
# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
# resulting binary.
hardcode_minus_L=no
# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
# the resulting binary.
hardcode_shlibpath_var=no
# Set to yes if building a shared library automatically hardcodes DIR into the
library
# and all subsequent libraries and executables linked against it.
hardcode_automatic=no
# Variables whose values should be saved in libtool wrapper scripts and
# restored at relink time.
variables_saved_for_relink="PATH GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
# Whether libtool must link a program against all its dependency libraries.
link_all_deplibs=unknown
# Compile-time system search path for libraries
sys_lib_search_path_spec=" /usr/lib/gcc-lib/amd64-unknown-openbsd3.8/3.3.5/
/usr/lib/gcc/amd64-unknown-openbsd3.8/3.3.5/
/usr/lib/gcc-lib/amd64-unknown-openbsd3.8/3.3.5/../../../../amd64-unknown-openbsd3.8/lib/amd64-unknown-openbsd3.8/3.3.5/
/usr/lib/gcc-lib/amd64-unknown-openbsd3.8/3.3.5/../../../../amd64-unknown-openbsd3.8/lib/
/usr/lib/gcc-lib/amd64-unknown-openbsd3.8/3.3.5//usr/lib/amd64-unknown-openbsd3.8/3.3.5/
/usr/lib/gcc-lib/amd64-unknown-openbsd3.8/3.3.5//usr/lib/
/lib/amd64-unknown-openbsd3.8/3.3.5/ /lib/
/usr/lib/amd64-unknown-openbsd3.8/3.3.5/ /usr/lib/"
# Run-time system search path for libraries
sys_lib_dlsearch_path_spec="/lib /usr/lib"
# Fix the shell variable $srcfile for the compiler.
fix_srcfile_path=""
# Set to yes if exported symbols are required.
always_export_symbols=no
# The commands to list exported symbols.
export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe |
\$SED 's/.* //' | sort | uniq > \$export_symbols"
# The commands to extract the exported symbol list from a shared archive.
extract_expsyms_cmds=""
# Symbols that should not be listed in the preloaded symbols.
exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
# Symbols that must always be exported.
include_expsyms=""
puff:~/tmp/lt%
--
<address@hidden>