automake-patches
[Top][All Lists]
Advanced

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

Re: Make depmode=cpp work with Microsoft Visual C++ on MSYS.


From: Peter Rosin
Subject: Re: Make depmode=cpp work with Microsoft Visual C++ on MSYS.
Date: Thu, 29 Jan 2009 16:39:16 +0100
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)

Den 2009-01-28 13:41, skrev Ralf Wildenhues:
* Peter Rosin wrote on Wed, Jan 28, 2009 at 12:57:43PM CET:
Considering all of the above, how about the attached patch instead? (I
consider it tiny. Even if it touches a few more lines the changes are
trivial, much of it is copy-paste...)

Let's not worry about the copyright implications of it yet.

Indeed.

Den 2009-01-28 09:12, skrev Ralf Wildenhues:
It would be great to see how the Automake test suite fares with this
compiler (see tests/README for how to enable verbose output), esp.
the depcomp*.test tests.
Sorry, but I get this

configure: error: Autoconf 2.61a-341 or better is required.

and I have plain old 2.61. I'm not too keen on building autoconf and
possibly muddy up my install...

You can install Autoconf below a different --prefix.

Yes, but MSYS is MSYS is MSYS is a bitch. I fail to get automake
to build even with autoconf-2.63 (in a new prefix, first in $PATH).

I get this when I type "make" (after ./configure CC="bla bla bla")

 cd .. && perllibdir="/home/peda/automake/git/automake/lib:./lib" 
"/home/peda/automake/git/automake/automake" --libdir=lib --gnu
/bin/sh: /home/peda/automake/git/automake/automake: No such file or directory
make: *** [Makefile.in] Error 1


Which gets me to the next question: if you haven't run the Automake
test suite, how have you tested this patch?  Does it rightly set
depmode to msvisualcpp on Cygwin, and to msvcmsys when using MSYS?
Does it produce correct dependencies?  In the end, I think it'd really
be the easiest if you showed testsuite results, including verbose output
for failures.  You need not take up work to fix all the failures you'll
probably encounter.  (At least not yet  ;->  )

Since the patch is now limited to the depcomp program, I simple copied
that file into libtool and played with configure.
If I configure libtool like this, on MSYS

../configure --enable-dependency-tracking CC=".../path/to/compile cl" CFLAGS="-MD 
-Zi"

I get this output:

## ---------------------------------------------------- ##
## Configuring libtool (Build:1.3093 2009-01-27) 2.2.7a ##
## ---------------------------------------------------- ##

checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether subdir libobjs are useable... yes
checking for gcc... .../path/to/compile cl
checking for C compiler default output file name... conftest.exe
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... obj
checking whether we are using the GNU C compiler... no
checking whether .../path/to/compile cl accepts -g... yes
checking for .../path/to/compile cl option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of .../path/to/compile cl... msvcmsys
checking whether .../path/to/compile cl and cc understand -c and -o together... 
yes
*snip*


On Cygwin, with the same configure options:

## ---------------------------------------------------- ##
## Configuring libtool (Build:1.3093 2009-01-27) 2.2.7a ##
## ---------------------------------------------------- ##

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether subdir libobjs are useable... yes
checking for gcc... .../path/to/compile cl
checking for C compiler default output file name... conftest.exe
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... obj
checking whether we are using the GNU C compiler... no
checking whether .../path/to/compile cl accepts -g... yes
checking for .../path/to/compile cl option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of .../path/to/compile cl... msvisualcpp
checking whether .../path/to/compile cl and cc understand -c and -o together... 
yes
*snip*

But I didn't test enough of course. Blast, it worked with depmode=cpp
so I just assumed depmode=msvisualcpp was good enough too. Not so.

depmode=msvisualcpp, when used with libtool clobbers the output file
in the second invocation (with -E). So, I need to copy-paste some code
from the depmode=cpp to filter out libtool (and -o $object) from
that second invocation.

But if you are looking for bugs to squash, one obvious problem is
that the standard
AC_PROG_CC
AM_PROG_CC_C_O
puts the dependency check before the -c -o check, which forces losers
like me to configure CC=".../path/to/compile cl" for the dependency
checker to work (as it compiles in subdirs with -c -o). Can some m4
magic be applied so that the dependency check is moved down or the
-c -o check moved up, that would be much appreciated!

Can probably be done in principle, but would be hacky.  Not sure if that
is the /first/ bug I'd be trying to fix.

It may mean that you have to
  export CC=".../path/to/compile cl"
for some of the testsuite tests though.  Bummer.

Bummer. Exactly, being forced to feed various options to configure
should be avoided. I't bad enough as it is...

Anyway, thank you for your work on this!

We'll see how far I get...

+2009-01-28  Peter Rosin  <address@hidden>
+
+       Add depmode=msvcmsys for Microsoft Visual C++ on MSYS.
+       * lib/depcomp: Add depmode=msvcmsys as a derivative of
+       depmode=msvisualcpp. msvcmsys uses echo instead of "cygpath -u"
+       to prevent any path translation.
+       Also transform any backslashes into forward slashes to make the
+       grep in depend.m4 match.

@@ -85,6 +85,13 @@ if test "$depmode" = dashXmstdout; then
    depmode=dashmstdout
 fi
