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: Fri, 30 Jan 2009 11:20:13 +0100
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)

Den 2009-01-30 00:14 skrev Ralf Wildenhues:
* Peter Rosin wrote on Thu, Jan 29, 2009 at 04:39:16PM CET:
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)

Well, sure, faster is better, but only if functionality is equivalent.

I have an old MSVC installation here to test, but that will take a
couple of days ... until then, any test results help.

Here is an update that forks *a lot* less. The old thing forked 4 times
per file in the dependencies [*], and there can easily be dozens of files.
These changes gets rid of all those per-file forks. Dependencies work
as far as I can see when I compile libltdl using MSVC on both Cygwin
(depmode=msvisualcpp) and MSYS (depmode=msvcmsys). But native MSVC on
Cygwin fails during link, but that's totally unrelated...

("cygpath -f -" support was checked into cvs April 2000.)

Cheers,
Peter

[*] one `subshell`, one cygpath, ttwwiiccee.
diff --git a/ChangeLog b/ChangeLog
index 2463967..2fed32c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-01-30  Peter Rosin  <address@hidden>
+
+       Add depmode=msvcmsys for Microsoft Visual C++ on MSYS.
+       * lib/depcomp [msvisualcpp]: Fork fewer processes. Filter out
+       libtool in the preprocessor invocation (as is done in
+       depmode=cpp). Silence compiler stderr.
+       [msvcmsys]: New depmode as a derivative of depmode=msvisualcpp.
+       msvcmsys transforms any backslashes into forward slashes to
+       make the grep in depend.m4 match, instead of the "cygpath -u"
+       that is used in 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..2205b6a 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-30.01
 
 # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
 # Foundation, Inc.
@@ -85,6 +85,15 @@ if test "$depmode" = dashXmstdout; then
    depmode=dashmstdout
 fi
 
+cygpath_u="cygpath -u -f -"
+if test "$depmode" = msvcmsys; then
+   # This is just like msvisualcpp but w/o cygpath translation.
+   # Just convert the backslash-escaped backslashes to single forward
+   # slashes to satisfy depend.m4
+   cygpath_u="sed s:\\\\\\\\:/:g"
+   depmode=msvisualcpp
+fi
+
 case "$depmode" in
 gcc3)
 ## gcc 3 implements dependency tracking that does exactly what
@@ -536,13 +545,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
@@ -555,16 +578,23 @@ msvisualcpp)
        ;;
     esac
   done
-  "$@" -E |
-  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' 
| sort | uniq > "$tmpdepfile"
+  "$@" -E 2>/dev/null |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > 
"$tmpdepfile"
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::   \1 \\:p' >> 
"$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::     \1 \\:p' >> 
"$depfile"
   echo "       " >> "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> 
"$depfile"
+  sed < "$tmpdepfile" -n -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]