summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorted.mielczarek%gmail.com <devnull@localhost>2011-05-03 18:59:07 +0000
committerted.mielczarek%gmail.com <devnull@localhost>2011-05-03 18:59:07 +0000
commita3523a20955df09395629023a097b466a59bf97d (patch)
tree43638e71dbe32731e86bd21e1942967e9f14f8ac /build
parentbdead222b8396c0ef04be8fe970e7e2c597c8c72 (diff)
downloadnspr-hg-a3523a20955df09395629023a097b466a59bf97d.tar.gz
bug 564851 - Add support for MSVC PGO. Patch by Tetsuro Kato <tete009+bugzilla@gmail.com>, r=wtcNSPR_HEAD_20110503
Diffstat (limited to 'build')
-rw-r--r--build/win32/pgomerge.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/build/win32/pgomerge.py b/build/win32/pgomerge.py
new file mode 100644
index 00000000..383457bf
--- /dev/null
+++ b/build/win32/pgomerge.py
@@ -0,0 +1,40 @@
+#!/usr/bin/python
+# Usage: pgomerge.py <binary basename> <dist/bin>
+# Gathers .pgc files from dist/bin and merges them into
+# $PWD/$basename.pgd using pgomgr, then deletes them.
+# No errors if any of these files don't exist.
+
+import sys, os, os.path, subprocess
+if not sys.platform == "win32":
+ raise Exception("This script was only meant for Windows.")
+
+def MergePGOFiles(basename, pgddir, pgcdir):
+ """Merge pgc files produced from an instrumented binary
+ into the pgd file for the second pass of profile-guided optimization
+ with MSVC. |basename| is the name of the DLL or EXE without the
+ extension. |pgddir| is the path that contains <basename>.pgd
+ (should be the objdir it was built in). |pgcdir| is the path
+ containing basename!N.pgc files, which is probably dist/bin.
+ Calls pgomgr to merge each pgc file into the pgd, then deletes
+ the pgc files."""
+ if not os.path.isdir(pgddir) or not os.path.isdir(pgcdir):
+ return
+ pgdfile = os.path.abspath(os.path.join(pgddir, basename + ".pgd"))
+ if not os.path.isfile(pgdfile):
+ return
+ for file in os.listdir(pgcdir):
+ if file.startswith(basename+"!") and file.endswith(".pgc"):
+ try:
+ pgcfile = os.path.normpath(os.path.join(pgcdir, file))
+ subprocess.call(['pgomgr', '-merge',
+ pgcfile,
+ pgdfile])
+ os.remove(pgcfile)
+ except OSError:
+ pass
+
+if __name__ == '__main__':
+ if len(sys.argv) != 3:
+ print >>sys.stderr, "Usage: pgomerge.py <binary basename> <dist/bin>"
+ sys.exit(1)
+ MergePGOFiles(sys.argv[1], os.getcwd(), sys.argv[2])