Ralf Wildenhues wrote:
> See above for the two cases.  With them fixed, I think the patch looks
> to be in fairly good shape, except that shell quoting bugs are really
> hard to detect when reading the doubly-quoted code.  So please fix
> above, resend, and apply if you don't hear back after 72 hours.

Squashed together and reposted from:

http://lists.gnu.org/archive/html/libtool-patches/2009-12/msg00015.html
and followon
http://lists.gnu.org/archive/html/libtool-patches/2010-01/msg00048.html
with more additions arising from Ralf's further comments this week:

    * libltdl/config/ltmain.m4sh (func_emit_wrapper_impl): Renamed to...
    (func_emit_wrapper): This. Old version removed.
    (func_parse_lt_options, func_lt_dump_args, func_exec_program_core):
    Use $LINENO, not @@LINENO@@.
    (func_opts_contain_lt): Removed.
    (func_exec_program): Rewrite to avoid forks and requoting.


This (combination) was the second of the two patches whose /first/
72hour rule invocation was here:
http://lists.gnu.org/archive/html/libtool-patches/2010-02/msg00003.html

Starting a new clock. No regressions attributable to these changes, on
cygwin or mingw.  No test failures at all on linux.

Consolidated changelog:

2010-02-18  Charles Wilson  <...>

        Add --lt-* options to shell wrapper
        * libltdl/config/ltmain.m4sh (func_emit_wrapper): Call
        func_parse_lt_options early. Use func_exec_program.
        (func_emit_wrapper:func_parse_lt_options): New function.
        (func_emit_wrapper:func_lt_dump_args): New function.
        (func_emit_wrapper:func_exec_program_core): New function.
        (func_emit_wrapper:func_exec_program): New function.

Test results:

It does not appear that there were any regressions caused by THESE
changes.  There are a few items that need investigation, but...later.


cygwin
======================================================================
All old tests passed.

New tests:
48: deplib in subdir                 FAILED (deplib-in-subdir.at:140)
69: dlloader API                     FAILED (dlloader-api.at:416)
92: C++ exception handling           FAILED (exceptions.at:254)
102: Run tests with low max_cmd_len  FAILED (cmdline_wrap.at:43)

048:
----------------------------------
libtool: install: cp .libs/m3.exe
.../tests/testsuite.dir/048/inst/bin/m3.exe
../../libtool/tests/deplib-in-subdir.at:140: $LIBTOOL --mode=clean rm -f
sub1/liba1.la sub1/liba2.la sub1/liba3.la       sub2/subsub/libb1.la
sub2/subsub/libb2.la sub2/subsub/libb3.la          sub3/subsub/m1$EXEEXT
sub3/subsub/m2$EXEEXT sub3/subsub/m3$EXEEXT
stderr:
.../libtool: line 1693: sub3/subsub/sub3/subsub/.libs/m1_ltshwrapper: No
such file or directory

in func_mode_uninstall, func_ltwrapper_scriptname_result is wrong
because objdir has been reset to be fullpathto, rather than just .libs,
before call to func_ltwrapper_scriptname.  So, when trying to source the
script, it dies.

069:
----------------------------------
 who knows, but it's somewhere in libltdl not libtool

--- expout      2010-02-18 03:12:56.231600000 -0500
+++ .../tests/testsuite.dir/at-groups/69/stdout 2010-02-18
03:13:09.261600000 -0500
@@ -9,11 +9,7 @@
 first_open denies a request
 result: module_symbol
 first_open denies a request
-last_open ("last"): last_ctx
-last_sym (last): last_ctx
-result: last_symbol
-first_open denies a request
 last_open denies a request
+lt_dlopen failed: file not found
 first_exit: first_ctx
-last_close (last): last_ctx
 last_exit: last_ctx


092:
----------------------------------
segfault in executable.  Pretty sure this isn't a problem in ltmain.m4sh

test "X$host" != "X$build" && test -x "$lt_exe" && exit 77;     exit
$lt_status; fi
stderr:
exceptions_in_prog
caught: exception in program
exceptions_in_lib
caught inside lib: exception in library
caught: exception from library
exceptions_in_module
caught inside module: exception in module
caught: exception from module
.../tests/testsuite.dir/at-groups/92/test-source: line 377:
5920 Segmentation fault      (core dumped)
$LIBTOOL --mode=execute -dlopen m/module.la "$lt_exe"
stdout:
../../libtool/tests/exceptions.at:254: exit code was 139, expected 0



102:
----------------------------------
low max_cmd_len: repeat of above errs


mingw:
======================================================================
FAIL: tests/tagdemo-make.test
FAIL: tests/tagdemo-make.test
FAIL: tests/tagdemo-make.test
FAIL: tests/tagdemo-make.test
27: C++ convenience archives         FAILED (convenience.at:99)
48: deplib in subdir                 FAILED (deplib-in-subdir.at:140)
62: C++ subdir-objects               FAILED (am-subdir.at:148)
89: (C++ template tests):simple template test   FAILED (template.at:89)
90: (C++ template tests):template test with subdirs FAILED
                                                    (template.at:241)
