diff --git a/ChangeLog b/ChangeLog index d6fc973d..4257deee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,48 @@ +2002-11-18 Charles Wilson + + * libtool.m4 (_LT_AC_LOCK): remove support for ancient + versions of mingw and cygwin. + (AC_LIBTOOL_POSTDEP_PREDEP): new function. + moved the "find hidden library dependencies" code here + from AC_LIBTOOL_LANG_CXX_CONFIG. Attempted to make it + multi-tag compatible, but currently only CXX calls it. + (AC_LIBTOOL_LANG_CXX_CONFIG): set + enable_shared_with_satic_runtimes to 'no' by default + Set it to 'yes' for cygwin, mingw, pw32. Replace + "find hidden library dependencies" code with a call + to the new function AC_LIBTOOL_POSTDEP_PREDEP. + Consolidate cygwin and mingw/pw32 stanzas. + (AC_LIBTOOL_LANG_F77_CONFIG): set + enable_shared_with_static_runtimes to 'no' by default + (AC_LIBTOOL_CONFIG): add + enable_shared_with_static_runtimes to the list of variables + to write into ltmain.sh; include it in the libtool script + template as allow_libtool_libs_with_static_runtimes. + (AC_LIBTOOL_PROG_LD_SHLIBS): set + enable_shared_with_static_runtimes to 'no' by default + Set it to 'yes' for cygwin, mingw, pw32. + (AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE): only put cr in regexp + if the build_os is mingw, not host_os + + * ltmain.in (case deplibs_check_method): for all appropriate + cases, if allow_libtool_libs_with_static_runtimes, then remove + predeps and postdeps from the list of dependencies that must + be checked for "dynamicness". For the "none" case, the + presence of compiler-generated postdeps and predeps should + not trigger "inter-library dependencies not supported" error. + (initial setup after arg processing): on cygwin/mingw, allow + compiler-generated dependent libs to be duplicated without + elimination. + (initial search loop for deplibs): if the deplib in question + is a libtool lib, then if + allow_libtool_libs_with_static_runtimes then parse the .la file. + If the .la file only has an "old_library", add the deplib + directly to the deplibs list (-lstdc++) and DON'T use the .la + file; this allows the (case deplibs_check_method) change above + to take effect. + * ltmain.in (for pass in $passes loop): remove predeps, + postdeps, and compiler_lib_search_path from dependency_libs. + 2002-11-08 Robert Boehne * doc/libtool.texi: Add --mode=* to every example using libtool. diff --git a/libtool.m4 b/libtool.m4 index fb7e11c8..a5e7e85c 100644 --- a/libtool.m4 +++ b/libtool.m4 @@ -495,32 +495,6 @@ AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) - - # recent cygwin and mingw systems supply a stub DllMain which the user - # can override, but on older systems we have to supply one - AC_CACHE_CHECK([if libtool should supply DllMain function], lt_cv_need_dllmain, - [AC_TRY_LINK([], - [extern int __attribute__((__stdcall__)) DllMain(void*, int, void*); - DllMain (0, 0, 0);], - [lt_cv_need_dllmain=no],[lt_cv_need_dllmain=yes])]) - - case $host/$CC in - *-*-cygwin*/gcc*-mno-cygwin*|*-*-mingw*) - # old mingw systems require "-dll" to link a DLL, while more recent ones - # require "-mdll" (and still newer ones would rather have "-shared") - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -shared" - AC_CACHE_CHECK([how to link DLLs], lt_cv_cc_dll_switch, - [AC_TRY_LINK([],[],[lt_cv_cc_dll_switch=-shared], - [ - CFLAGS="$SAVE_CFLAGS -mdll" - AC_TRY_LINK([], [], [lt_cv_cc_dll_switch=-mdll],[lt_cv_cc_dll_switch=-dll])])]) - CFLAGS="$SAVE_CFLAGS" ;; - *-*-cygwin* | *-*-pw32*) - # cygwin systems need to pass --dll to the linker, and not link - # crt.o which will require a WinMain@16 definition. - lt_cv_cc_dll_switch="-Wl,--dll -nostartfiles" ;; - esac ;; ]) esac @@ -2428,6 +2402,7 @@ _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown _LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_AC_TAGVAR(no_undefined_flag, $1)= _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= +_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Dependencies to place before and after the object being linked: _LT_AC_TAGVAR(predep_objects, $1)= @@ -2646,12 +2621,13 @@ case $host_os in esac ;; - cygwin* ) + cygwin* | mingw* | pw32*) # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | egrep 'auto-import' > /dev/null; then _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' @@ -2661,19 +2637,6 @@ case $host_os in fi ;; - mingw* | pw32* ) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_AC_TAGVAR(always_export_symbols, $1)=no - - if $LD --help 2>&1 | egrep 'auto-import' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC '$lt_cv_cc_dll_switch' $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--out-implib,${lib}' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC '$lt_cv_cc_dll_switch' $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}-retain-symbols-file $wl$export_symbols ${wl}--out-implib,${lib}' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - dgux*) case $cc_basename in ec++) @@ -3145,9 +3108,46 @@ esac AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no -# Figure out "hidden" C++ library dependencies from verbose -# compiler output whening linking a shared library. -cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <&1 | egrep 'auto-import' > /dev/null; then _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' @@ -4887,6 +4888,7 @@ EOF # FIXME: Should let the user specify the lib program. _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs' fix_srcfile_path='`cygpath -w "$srcfile"`' + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; darwin* | rhapsody*) diff --git a/ltmain.in b/ltmain.in index c1bcb61e..cd2fbbf1 100644 --- a/ltmain.in +++ b/ltmain.in @@ -1668,28 +1668,15 @@ EOF esac case $host in - *cygwin*) - # This is a hack, but we run into problems on cygwin. - # libgcc.a depends on libcygwin, but gcc puts -lgcc onto - # the link line twice: once before the "normal" libs - # (-lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32) and - # once AFTER those. However, the "eliminate dup deps" - # procedure keeps only the LAST duplicate -- thus - # messing up the order, since after dup elimination - # -lgcc comes AFTER -lcygwin. In normal C operation, - # you don't notice the problem, because -lgcc isn't - # really used. However, now that C++ libraries are - # libtool-able, you DO see the problem. So, it must - # be fixed. We could always force "--preserve-dup-deps" - # but that could lead to other problems. So, on cygwin, - # always preserve dups of -lgcc...but only -lgcc. That - # way, the dependency order won't get corrupted. - specialdeplibs="-lgcc" + *cygwin* | *mingw* | *pw32*) + # don't eliminate duplcations in $postdeps and $predeps + duplicate_compiler_generated_deps=yes ;; *) - specialdeplibs= + duplicate_compiler_generated_deps=$duplicate_deps ;; esac + specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries @@ -1710,7 +1697,7 @@ EOF # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= - if test "X$duplicate_deps" = "Xyes" ; then + if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; @@ -1801,6 +1788,41 @@ EOF test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue + else # deplib is a libtool library + # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, + # We need to do some special things here, and not later. + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $deplib "*) + if (${SED} -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + library_names= + old_library= + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + for l in $old_library $library_names; do + ll="$l" + done + if test "X$ll" = "X$old_library" ; then # only static version available + found=no + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + lib=$ladir/$old_library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi fi ;; # -l -L*) @@ -2549,6 +2571,19 @@ EOF eval $var=\"$tmp_libs\" done # for var fi + # Last step: remove runtime libs from dependency_libs (they stay in deplibs) + tmp_libs= + for i in $dependency_libs ; do + case " $predeps $postdeps $compiler_lib_search_path " in + *" $i "*) + i="" + ;; + esac + if test -n "$i" ; then + tmp_libs="$tmp_libs $i" + fi + done + dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" @@ -2972,39 +3007,16 @@ EOF for i in $deplibs; do name="`expr $i : '-l\(.*\)'`" # If $name is empty we are operating on a -L argument. - if test "$name" != "" && test "$name" -ne "0"; then - libname=`eval \\$echo \"$libname_spec\"` - deplib_matches=`eval \\$echo \"$library_names_spec\"` - set dummy $deplib_matches - deplib_match=$2 - if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then - newdeplibs="$newdeplibs $i" - else - droppeddeps=yes - echo - echo "*** Warning: dynamic linker does not accept needed library $i." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which I believe you do not have" - echo "*** because a test_compile did reveal that the linker did not use it for" - echo "*** its dynamic dependency list that programs get resolved with at runtime." - fi - else - newdeplibs="$newdeplibs $i" - fi - done - else - # Error occurred in the first compile. Let's try to salvage - # the situation: Compile a separate program for each library. - for i in $deplibs; do - name="`expr $i : '-l\(.*\)'`" - # If $name is empty we are operating on a -L argument. - if test "$name" != "" && test "$name" != "0"; then - $rm conftest - $LTCC -o conftest conftest.c $i - # Did it work? - if test "$?" -eq 0 ; then - ldd_output=`ldd conftest` + if test "$name" != "" && test "$name" -ne "0"; then + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $i "*) + newdeplibs="$newdeplibs $i" + i="" + ;; + esac + fi + if test -n "$i" ; then libname=`eval \\$echo \"$libname_spec\"` deplib_matches=`eval \\$echo \"$library_names_spec\"` set dummy $deplib_matches @@ -3017,9 +3029,52 @@ EOF echo "*** Warning: dynamic linker does not accept needed library $i." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because a test_compile did reveal that the linker did not use this one" - echo "*** as a dynamic dependency that programs can get resolved with at runtime." + echo "*** shared version of the library, which I believe you do not have" + echo "*** because a test_compile did reveal that the linker did not use it for" + echo "*** its dynamic dependency list that programs get resolved with at runtime." + fi + fi + else + newdeplibs="$newdeplibs $i" + fi + done + else + # Error occurred in the first compile. Let's try to salvage + # the situation: Compile a separate program for each library. + for i in $deplibs; do + name="`expr $i : '-l\(.*\)'`" + # If $name is empty we are operating on a -L argument. + if test "$name" != "" && test "$name" != "0"; then + $rm conftest + $LTCC -o conftest conftest.c $i + # Did it work? + if test "$?" -eq 0 ; then + ldd_output=`ldd conftest` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $i "*) + newdeplibs="$newdeplibs $i" + i="" + ;; + esac + fi + if test -n "$i" ; then + libname=`eval \\$echo \"$libname_spec\"` + deplib_matches=`eval \\$echo \"$library_names_spec\"` + set dummy $deplib_matches + deplib_match=$2 + if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then + newdeplibs="$newdeplibs $i" + else + droppeddeps=yes + echo + echo "*** Warning: dynamic linker does not accept needed library $i." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because a test_compile did reveal that the linker did not use this one" + echo "*** as a dynamic dependency that programs can get resolved with at runtime." + fi fi else droppeddeps=yes @@ -3041,11 +3096,20 @@ EOF for a_deplib in $deplibs; do name="`expr $a_deplib : '-l\(.*\)'`" # If $name is empty we are operating on a -L argument. - if test "$name" != "" && test "$name" != "0"; then - libname=`eval \\$echo \"$libname_spec\"` - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` - for potent_lib in $potential_libs; do + if test "$name" != "" && test "$name" != "0"; then + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $a_deplib "*) + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + ;; + esac + fi + if test -n "$a_deplib" ; then + libname=`eval \\$echo \"$libname_spec\"` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null \ | grep " -> " >/dev/null; then @@ -3071,8 +3135,9 @@ EOF a_deplib="" break 2 fi - done - done + done + done + fi if test -n "$a_deplib" ; then droppeddeps=yes echo @@ -3101,20 +3166,30 @@ EOF name="`expr $a_deplib : '-l\(.*\)'`" # If $name is empty we are operating on a -L argument. if test -n "$name" && test "$name" != "0"; then - libname=`eval \\$echo \"$libname_spec\"` - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` - for potent_lib in $potential_libs; do - potlib="$potent_lib" # see symlink-check above in file_magic test - if eval echo \"$potent_lib\" 2>/dev/null \ - | ${SED} 10q \ - | egrep "$match_pattern_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $a_deplib "*) + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + ;; + esac + fi + if test -n "$a_deplib" ; then + libname=`eval \\$echo \"$libname_spec\"` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + potlib="$potent_lib" # see symlink-check above in file_magic test + if eval echo \"$potent_lib\" 2>/dev/null \ + | ${SED} 10q \ + | egrep "$match_pattern_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done done - done + fi if test -n "$a_deplib" ; then droppeddeps=yes echo @@ -3138,9 +3213,16 @@ EOF ;; none | unknown | *) newdeplibs="" - if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ - -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' | - grep . >/dev/null; then + tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ + -e 's/ -[LR][^ ]*//g'` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + for i in $predeps $postdeps ; do + # can't use Xsed below, because $i might contain '/' + tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` + done + fi + if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ + | grep . >/dev/null; then echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform."