libtool-patches
[Top][All Lists]
Advanced

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

Re: libtool bug


From: Charles Wilson
Subject: Re: libtool bug
Date: Sat, 09 Oct 2004 22:55:10 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040616 MultiZilla/1.6.4.0b

Charles Wilson wrote:

Whether to set the $PATH and produce wrapper scripts is clearly a distinct issue from "should stuff be relinked on install" -- although on platforms which encode -rpaths into sharedlibs and executables one issue will affect the other.

Not true on cygwin.

These two questions (need wrappers to set PATH/LD_LIBRARY_PATH/etc, vs. need to relink on install) should be disentangled. On cygwin, we need wrappers, but not relink. On most OTHER platforms, you probably need relink (but no wrappers?) IF using rpath; you need wrappers (and relink?) if you are NOT using rpath. Confusing, no?

The culprit is this little stanza in ltmain.m4sh:

***********************************
if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
        # Replace the output file specification.
compile_command=`$ECHO "X$compile_command" | $Xsed -e 'address@hidden@%'"$output"'%g'`
        link_command="$compile_command$compile_rpath"

# We have no uninstalled library dependencies, so finalize right now.
        $show "$link_command"
        $run eval "$link_command"
        status=$?

        # Delete the generated files.
        if test -f "$output_objdir/${outputname}S.${objext}"; then
          $show "$RM $output_objdir/${outputname}S.${objext}"
          $run $RM "$output_objdir/${outputname}S.${objext}"
        fi

        exit $status
      fi
***********************************

We finalize and bail out before creating the wrappers (and put the result into $output) simply because need_relink is no. But on cygwin, at least, we still need the wrappers! By manually removing this stanza from a prebuilt libtool (but leaving need_relink=no) the -make and -exec checks will pass.

e.g. something like the following will "fix it": wrap the whole stanza inside a case statement:

  case $host in
  *cygwin* | *mingw* )
    ;; # don't bail out early on cygwin or mingw
  *)
    <put offending stanza here>
    ;;
  esac

but that just seems wrong somehow. It's like we need another variable, whose meaning is something like "yeah, we don't need to relink, but we still need wrappers" -- but we may already have that variable, and just need to add it to the 'if' statement in the offending stanza.

Worse, the above change breaks the -inst.test, because with the change above we are now creating a wrapper script and wrapper executable for hell_static, which we certainly don't need to do. And the wrapper script thus created -- for a STATIC executable -- has an empty $notinst_deplibs, which is as it should be, because it's static and doesn't care where the deplib came from; the exe "has it" built in.

But libtool checks to make sure that after sourcing the wrapper script, $notinst_deplib is non-empty, because the only reason to HAVE a wrapper script is if $notinst_deplib would have something in it.

Sheesh.

The attached patch (against libtool cvs branch 2.0) ain't pretty, but it works on cygwin and shouldn't break other platforms.

--
Chuck

2004-10-09  Charles Wilson  <spam.protected>

        * config/ltmain.m4sh (func_mode_link): don't relink
        on cygwin/mingw; no need.  But do ensure that wrappers
        are created unless doing a purely static build.
Index: ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/config/ltmain.m4sh,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 ltmain.m4sh
--- ltmain.m4sh 8 Oct 2004 16:17:40 -0000       1.1.2.4
+++ ltmain.m4sh 10 Oct 2004 02:10:40 -0000
@@ -3539,10 +3539,19 @@
        link_static=no # Whether the deplib will be linked statically
        if test -n "$library_names" &&
           { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
-         if test "$installed" = no; then
-           notinst_deplibs="$notinst_deplibs $lib"
-           need_relink=yes
-         fi
+         case $host in
+         *cygwin* | *mingw*)
+             # No point in relinking DLLs because paths are not encoded
+             notinst_deplibs="$notinst_deplibs $lib"
+             need_relink=no
+           ;;
+         *)
+           if test "$installed" = no; then
+             notinst_deplibs="$notinst_deplibs $lib"
+             need_relink=yes
+           fi
+           ;;
+         esac
          # This is a shared library
 
          # Warn about portability, can't link against -module's on some
@@ -5427,7 +5436,21 @@
 
       func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
 
-      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+
+      wrappers_required=yes
+      case $host in
+      *cygwin* | *mingw* )
+        if test "$build_libtool_libs" != yes; then
+          wrappers_required=no
+        fi
+        ;;
+      *)
+        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+          wrappers_required=no
+        fi
+        ;;
+      esac
+      if test "$wrappers_required" = no; then
        # Replace the output file specification.
        compile_command=`$ECHO "X$compile_command" | $Xsed -e 
'address@hidden@%'"$output"'%g'`
        link_command="$compile_command$compile_rpath"

reply via email to

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