On my system, "build DEBUG" takes ~2.75 minutes. When I tell MSBuild to build in parallel by passing it the /m flag, that goes down to 1.5 minutes.

The first patch passes the value of the MSBFLAGS environment variable to msbuild's command line.

The output of parallel and sequential builds has identical file count and size after installing; all tests pass.

Even without /m, MSBuild will already run enough compilers to keep all CPUs busy whenever it can do that with only a single project's files. With /m, it will also process _projects_ in parallel.

One additional fix required is to put gendef.pl's "symbols.out" file into the directory it is working on, rather than the source tree root, to avoid collisions that cause the parallel build to fail otherwise.

--
Christian
From 4b455e1ac38f1441f1faf695da4be8c5eb478970 Mon Sep 17 00:00:00 2001
From: Christian Ullrich <ch...@chrullrich.net>
Date: Tue, 26 Apr 2016 14:52:27 +0200
Subject: [PATCH 1/2] Support passing arbitrary arguments to MSBuild.

This is particularly useful to pass /m, to perform a parallel build.
---
 doc/src/sgml/install-windows.sgml | 11 +++++++++--
 src/tools/msvc/build.pl           |  5 +++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/doc/src/sgml/install-windows.sgml 
b/doc/src/sgml/install-windows.sgml
index 74265fc..2b9cf1a 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -137,6 +137,13 @@ $config->{python} = 'c:\python26';
 $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';
 </programlisting>
  </para>
+ <para>
+  To pass additional command line arguments to msbuild (Visual Studio 2010
+  and later):
+<programlisting>
+$ENV{MSBFLAGS}="/m";
+</programlisting>
+ </para>
 
  <sect2>
   <title>Requirements</title>
@@ -361,12 +368,12 @@ $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';
 </screen>
    To build all of PostgreSQL in debug configuration, run the command:
 <screen>
-<userinput>build DEBUG</userinput>
+<userinput>build -c DEBUG</userinput>
 </screen>
    To build just a single project, for example psql, run the commands:
 <screen>
 <userinput>build psql</userinput>
-<userinput>build DEBUG psql</userinput>
+<userinput>build -c DEBUG psql</userinput>
 </screen>
    To change the default build configuration to debug, put the following
    in the <filename>buildenv.pl</filename> file:
diff --git a/src/tools/msvc/build.pl b/src/tools/msvc/build.pl
index c4e4dc7..85109a2 100644
--- a/src/tools/msvc/build.pl
+++ b/src/tools/msvc/build.pl
@@ -38,6 +38,7 @@ my $vcver = Mkvcbuild::mkvcbuild($config);
 # check what sort of build we are doing
 
 my $bconf     = $ENV{CONFIG} || "Release";
+my $msbflags  = $ENV{MSBFLAGS} || "";
 my $buildwhat = $ARGV[1]     || "";
 if (uc($ARGV[0]) eq 'DEBUG')
 {
@@ -53,7 +54,7 @@ elsif (uc($ARGV[0]) ne "RELEASE")
 if ($buildwhat and $vcver >= 10.00)
 {
        system(
-"msbuild $buildwhat.vcxproj /verbosity:normal /p:Configuration=$bconf");
+"msbuild $buildwhat.vcxproj $msbflags /verbosity:normal 
/p:Configuration=$bconf");
 }
 elsif ($buildwhat)
 {
@@ -61,7 +62,7 @@ elsif ($buildwhat)
 }
 else
 {
-       system("msbuild pgsql.sln /verbosity:normal /p:Configuration=$bconf");
+       system("msbuild pgsql.sln $msbflags /verbosity:normal 
/p:Configuration=$bconf");
 }
 
 # report status
-- 
2.8.1.windows.1

From 51cccd968b5ba98da4d971d9c69b59ec85cfa513 Mon Sep 17 00:00:00 2001
From: Christian Ullrich <ch...@chrullrich.net>
Date: Tue, 26 Apr 2016 14:52:53 +0200
Subject: [PATCH 2/2] Support parallel build with MSBuild.

gendef.pl now puts the temporary output file into the target directory instead 
of the source tree root, to avoid collisions.
---
 src/tools/msvc/gendef.pl | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/tools/msvc/gendef.pl b/src/tools/msvc/gendef.pl
index 8ccaab3..4bd05fa 100644
--- a/src/tools/msvc/gendef.pl
+++ b/src/tools/msvc/gendef.pl
@@ -4,6 +4,7 @@ use warnings;
 use strict;
 use 5.8.0;
 use List::Util qw(max);
+use File::Spec::Functions qw(splitpath catpath);
 
 #
 # Script that generates a .DEF file for all objects in a directory
@@ -14,9 +15,11 @@ use List::Util qw(max);
 sub dumpsyms
 {
        my ($objfile, $symfile) = @_;
-       system("dumpbin /symbols /out:symbols.out $_ >NUL")
+       my ($symvol, $symdirs, $symbase) = splitpath($symfile);
+       my $tmpfile = catpath($symvol, $symdirs, "symbols.out");
+       system("dumpbin /symbols /out:$tmpfile $_ >NUL")
          && die "Could not call dumpbin";
-       rename("symbols.out", $symfile);
+       rename($tmpfile, $symfile);
 }
 
 # Given a symbol file path, loops over its contents
-- 
2.8.1.windows.1

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to