91: C++ static constructors          FAILED (ctor.at:62)
92: C++ exception handling           FAILED (exceptions.at:242)
102: Run tests with low max_cmd_len  FAILED (cmdline_wrap.at:43)

Basically, it appears that C++ support is borked on MinGW, because all
of the failures except #48 are c++ related.  It has something to do with
the new 4.4.0 compiler, which ships the import library for the C++
runtime as libstdc++_s.a, but the .la file shipped with gcc claims that
library_names='libstdc++.dll.a'.

This is really a packaging bug in MinGW's g++, but the fix is not
simple. Unlike cygwin, in which the default linking behavior and default
runtime usage agree (ld prefers .dll.a, and gcc prefers to link to
dynamic runtimes) -- mingw-gcc and mingw-ld disagree on the proper
default behavior with regards to the runtime libs.  mingw-ld prefers
.dll.a, but mingw-gcc defaults to -static-libstdc++.  To make this work
(in the absence of libtool), the import library is given a non-standard
name (libstdc++_s.a).

Cygwin shows (showed?) similar issues with you tried to mix
-static-libstdc++ with libtool.

Anyway, fixing that is beyond the scope of this patch.  The only
remaining test failure is the #48, which fails for the same reasons as
described above.

Linux:
======================================================================
All test passed, in both the old and new testsuites.

diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 4549023..85cc110 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -2407,7 +2407,110 @@ func_fallback_echo ()
 _LTECHO_EOF'
 }
     ECHO=\"$qECHO\"
-  fi\
+  fi
+
+# Very basic option parsing. These options are (a) specific to
+# the libtool wrapper, (b) are identical between the wrapper
+# /script/ and the wrapper /executable/ which is used only on
+# windows platforms, and (c) all begin with the string "--lt-"
+# (application programs are unlikely to have options which match
+# this pattern).
+#
+# There are only two supported options: --lt-debug and
+# --lt-dump-script. There is, deliberately, no --lt-help.
+#
+# The first argument to this parsing function should be the
+# script's $0 value, followed by "$@".
+lt_option_debug=
+func_parse_lt_options ()
+{
+  lt_script_arg0=\$0
+  shift
+  for lt_opt
+  do
+    case \"\$lt_opt\" in
+    --lt-debug) lt_option_debug=1 ;;
+    --lt-dump-script)
+        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
+        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
+        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
+        cat \"\$lt_dump_D/\$lt_dump_F\"
+        exit 0
+      ;;
+    --lt-*)
+        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
+        exit 1
+      ;;
+    esac
+  done
+
+  # Print the debug banner immediately:
+  if test -n \"\$lt_option_debug\"; then
+    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
+  fi
+}
+
+# Used when --lt-debug. Prints its arguments to stdout
+# (redirection is the responsibility of the caller)
+func_lt_dump_args ()
+{
+  lt_dump_args_N=1;
+  for lt_arg
+  do
+    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
+    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
+  done
+}
+
+# Core function for launching the target application
+func_exec_program_core ()
+{
+"
+  case $host in
+  # Backslashes separate directories on plain windows
+  *-*-mingw | *-*-os2* | *-cegcc*)
+    $ECHO "\
+      if test -n \"\$lt_option_debug\"; then
+        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
+        func_lt_dump_args \${1+\"\...@\"} 1>&2
+      fi
+      exec \"\$progdir\\\\\$program\" \${1+\"\...@\"}
+"
+    ;;
+
+  *)
+    $ECHO "\
+      if test -n \"\$lt_option_debug\"; then
+        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
+        func_lt_dump_args \${1+\"\...@\"} 1>&2
+      fi
+      exec \"\$progdir/\$program\" \${1+\"\...@\"}
+"
+    ;;
+  esac
+  $ECHO "\
+      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
+      exit 1
+}
+
+# A function to encapsulate launching the target application
+# Strips options in the --lt-* namespace from \$@ and
+# launches target application with the remaining arguments.
+func_exec_program ()
+{
+  for lt_wr_arg
+  do
+    case \$lt_wr_arg in
+    --lt-*) ;;
+    *) set x \"\...@\" \"\$lt_wr_arg\"; shift;;
+    esac
+    shift
+  done
+  func_exec_program_core \${1+\"\...@\"}
+}
+
+  # Parse options
+  func_parse_lt_options \"\$0\" \${1+\"\...@\"}
 
   # Find the directory that this script lives in.
   thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
@@ -2520,24 +2623,7 @@ _LTECHO_EOF'
 	$ECHO "\
     if test \"\$libtool_execute_magic\" != \"$magic\"; then
       # Run the actual program with our arguments.
-"
-	case $host in
-	# Backslashes separate directories on plain windows
-	*-*-mingw | *-*-os2* | *-cegcc*)
-	  $ECHO "\
-      exec \"\$progdir\\\\\$program\" \${1+\"\...@\"}
-"
-	  ;;
-
-	*)
-	  $ECHO "\
-      exec \"\$progdir/\$program\" \${1+\"\...@\"}
-"
-	  ;;
-	esac
-	$ECHO "\
-      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
-      exit 1
+      func_exec_program \${1+\"\...@\"}
     fi
   else
     # The program doesn't exist.

Reply via email to