From 06470c3a43171aeff807738d6c345c44420924a0 Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Mon, 23 Apr 2007 17:10:17 +0000 Subject: [PATCH] * libltdl/config/ltmain.m4sh (func_mode_link): Fix accumulation of `inherited_linker_flags' entries from multiple deplibs, by adding $new_inherited_linker_flags only once, only in link pass. * tests/inherited_flags: Amend test to expose this. * NEWS: Adjust: kill one regression, but add note about the feature new in 1.9b. Report by Jeff Squyres and others. --- ChangeLog | 10 ++++++++++ NEWS | 10 ++++------ libltdl/config/ltmain.m4sh | 14 ++++++++------ tests/inherited_flags.at | 25 +++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2185ab7c..725c92fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-04-23 Ralf Wildenhues + + * libltdl/config/ltmain.m4sh (func_mode_link): Fix accumulation + of `inherited_linker_flags' entries from multiple deplibs, by + adding $new_inherited_linker_flags only once, only in link pass. + * tests/inherited_flags: Amend test to expose this. + * NEWS: Adjust: kill one regression, but add note about the + feature new in 1.9b. + Report by Jeff Squyres and others. + 2007-04-23 Charles Wilson * libltdl/config/ltmain.m4sh (func_mode_link): move wrapper diff --git a/NEWS b/NEWS index ff55563a..6c0d5d59 100644 --- a/NEWS +++ b/NEWS @@ -12,12 +12,6 @@ New in 2.1a: 2007-??-??; CVS version 2.1a, Libtool team: any more, some setups may fail. A mechanism to allow the user to choose the mode has not been implemented yet. - - In 1.9b, a new variable inherited_linker_flags has been added to the - libtool library files. This variable takes flags that should be - used by dependent libraries and programs, but that do not fit into - `dependency_libs' for both clarity and backward-compatibility. - Currently, these flags are not uniquified and thus accumulate. - * Important incompatible changes and obsoleted features: - Removed deprecated APIs from libltdl: lt_dlcaller_register, @@ -66,6 +60,10 @@ New in 2.1a: 2007-??-??; CVS version 2.1a, Libtool team: Both testsuites have been made more useful for testing cross-compilers. The new testsuite exposes many more issues, but may also be a little rocky on exotic systems. + - In 1.9b, a new variable inherited_linker_flags has been added to the + libtool library files. This variable takes flags that should be + used by dependent libraries and programs, but that do not fit into + `dependency_libs' for both clarity and backward-compatibility. * Changes in supported systems or compilers: diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index 017644a2..df4d5c43 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -4036,12 +4036,6 @@ func_mode_link () done fi dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$new_inherited_linker_flags $compile_deplibs" - finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" - else - compiler_flags="$compiler_flags $inherited_linker_flags" - fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then @@ -4669,6 +4663,14 @@ func_mode_link () fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs + if test "$pass" = link; then + if test "$linkmode" = "prog"; then + compile_deplibs="$new_inherited_linker_flags $compile_deplibs" + finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" + else + compiler_flags="$compiler_flags $new_inherited_linker_flags" + fi + fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries diff --git a/tests/inherited_flags.at b/tests/inherited_flags.at index b749a406..cd693fa6 100644 --- a/tests/inherited_flags.at +++ b/tests/inherited_flags.at @@ -41,6 +41,11 @@ AT_DATA([baz.c], int baz() { return 1;} ]) +AT_DATA([both.c], +[ +int both() { return 1;} +]) + AT_DATA([main.c], [ int main() { return 0;} @@ -49,9 +54,11 @@ int main() { return 0;} $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o foo.lo foo.c $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o bar.lo bar.c $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o baz.lo baz.c +$LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o both.lo both.c $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o main.lo main.c $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libfoo.la foo.lo -rpath /usr/local/lib -no-undefined $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libbar.la bar.lo -rpath /usr/local/lib -no-undefined +$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libboth.la both.lo -rpath /usr/local/lib -no-undefined mv libfoo.la libfoo.la.bak @@ -62,6 +69,10 @@ mv libbar.la libbar.la.bak sed -e 's/^inherited_linker_flags.*/inherited_linker_flags=-llt_unlikely_existing_lib/g' < libbar.la.bak > libbar.la rm libbar.la.bak +mv libboth.la libboth.la.bak +sed -e "s/^inherited_linker_flags.*/inherited_linker_flags='-llt_inlikely_existing_lib -llt_unlikely_existing_lib'/g" < libboth.la.bak > libboth.la +rm libboth.la.bak + AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libbaz.la baz.lo -no-undefined -rpath /usr/local/lib ./libfoo.la ./libbar.la], [ignore],[stdout],[ignore]) # We used to grep for @@ -76,4 +87,18 @@ AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o main main.lo -no AT_CHECK([grep 'lt_[[ui]]nlikely_existing_lib.*lt_[[ui]]nlikely_existing_lib' stdout], [0],[ignore],[ignore]) +# now check for duplicates +AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libbaz.la baz.lo -no-undefined -rpath /usr/local/lib ./libfoo.la ./libbar.la ./libboth.la], + [ignore],[stdout],[ignore]) +AT_CHECK([grep 'lt_inlikely_existing_lib.*lt_inlikely_existing_lib' stdout], + [1],[ignore],[ignore]) +AT_CHECK([grep 'lt_unlikely_existing_lib.*lt_unlikely_existing_lib' stdout], + [1],[ignore],[ignore]) +AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o main main.lo -no-undefined -rpath /usr/local/lib ./libfoo.la ./libbar.la ./libboth.la], + [ignore],[stdout],[ignore]) +AT_CHECK([grep 'lt_inlikely_existing_lib.*lt_inlikely_existing_lib' stdout], + [1],[ignore],[ignore]) +AT_CHECK([grep 'lt_unlikely_existing_lib.*lt_unlikely_existing_lib' stdout], + [1],[ignore],[ignore]) + AT_CLEANUP