]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #25348: Add --pgo and --pgo-job flags to PCbuild\build.bat
authorZachary Ware <zachary.ware@gmail.com>
Tue, 12 Jan 2016 07:20:33 +0000 (01:20 -0600)
committerZachary Ware <zachary.ware@gmail.com>
Tue, 12 Jan 2016 07:20:33 +0000 (01:20 -0600)
Misc/NEWS
PCbuild/build.bat
PCbuild/build_pgo.bat
PCbuild/env.bat

index e533d55d7117056c5d17c706aae69deda49b5e39..d470780c0cc8ec89000a2a99d3d1e97117612738 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -85,6 +85,11 @@ Tests
 Build
 -----
 
+- Issue #25348: Added ``--pgo`` and ``--pgo-job`` arguments to
+  ``PCbuild\build.bat`` for building with Profile-Guided Optimization.  The
+  old ``PCbuild\build_pgo.bat`` script is now deprecated, and simply calls
+  ``PCbuild\build.bat --pgo %*``.
+
 - Issue #25827: Add support for building with ICC to ``configure``, including
   a new ``--with-icc`` flag.
 
index f3dcc91eab991a7238291dea8692d7d2a6af7d71..766378fb2daa9c9efd9c41c2f9d19a37f48be3fc 100644 (file)
@@ -24,6 +24,8 @@ echo.  -M  Disable parallel build (disabled by default)
 echo.  -v  Increased output messages\r
 echo.  -k  Attempt to kill any running Pythons before building (usually done\r
 echo.      automatically by the pythoncore project)\r
+echo.  --pgo          Build with Profile-Guided Optimization.  This flag\r
+echo.                 overrides -c and -d\r
 echo.\r
 echo.Available flags to avoid building certain modules.\r
 echo.These flags have no effect if '-e' is not given:\r
@@ -38,6 +40,8 @@ echo.  -p x64 ^| Win32
 echo.     Set the platform (default: Win32)\r
 echo.  -t Build ^| Rebuild ^| Clean ^| CleanAll\r
 echo.     Set the target manually\r
+echo.  --pgo-job  The job to use for PGO training; implies --pgo\r
+echo.             (default: "-m test.regrtest --pgo")\r
 exit /b 127\r
 \r
 :Run\r
@@ -50,6 +54,12 @@ set dir=%~dp0
 set parallel=\r
 set verbose=/nologo /v:m\r
 set kill=\r
+set do_pgo=\r
+set pgo_job=-m test.regrtest --pgo\r
+set on_64_bit=true\r
+\r
+rem This may not be 100% accurate, but close enough.\r
+if "%ProgramFiles(x86)%"=="" (set on_64_bit=false)\r
 \r
 :CheckOpts\r
 if "%~1"=="-h" goto Usage\r
@@ -62,6 +72,8 @@ if "%~1"=="-m" (set parallel=/m) & shift & goto CheckOpts
 if "%~1"=="-M" (set parallel=) & shift & goto CheckOpts\r
 if "%~1"=="-v" (set verbose=/v:n) & shift & goto CheckOpts\r
 if "%~1"=="-k" (set kill=true) & shift & goto CheckOpts\r
+if "%~1"=="--pgo" (set do_pgo=true) & shift & goto CheckOpts\r
+if "%~1"=="--pgo-job" (set do_pgo=true) & (set pgo_job=%~2) & shift & shift & goto CheckOpts\r
 rem These use the actual property names used by MSBuild.  We could just let\r
 rem them in through the environment, but we specify them on the command line\r
 rem anyway for visibility so set defaults after this\r
@@ -77,15 +89,49 @@ if "%IncludeBsddb%"=="" set IncludeBsddb=true
 \r
 if "%IncludeExternals%"=="true" call "%dir%get_externals.bat"\r
 \r
-if "%platf%"=="x64" (set vs_platf=x86_amd64)\r
+if "%platf%"=="x64" (\r
+    if "%on_64_bit%"=="true" (\r
+        rem This ought to always be correct these days...\r
+        set vs_platf=amd64\r
+    ) else (\r
+        if "%do_pgo%"=="true" (\r
+            echo.ERROR: Cannot cross-compile with PGO\r
+            echo.    32bit operating system detected, if this is incorrect,\r
+            echo.    make sure the ProgramFiles(x86^) environment variable is set\r
+            exit /b 1\r
+        )\r
+        set vs_platf=x86_amd64\r
+    )\r
+)\r
 \r
 rem Setup the environment\r
 call "%dir%env.bat" %vs_platf% >nul\r
 \r
