libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new shlibpath_overrides_runpath test


From: Ralf Wildenhues
Subject: new shlibpath_overrides_runpath test
Date: Sat, 16 Sep 2006 00:12:21 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

The old hardcode tests are partly bogus and broken.  Rather than trying
to fix the broken ones, I intend to add new ones to the new testsuite
(but not yet remove the old ones; they still serve a purpose, and the
new one is certainly not bug free).

The first patch below tests that shlibpath_var works and that the
setting of shlibpath_overrides_runpath is correct.

Tested on GNU/Linux (Debian) where it succeeds, and GNU/Linux (Gentoo)
where it rightly fails, unlike the demo-relink and depdemo-relink tests;
tested further on AIX (both with and without runtimelinking), Solaris,
OpenBSD, FreeBSD, HP-UX/IA and /PA (it fails for the latter, as we do
not use -Wl,+s which would enable the override).

The test is not yet exposing as much as it could be: only a program
linked to a shared library is tested.  But for current usage of
shlibpath_overrides_runpath this is sufficient (for some other uses
of $shlibpath_var it is not yet).

Wrt. fixing the setting for Gentoo: a fully portable configure test
would have to repeat almost half of the test below; ugly.  Maybe we can
get away with testing only whether -Wl,-rpath,/foo sets DT_RUNPATH in a
program; see the second patch below.  It makes use of objdump, but only
on Linux and k*bsd*-gnu, and falls back to the current setting in any
failure case, so it should be fairly safe IMHO.

OK to apply both?

I still have to think about the HP-UX/PA case.

Cheers,
Ralf

        * tests/shlibpath.at: New file, with...
        (shlibpath_overrides_runpath): ...new test.
        * Makefile.am: Update.

        * libltdl/m4/libtool.m4 (_LT_SYS_DYNAMIC_LINKER) [ linux ]
        [ k*bsd*-gnu ]: Test if ld sets DT_RUNPATH; in that case, set
        shlib_overrides_runpath to `yes'.  Fixes test failure of new
        test on Gentoo GNU/Linux.

Index: Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/Makefile.am,v
retrieving revision 1.198
diff -u -r1.198 Makefile.am
--- Makefile.am 12 Sep 2006 18:02:31 -0000      1.198
+++ Makefile.am 16 Sep 2006 22:06:25 -0000
@@ -399,5 +399,6 @@
                  tests/link-order.at \
                  tests/fail.at \
+                 tests/shlibpath.at \
                  tests/static.at \
                  tests/destdir.at \
                  tests/old-m4-iface.at \
--- /dev/null   2006-05-22 13:44:12.000000000 +0200
+++ tests/shlibpath.at  2006-09-16 00:10:48.000000000 +0200
@@ -0,0 +1,68 @@
+# Hand crafted tests for GNU Libtool.                         -*- Autotest -*-
+# Copyright 2006 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# Test shlibpath settings.
+
+AT_SETUP([shlibpath_overrides_runpath])
+
+mkdir sub sub/lib sub/bin
+echo 'int a () { return 0; }' > a.c
+echo 'extern int a (); int main () { return a(); }' > m.c
+$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c
+$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la a.lo -rpath `pwd`/sub/lib
+$LIBTOOL --mode=install cp liba.la `pwd`/sub/lib/liba.la
+$LIBTOOL --mode=clean rm -f liba.la
+rm -f sub/lib/liba.la
+
+$CC $CPPFLAGS $CFLAGS -c m.c
+AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o m m.$OBJEXT -Lsub/lib 
-la -R`pwd`/sub/lib],
+         [], [ignore], [ignore])
+AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o m2 m.$OBJEXT -Lsub/lib 
-la],
+         [], [ignore], [ignore])
+
+mv sub moved
+mkdir sub sub/lib sub/bin
+echo 'int wrong_lib () { return 0; }' > a.c
+$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c
+$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la a.lo -rpath `pwd`/sub/lib
+$LIBTOOL --mode=install cp liba.la `pwd`/sub/lib/liba.la
+$LIBTOOL --mode=clean rm -f liba.la
+
+eval `$LIBTOOL --config | $EGREP 
'^(shlibpath_var|shlibpath_overrides_runpath)='`
+
+# No point checking a system with static libraries:
+AT_CHECK([{ ./m || exit 1; } && exit 77], [1], [ignore], [ignore])
+
+if test "$shlibpath_var" = PATH; then
+  addpath=`pwd`/moved/bin
+else
+  addpath=`pwd`/moved/lib
+fi
+sep=
+eval test -n \"\$$shlibpath_var\" && sep=:
+eval $shlibpath_var='$addpath$sep$'$shlibpath_var
+export $shlibpath_var
+if test "$shlibpath_overrides_runpath" != no; then
+  LT_AT_EXEC_CHECK([./m], [0], [ignore], [ignore])
+else
+  AT_CHECK([./m || exit 1], [1], [ignore], [ignore])
+fi
+# Test that shlibpath_var is effective in adding paths at all:
+LT_AT_EXEC_CHECK([./m2], [0], [ignore], [ignore])
+
+AT_CLEANUP



Index: libltdl/m4/libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/m4/libtool.m4,v
retrieving revision 1.82
diff -u -r1.82 libtool.m4
--- libltdl/m4/libtool.m4       25 Aug 2006 15:04:30 -0000      1.82
+++ libltdl/m4/libtool.m4       16 Sep 2006 22:08:05 -0000
@@ -2275,6 +2275,15 @@
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
+  # Some binutils ld are patched to set DT_RUNPATH 
+  save_LDFLAGS=$LDFLAGS
+  libdir=/foo wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) \
+  eval LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+    [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep 
"RUNPATH.*$libdir"],
+       [shlibpath_overrides_runpath=yes])])
+  LDFLAGS=$save_LDFLAGS
+
   # This implies no fast_install, which is unacceptable.
   # Some rework will be needed to allow for fast_install
   # before this can be enabled.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]