From: Alexandre Oliva Date: Thu, 14 Apr 2005 11:59:10 +0000 (+0000) Subject: * config/ltmain.m4sh (link mode): Add to tmp_libs paths for libtool dep X-Git-Tag: release-2-1b~675 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31327f332da6b4f19129a901d5ee327085911215;p=thirdparty%2Flibtool.git * config/ltmain.m4sh (link mode): Add to tmp_libs paths for libtool dep libs in reverse order as well. * Makefile.am, tests/testsuite.at, tests/link-order.at: New test. --- diff --git a/ChangeLog b/ChangeLog index ed595fa0a..0c24ebc64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-04-14 Alexandre Oliva , + Ralf Wildenhues + + * config/ltmain.m4sh (link mode): Add to tmp_libs paths for libtool dep + libs in reverse order as well. + * Makefile.am, tests/testsuite.at, tests/link-order.at: New test. + 2005-04-13 Gary V. Vaughan Since the bootstrap process requires that several of the rules for diff --git a/Makefile.am b/Makefile.am index 0a199b385..65c45a4b3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -305,6 +305,7 @@ TESTSUITE_AT = tests/testsuite.at \ tests/inherited_flags.at \ tests/libtoolize.at \ tests/stresstest.at \ + tests/link-order.at \ tests/template.at EXTRA_DIST += $(TESTSUITE) $(TESTSUITE_AT) tests/package.m4 diff --git a/config/ltmain.m4sh b/config/ltmain.m4sh index a188f7672..651101534 100644 --- a/config/ltmain.m4sh +++ b/config/ltmain.m4sh @@ -4054,7 +4054,7 @@ func_mode_link () esac case " $deplibs " in *" $path "*) ;; - *) deplibs="$deplibs $path" ;; + *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no diff --git a/tests/link-order.at b/tests/link-order.at new file mode 100644 index 000000000..535ab05a7 --- /dev/null +++ b/tests/link-order.at @@ -0,0 +1,88 @@ +# Hand crafted tests for GNU Libtool. -*- Autotest -*- +# Copyright 2005 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., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# link-order.test - make sure that library linking order matches + +AT_BANNER([Libtool link order test.]) +AT_SETUP([Link order test.]) +: ${LIBTOOL=${abs_top_builddir}/libtool} +: ${EGREP='grep -E'} +eval `$LIBTOOL --config | grep ECHO=` + +prefix_old=`pwd`/old +prefix_new=`pwd`/new +mkdir src $prefix_old $prefix_new $prefix_old/lib $prefix_new/lib + +AT_DATA(src/c.c, +[[int c = 1; +]]) + +$LIBTOOL --mode=compile $CC $CFLAGS -c src/c.c -o src/c.lo +$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o src/libcee.la src/c.lo -rpath $prefix_old/lib +$LIBTOOL --mode=install cp src/libcee.la $prefix_old/lib/libcee.la + +for i in old new; do + rm -rf src + mkdir src + + AT_DATA(src/a_$i.c, +[[extern int c; +extern int b_$i(); +int a_$i() { return c + b_$i(); } +]]) + + AT_DATA(src/b_$i.c, +[[extern int c; +int b_$i() { return 1 + c; } +]]) + + prefix=`eval echo \\$prefix_$i` + $LIBTOOL --mode=compile $CC $CFLAGS -c src/a_$i.c -o src/a.lo + $LIBTOOL --mode=compile $CC $CFLAGS -c src/b_$i.c -o src/b.lo + $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o src/libb.la src/b.lo \ + -L$prefix_old/lib -lcee -rpath $prefix/lib + $LIBTOOL --mode=link $CC $CFLAGS -o src/liba.la src/a.lo \ + src/libb.la -L$prefix_old/lib -lcee -rpath $prefix/lib + $LIBTOOL --mode=install cp src/libb.la $prefix/lib/libb.la + $LIBTOOL --mode=install cp src/liba.la $prefix/lib/liba.la +done + +# Do not error if we do not relink (e.g. static-only systems) +AT_CHECK([$LIBTOOL --mode=install cp src/liba.la $prefix/lib/liba.la >mylog 2>&1; + if $EGREP relinking mylog; then + $EGREP ' -L.*\/new\/lib -lb -L.*\/old\/lib -lcee' mylog + else :; + fi], [0], [ignore], [ignore], [echo "wrong link order"]) + + +for i in old new; do + AT_DATA(src/main_$i.c, +[[extern int a_$i(); +int main(void) { return a_$i() != 3; } +]]) + + prefix=`eval echo \\$prefix_$i` + $LIBTOOL --mode=compile $CC $CFLAGS -c src/main_$i.c -o src/main_$i.lo + AT_CHECK($LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o src/main_$i src/main_$i.lo -L$prefix/lib -la, + [0], [ignore], [ignore]) + + AT_CHECK(src/main_$i, [0],,, + [AT_CHECK(if test "X$host" != "X$build"; then exit 77; fi)]) +done + +AT_CLEANUP diff --git a/tests/testsuite.at b/tests/testsuite.at index 57deaa462..afebcb8e3 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -72,4 +72,6 @@ m4_include([stresstest.at]) m4_include([template.at]) # libtoolize tests m4_include([libtoolize.at]) +# link order test +m4_include([link-order.at])