+cygpath_u="cygpath -u"
+if test "$depmode" = msvcmsys; then
+   # This is just like msvisualcpp but w/o cygpath translation.
+   cygpath_u=echo

Why not something involving 'CMD //C'?

Because MSVC spits out Win32 paths, no need to involve MSYS with those.

+   depmode=msvisualcpp
+fi
+
 case "$depmode" in
 gcc3)
 ## gcc 3 implements dependency tracking that does exactly what
@@ -556,15 +563,22 @@ msvisualcpp)
     esac
   done
   "$@" -E |
-  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq 
> "$tmpdepfile"
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`$cygpath_u \\"\1\\"`":p' | sort | uniq 
> "$tmpdepfile"

sort -u?

One fork less for each dep, thank you very much. But if it's forks
we're chasing, the echo in the echoed `subshell` isn't really
defendable when some form of simple echo would do...

   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> 
"$depfile"
+  . "$tmpdepfile" | sed -e 's%\\%/%g' -e 's% %\\ %g' | sed -n '/^\(.*\)$/ s::        \1 \\:p' 
>> "$depfile"

You can combine the two sed scripts.

One fork less for each dep, thank you very much.

   echo "  " >> "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> 
"$depfile"
+  . "$tmpdepfile" | sed -e 's%\\%/%g' -e 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> 
"$depfile"

Likewise.

One fork less for each dep, thank you very much.

   rm -f "$tmpdepfile"
   ;;


Ok, third iteration, taking care of all of the above except the
echo `echo file` thing.

But comparing the resulting depmode=msvisualcpp with depmode=cpp,
maybe msvcmsys fit better as a tweeked cpp?
That would get rid of a whole bunch of forks for each dep.
(msvisualcpp is noticeably slower than cpp)

Cheers,
Peter

2009-01-29  Peter Rosin  <address@hidden>

        Add depmode=msvcmsys for Microsoft Visual C++ on MSYS.
        * lib/depcomp: Add depmode=msvcmsys as a derivative of
        depmode=msvisualcpp. msvcmsys uses echo instead of "cygpath -u"
        to prevent any path translation.
        Also transform any backslashes into forward slashes to make the
        grep in depend.m4 match.
        Fork fewer processes for depmode=msvisualcpp.
        Filter out libtool in the preprocessor invocation (as is done
        in depmode=cpp) for depmode=msvisualcpp.
diff --git a/ChangeLog b/ChangeLog
index 2463967..60084f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-01-29  Peter Rosin  <address@hidden>
+
+       Add depmode=msvcmsys for Microsoft Visual C++ on MSYS.
+       * lib/depcomp: Add depmode=msvcmsys as a derivative of
+       depmode=msvisualcpp. msvcmsys uses echo instead of "cygpath -u"
+       to prevent any path translation.
+       Also transform any backslashes into forward slashes to make the
+       grep in depend.m4 match.
+       Fork fewer processes for depmode=msvisualcpp.
+       Filter out libtool in the preprocessor invocation (as is done
+       in depmode=cpp) for depmode=msvisualcpp.
+
 2009-01-23  Eric Blake  <address@hidden>
 
        Use no-arg macros via AC_REQUIRE for consistency.
diff --git a/lib/depcomp b/lib/depcomp
index 0f2bf43..ccb97d2 100755
--- a/lib/depcomp
+++ b/lib/depcomp
@@ -1,7 +1,7 @@
 #! /bin/sh
 # depcomp - compile a program generating dependencies as side-effects
 
-scriptversion=2007-03-29.01
+scriptversion=2009-01-29.01
 
 # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
 # Foundation, Inc.
@@ -85,6 +85,13 @@ if test "$depmode" = dashXmstdout; then
    depmode=dashmstdout
 fi
 
+cygpath_u="cygpath -u"
+if test "$depmode" = msvcmsys; then
+   # This is just like msvisualcpp but w/o cygpath translation.
+   cygpath_u=echo
+   depmode=msvisualcpp
+fi
+
 case "$depmode" in
 gcc3)
 ## gcc 3 implements dependency tracking that does exactly what
@@ -536,13 +543,27 @@ cpp)
 
 msvisualcpp)
   # Important note: in order to support this mode, a compiler *must*
-  # always write the preprocessed file to stdout, regardless of -o,
-  # because we must use -o when running libtool.
+  # always write the preprocessed file to stdout.
   "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
   IFS=" "
   for arg
   do
     case "$arg" in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
     "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
        set fnord "$@"
        shift
@@ -556,15 +577,22 @@ msvisualcpp)
     esac
   done
   "$@" -E |
-  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' 
| sort | uniq > "$tmpdepfile"
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`$cygpath_u \\"\1\\"`":p' 
| sort -u > "$tmpdepfile"
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::   \1 \\:p' >> 
"$depfile"
+  . "$tmpdepfile" | sed -n -e 's%\\%/%g' -e 's% %\\ %g' -e '/^\(.*\)$/ s::     
\1 \\:p' >> "$depfile"
   echo "       " >> "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> 
"$depfile"
+  . "$tmpdepfile" | sed -n -e 's%\\%/%g' -e 's% %\\ %g' -e '/^\(.*\)$/ 
s::\1\::p' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
+msvcmsys)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
 none)
   exec "$@"
   ;;

reply via email to

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