Hi! As suggested by Ralf, there is room for improvement in the compile script. There is no need to convert filenames when MSYS is going to do it anyway, especially when the conversion costs a bunch of forks.
I have tested this patch with this: cat > filenames << 'EOF' #! /bin/sh foo=0 while test $foo -lt $1 do foo=$(($foo + 1)) args="$args $2$foo$3" done echo "$args" EOF chmod 755 filenames time for file in `./filenames 20 / .cc`; do ./compile cl $file; done real 0m9.781s user 0m5.532s sys 0m4.609s time for file in `./filenames 20 / .cpp`; do ./compile cl $file; done real 0m5.547s user 0m1.737s sys 0m1.890s time ./compile cl `./filenames 20 / .cc` real 0m5.218s user 0m3.871s sys 0m3.158s time ./compile cl `./filenames 20 / .cpp` real 0m0.734s user 0m0.106s sys 0m0.154s The C++ files don't exist, so this includes the time for cl determining that and outputing an error message (which I snipped). For reference, here's a run from before the patch: time for file in `./filenames 20 / .cc`; do ./oldcompile cl $file; done real 0m9.875s user 0m5.718s sys 0m4.483s time for file in `./filenames 20 / .cpp`; do ./oldcompile cl $file; done real 0m9.906s user 0m5.498s sys 0m4.822s time ./oldcompile cl `./filenames 20 / .cc` real 0m5.187s user 0m4.026s sys 0m2.912s time ./oldcompile cl `./filenames 20 / .cpp` real 0m5.156s user 0m4.044s sys 0m2.898s To conclude, this shaves off 4-5 seconds when compiling 20 files with absolute file names on MSYS. The cost when the new code isn't needed seems negligible in comparison. I get the same 4-5 seconds improvement when I run with this fake cl script: cat > cl << 'EOF' #! /bin/sh echo "$@" EOF That said, don't expect too much from this as using absolute file names is not really the common case... Cheers, Peter
>From 77f0a9fd4265f5b22d5686e3da27c86aee496b6d Mon Sep 17 00:00:00 2001 From: Peter Rosin <p...@lysator.liu.se> Date: Mon, 16 Aug 2010 13:50:32 +0200 Subject: [PATCH] Optimize compile script on MSYS. * lib/compile (func_file_conv): Add new argument 'lazy' which takes an optional list of conversion types where the requested conversion isn't needed. (func_cl_wrapper): Take advantage of the above for cases where MSYS is doing the conversion for us. Suggested by Ralf Wildenhues. Signed-off-by: Peter Rosin <p...@lysator.liu.se> --- ChangeLog | 10 ++++++++++ lib/compile | 22 +++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f90bd0..9a054e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2010-08-16 Peter Rosin <p...@lysator.liu.se> + Optimize compile script on MSYS. + * lib/compile (func_file_conv): Add new argument 'lazy' which + takes an optional list of conversion types where the requested + conversion isn't needed. + (func_cl_wrapper): Take advantage of the above for cases where + MSYS is doing the conversion for us. + Suggested by Ralf Wildenhues. + +2010-08-16 Peter Rosin <p...@lysator.liu.se> + Support more C++ file extensions for MSVC in the compile script. * lib/compile (func_cl_wrapper): MSVC only recognizes the .cpp file extension as C++, unless it's given a hint. So hint about diff --git a/lib/compile b/lib/compile index cd3b801..b6419ce 100755 --- a/lib/compile +++ b/lib/compile @@ -1,7 +1,7 @@ #! /bin/sh # Wrapper for compilers which do not understand `-c -o'. -scriptversion=2010-08-16.07; # UTC +scriptversion=2010-08-16.11; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010 Free Software # Foundation, Inc. @@ -38,9 +38,11 @@ IFS=" "" $nl" file_conv= -# func_file_conv build_file +# func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file -# Currently only supports Win32 hosts. +# Currently only supports Win32 hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. func_file_conv () { file=$1 @@ -60,14 +62,16 @@ func_file_conv () ;; esac fi - case $file_conv in - mingw) + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; - cygwin) + cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; - wine) + wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac @@ -104,7 +108,7 @@ func_cl_wrapper () esac ;; -I*) - func_file_conv "${1#-I}" + func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; @@ -139,7 +143,7 @@ func_cl_wrapper () shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib) - func_file_conv "$1" + func_file_conv "$1" mingw set x "$@" "$file" shift ;; -- 1.6.4.2