libtool-patches
[Top][All Lists]
Advanced

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

Re: Bug#391427: Link order


From: Ralf Wildenhues
Subject: Re: Bug#391427: Link order
Date: Sat, 21 Oct 2006 13:30:31 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

[ adding libtool-patches; this is addressing
  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=391427#80 ]

Hello, and sorry for the delay.

* Kurt Roeckx wrote on Sat, Oct 07, 2006 at 08:34:29PM CEST:
> 
> I agree that libraries picked up from the .la file would better be added
> at the end of the list of libraries.  But I'm not sure if that's going
> to break something or not.  I guess I need to think more about this.

Maybe this testsuite addition helps you with your thoughts.

OK to apply?  Note that this kind of test is IMHO clearly controversial;
there is definitely a choice to make whether Libtool wants to commit to
supporting such a case or not.  (I haven't tested whether it works on
all kinds of systems.)

But also there is clearly no escape from the need of adding several such
cases, to define more clearly the semantics that Libtool wants to
support.


Elsewhere in the bug thread, Kurt wrote:
> I think this is the relavant change:
> -  lt_module   module   = dlopen (filename, LT_GLOBAL | LT_LAZY_OR_NOW);
> +  lt_module   module   = dlopen (filename, LT_LAZY_OR_NOW);
> 
> Which is a backport from the head/2.0 branch.

Yes there is a problem with this change, there have been some reports.
Before we release 2.0, we intend to add functionality to choose the
desired behavior (with non- global being the default).

Cheers,
Ralf

2006-10-21  Ralf Wildenhues  <address@hidden>

        * tests/link-order2.at: New test.
        * Makefile.am: Adjust.

Index: Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/Makefile.am,v
retrieving revision 1.200
diff -u -r1.200 Makefile.am
--- Makefile.am 17 Sep 2006 20:02:15 -0000      1.200
+++ Makefile.am 10 Oct 2006 11:13:35 -0000
@@ -403,6 +403,7 @@
                  tests/inherited_flags.at \
                  tests/convenience.at \
                  tests/link-order.at \
+                 tests/link-order2.at \
                  tests/fail.at \
                  tests/shlibpath.at \
                  tests/static.at \
--- /dev/null   2006-05-22 13:44:12.000000000 +0200
+++ tests/link-order2.at        2006-10-10 08:56:35.000000000 +0200
@@ -0,0 +1,69 @@
+# 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.
+
+# link-order2.test: make sure that depdepls are added right after
+# the libs that pull them in: necessary at least for static linking
+# and on systems where libraries do not link against other libraries,
+# in order to do this: override a commonly used symbol in a commonly
+# used library.
+
+AT_SETUP([Link order of deplibs.])
+AT_KEYWORDS([libtool])
+LDFLAGS="$LDFLAGS -no-undefined"
+libdir=`pwd`/inst/lib
+mkdir inst inst/bin inst/lib
+
+cat >a.c <<\EOF
+/* pretend we have a better sine function */
+double sin (double x) { return 0.0; }
+EOF
+
+cat >b.c <<\EOF
+extern double sin (double);
+double b (double x) { return sin (x); }
+EOF
+
+cat >main.c <<\EOF
+#include <math.h>
+extern double b (double);
+int main (void)
+{
+  return fabs (b (3.1415 / 2.)) < 0.01 && fabs (sqrt (4.) - 2.) < 0.01;
+}
+EOF
+
+$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c
+$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c b.c
+$CC $CPPFLAGS $CFLAGS -c main.c
+for static in '' -static; do
+  $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS $static -o liba.la a.lo -rpath 
$libdir
+  $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS $static -o libb.la b.lo liba.la 
-rpath $libdir
+  $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main main.$OBJEXT libb.la -lm
+  LT_AT_EXEC_CHECK([./main])
+  $LIBTOOL --mode=install cp liba.la $libdir/liba.la
+  $LIBTOOL --mode=install cp libb.la $libdir/libb.la
+  $LIBTOOL --mode=install cp main $bindir/main
+  $LIBTOOL --mode=clean rm -f liba.la libb.la
+  LT_AT_EXEC_CHECK([$bindir/main])
+done
+
+
+# Now the converse: if both the program and the library need libm, then
+# it needs to be sorted last.  (TODO)
+
+AT_CLEANUP




reply via email to

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