From: Alexandre Oliva Date: Fri, 8 Apr 2005 13:00:50 +0000 (+0000) Subject: Fix the order of -L flags added for libtool dep libs. X-Git-Tag: release-1-5-16~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d028dd6e7d84378f6416fdbaf3669bf9a1b0e883;p=thirdparty%2Flibtool.git Fix the order of -L flags added for libtool dep libs. * ltmain.in (link mode): Add to tmp_libs paths for libtool dep libs in reverse order as well. * tests/defs: Set $build to allow to detect cross-compiles. * tests/Makefile.am, tests/linkorder.test: New test. --- diff --git a/ChangeLog b/ChangeLog index 144ee7e00..ef9914a07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-04-08 Alexandre Oliva , + Ralf Wildenhues + + Fix the order of -L flags added for libtool dep libs. + + * ltmain.in (link mode): Add to tmp_libs paths for libtool dep + libs in reverse order as well. + * tests/defs: Set $build to allow to detect cross-compiles. + * tests/Makefile.am, tests/linkorder.test: New test. + 2005-04-01 Mike Stump * libtool.m4 (AC_LIBTOOL_SYS_MAX_CMD_LEN) [ netbsd, freebsd, openbsd, diff --git a/ltmain.in b/ltmain.in index 46e6393dc..d5687046e 100644 --- a/ltmain.in +++ b/ltmain.in @@ -2867,12 +2867,12 @@ EOF *) continue ;; esac case " $deplibs " in - *" $depdepl "*) ;; - *) deplibs="$depdepl $deplibs" ;; + *" $path "*) ;; + *) deplibs="$path $deplibs" ;; esac case " $deplibs " in - *" $path "*) ;; - *) deplibs="$deplibs $path" ;; + *" $depdepl "*) ;; + *) deplibs="$depdepl $deplibs" ;; esac done fi # link_all_deplibs != no diff --git a/tests/Makefile.am b/tests/Makefile.am index ccee574b3..9fa3f15ee 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -46,7 +46,7 @@ COMMON_TESTS = \ pdemo-make.test pdemo-exec.test pdemo-inst.test \ mdemo-conf.test mdemo-make.test mdemo2-conf.test \ mdemo2-make.test mdemo2-exec.test \ - func_extract_archives.test + func_extract_archives.test linkorder.test if HAVE_CXX diff --git a/tests/defs b/tests/defs index e7a12be5c..ad76311ae 100644 --- a/tests/defs +++ b/tests/defs @@ -47,6 +47,9 @@ eval `$libtool --config | grep '^CC='` # Extract host from the libtool configuration eval `$libtool --config | grep '^host='` +# Extract build from the libtool configuration +eval `$libtool --config | grep '^build='` + # Disable usage of config.site for autoconf, unless DJGPP is present. # The DJGPP port of autoconf requires config.site, to work correctly. if test -z "$DJGPP"; then diff --git a/tests/linkorder.test b/tests/linkorder.test new file mode 100644 index 000000000..ec5e274ae --- /dev/null +++ b/tests/linkorder.test @@ -0,0 +1,92 @@ +#! /bin/sh +# linkorder.test - make sure that library linking order matches + +# Test script header. +need_prefix=no +if test -z "$srcdir"; then + srcdir=`echo "$0" | sed 's%/[^/]*$%%'` + test "$srcdir" = "$0" && srcdir=. + test "${VERBOSE+set}" != "set" && VERBOSE=yes +fi +. $srcdir/defs || exit 1 + +retcode=0 + +rm -rf linkorder.dir +mkdir linkorder.dir +top_dir=`pwd`/linkorder.dir +prefix_old=$top_dir/old +prefix_new=$top_dir/new +srcdir=linkorder.dir/src +mkdir $srcdir $prefix_old $prefix_new $prefix_old/lib $prefix_new/lib + +cat >$srcdir/c.c <$srcdir/a_$i.c <$srcdir/b_$i.c <$srcdir/stdout 2>$srcdir/stderr || retcode=1 + cat $srcdir/stdout + cat $srcdir/stderr >&2 +done + +# Do not error if we do not relink (e.g. static-only systems) +if $EGREP relinking $srcdir/stderr; then + if $EGREP ' -L.*\/new\/lib -lb -L.*\/old\/lib -lcee' $srcdir/stdout; then :; else + echo "$0: wrong link order" 1>&2 + retcode=1 + fi +fi + +for i in old new; do + cat >$srcdir/main_$i.c <&2 + if test "X$host" != "X$build"; then + echo "This may be ok since you seem to be cross-compiling." 1>&2 + retcode=77 + else + retcode=1 + fi + fi +done + +rm -rf $top_dir +exit $retcode