-if "%kill%"=="true" (\r
-    msbuild /v:m /nologo /target:KillPython "%dir%\pythoncore.vcxproj" /p:Configuration=%conf% /p:Platform=%platf% /p:KillPython=true\r
+if "%kill%"=="true" call :Kill\r
+\r
+if "%do_pgo%"=="true" (\r
+    set conf=PGInstrument\r
+    call :Build\r
+    del /s "%dir%\*.pgc"\r
+    del /s "%dir%\..\Lib\*.pyc"\r
+    echo on\r
+    call "%dir%\..\python.bat" %pgo_job%\r
+    @echo off\r
+    call :Kill\r
+    set conf=PGUpdate\r
 )\r
+goto Build\r
+\r
+:Kill\r
+echo on\r
+msbuild "%dir%\pythoncore.vcxproj" /t:KillPython %verbose%^\r
+ /p:Configuration=%conf% /p:Platform=%platf%^\r
+ /p:KillPython=true\r
+\r
+@echo off\r
+goto :eof\r
 \r
+:Build\r
 rem Call on MSBuild to do the work, echo the command.\r
 rem Passing %1-9 is not the preferred option, but argument parsing in\r
 rem batch is, shall we say, "lackluster"\r
@@ -96,3 +142,6 @@ msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
  /p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^\r
  /p:IncludeBsddb=%IncludeBsddb%^\r
  %1 %2 %3 %4 %5 %6 %7 %8 %9\r
+\r
+@echo off\r
+goto :eof\r
index 79ec2670b043653398e6a8bcd1c33cdc847fbff5..872c3822ecb21954c0c0228c7520f75ed5386a45 100644 (file)
@@ -1,48 +1,6 @@
 @echo off\r
-rem A batch program to build PGO (Profile guided optimization) by first\r
-rem building instrumented binaries, then running the testsuite, and\r
-rem finally building the optimized code.\r
-rem Note, after the first instrumented run, one can just keep on\r
-rem building the PGUpdate configuration while developing.\r
+echo.DeprecationWarning:\r
+echo.    This script is deprecated, use `build.bat --pgo` instead.\r
+echo.\r
 \r
-setlocal\r
-set platf=Win32\r
-set parallel=/m\r
-set dir=%~dp0\r
-\r
-rem use the performance testsuite.  This is quick and simple\r
-set job1="%dir%..\tools\pybench\pybench.py" -n 1 -C 1 --with-gc\r
-set path1="%dir%..\tools\pybench"\r
-\r
-rem or the whole testsuite for more thorough testing\r
-set job2="%dir%..\lib\test\regrtest.py"\r
-set path2="%dir%..\lib"\r
-\r
-set job=%job1%\r
-set clrpath=%path1%\r
-\r
-:CheckOpts\r
-if "%1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts\r
-if "%1"=="-2" (set job=%job2%) & (set clrpath=%path2%) & shift & goto CheckOpts\r
-if "%1"=="-M" (set parallel=) & shift & goto CheckOpts\r
-\r
-\r
-rem We cannot cross compile PGO builds, as the optimization needs to be run natively\r
-set vs_platf=x86\r
-set PGO=%dir%win32-pgo\r
-\r
-if "%platf%"=="x64" (set vs_platf=amd64) & (set PGO=%dir%amd64-pgo)\r
-rem Setup the environment\r
-call "%dir%env.bat" %vs_platf%\r
-\r
-\r
-rem build the instrumented version\r
-msbuild "%dir%pcbuild.proj" %parallel% /t:Build /p:Configuration=PGInstrument /p:Platform=%platf% %1 %2 %3 %4 %5 %6 %7 %8 %9\r
-\r
-rem remove .pyc files, .pgc files and execute the job\r
-"%PGO%\python.exe" "%dir%rmpyc.py" %clrpath%\r
-del "%PGO%\*.pgc"\r
-"%PGO%\python.exe" %job%\r
-\r
-rem build optimized version\r
-msbuild "%dir%pcbuild.proj" %parallel% /t:Build /p:Configuration=PGUpdate /p:Platform=%platf% %1 %2 %3 %4 %5 %6 %7 %8 %9\r
+call "%~dp0build.bat" --pgo %*\r
index ec8a69539f8ee68784f1c4ec6bf99096829cf867..1719cc130b63e63637c58952796d7c0857d231d6 100644 (file)
@@ -10,6 +10,12 @@ rem other than 'v90' is supported!
 \r
 echo Build environments: x86, amd64, x86_amd64\r
 echo.\r
+\r
+rem Set up the v90 tools first.  This is mostly needed to allow PGInstrument\r
+rem builds to find the PGO DLL.  Do it first so the newer MSBuild is found\r
+rem before the one from v90 (vcvarsall.bat prepends to PATH).\r
+call "%VS90COMNTOOLS%..\..\VC\vcvarsall.bat" %*\r
+\r
 set VSTOOLS=%VS140COMNTOOLS%\r
 if "%VSTOOLS%"=="" set VSTOOLS=%VS120COMNTOOLS%\r
 if "%VSTOOLS%"=="" set VSTOOLS=%VS110COMNTOOLS%\r