bug-libtool
[Top][All Lists]
Advanced

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

Re: libtool 2.2.2 cross-compile to mingw problems


From: Charles Wilson
Subject: Re: libtool 2.2.2 cross-compile to mingw problems
Date: Sat, 19 Apr 2008 13:06:19 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.12) Gecko/20080213 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

Simon Josefsson said:
address@hidden:~/gnutls4win/build/gnutls-2.3.7/src$ ./certtool.exe
Wine failed with return code 127
address@hidden:~/gnutls4win/build/gnutls-2.3.7/src$
I need to run them in-place, because they are invoked from 'make check'.

Re-compiling the wrapper with DEBUGWRAPPER yields:

(main) libtool shell wrapper name: certtool_ltshwrapperTMP
(make_executable) : Z:/home/jas/gnutls4win/build/gnutls-2.3.7/src/./.libs/certtool_ltshwrapperTMP
(main) newargz[0]   : .exe

well, here's your problem.

As far as I can understand from the .libs/lt-certtool.c code, it writes
a bash script into .libs/certtool_ltshwrapperTMP and then tries to
execute that.

How is this intended to work?  You can't execute bash scripts under
Windows nor Wine, as far as I know.

Yes and no. You need some win32 shell installed in your Wine environment. (For native win32 builds, this is no problem: if you are running libtool, you have a shell). Long-term, it would be great to use the wrapper executable ONLY, without a script, to execute the real target exe -- at least for win32 hosts. (we'd still need the script for one purpose, even then; libtool "reads" the script by sourcing it back it.) However, we don't that yet -- to do so, we'd need to create an env structure, copy the existing env, then manipulate the LT_LIBRARY_PATH and PATH (and, and, etc) entries...that's probably a libtool-2.4 idea.

Anyway, the following bits in ltmain kick in, which try to determine the name of the shell that the (win32 wrapper executable) should invoke, as if:
   system("some-win32-sh.exe the-wrapper-script <other args?>")


case "$host" in
  *mingw* )
    # awkward: cmd appends spaces to result
    lt_sed_strip_trailing_spaces="s/[ ]*\$//"
lt_newargv0=`( cmd //c echo $SHELL | $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo $SHELL`
    case $lt_newargv0 in
      *.exe | *.EXE) ;;
      *) lt_newargv0=$lt_newargv0.exe ;;
    esac
    ;;
  * ) lt_newargv0=$SHELL ;;
esac

However, I see the problem:

(1) the construct `(cmd //c echo $SHELL ...)` assumes that the shell used by the backticks is the MSYS shell -- which is true for native mingw builds only -- because it is using the doubled '/' to bypass MSYS path-translation logic (/c is a switch, not a posix path that needs to be win32-ified). (2) in your case, the shell used by the backticks is your linux shell. Even if you could invoke the Wine 'cmd.exe' in this way, your shell will pass '//c' literally, unlike MSYS shell which says "Oh, this is not a path, so I'll replace '//' with '/' and move on". In your case, the Wine cmd.exe will complain about the illegal argument '//c' (3) the "|| echo $SHELL" part isn't working, because the return status of a subshell is the status of the LAST command -- and $SED is perfectly happy. (4) end result: you have lt_newargv0=<EMPTY>, which then gets ".exe" appended.

Boom.

(5) Also, there is a hidden assumption that the win32 shell that should be used by Wine has the same name as the host shell.

Now, I can probably address some of these isses -- but the real solution is actually found in the enclosing block of code:

if test -n "$TARGETSHELL" ; then
  # no path translation at all
  lt_newargv0=$TARGETSHELL
else
 <the stuff above>
fi

If, when compiling your code, you have TARGETSHELL defined in your envinrment to the win32 (e.g. internal Wine) path, then the wrapper executable will use that. That is,

export TARGETSHELL="C:\\Util\\gnuwin\\bin\\sh.exe"
export TARGETSHELL="C:\\msys\\1.0\\bin\\sh.exe"

*before* building your project.

Assuming that setting TARGETSHELL solves your problem, I think something like the following (untested) patch might be useful. The second hunk tries to address points (1), (2) and (3) above. This still won't fix your problem -- but TARGETSHELL should -- because you'd really just end up trying to exec the linux shell from the (win32-native, Wine) wrapper exe: I don't know if Wine lets you do that.

--
Chuck


--- ltmain.m4sh.orig    2008-04-19 12:30:30.125000000 -0400
+++ ltmain.m4sh 2008-04-19 13:00:08.750000000 -0400
@@ -2683,9 +2683,20 @@
            else
              case "$host" in
                *mingw* )
+                  case "$build" in
+                   *mingw* ) ;;
+                   *cygwin* ) ;; # don't warn if doing cygwin->mingw cross
+                   * ) 
+                     func_warning "Cross-compile for mingw detected, but 
\$TARGETSHELL is not set."
+                     func_warning "Wrapper executables may not function 
correctly unless \$TARGETSHELL"
+                     func_warning "is set to the mingw emulation environment 
path to a posix shell"
+                     func_warning "while building this executable."
+                     ;;
+                 esac 
                  # awkward: cmd appends spaces to result
                  lt_sed_strip_trailing_spaces="s/[ ]*\$//"
-                 lt_newargv0=`( cmd //c echo $SHELL | $SED -e 
"$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo $SHELL`
+                 lt_newargv0=`( cmd //c echo $SHELL ) 2>/dev/null || ( cmd /c 
echo $SHELL ) 2>/dev/null || $ECHO $SHELL`
+                 lt_newargv0=`$ECHO $lt_newargv0 | $SED -e 
"$lt_sed_strip_trailing_spaces"`
                  case $lt_newargv0 in
                    *.exe | *.EXE) ;;
                    *) lt_newargv0=$lt_newargv0.exe ;;

reply via email to

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