]> 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:26:50 +0000 (01:26 -0600)
committerZachary Ware <zachary.ware@gmail.com>
Tue, 12 Jan 2016 07:26:50 +0000 (01:26 -0600)
Misc/NEWS
PCbuild/build.bat
PCbuild/build_pgo.bat

index 20d8bb2e0de6bd5a19c14d89de2731ff77c727ad..cc0c799d1ce281c94f199063b709cb2591a65d8a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -151,6 +151,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 cfbc4a29377755c9373cffd5d39a18d837329dfe..88b1f060ab1f0470ed836f2f70770f7f6c7df310 100644 (file)
@@ -25,6 +25,9 @@ echo.  -M  Disable parallel build
 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.  --test-marker  Enable the test marker within the build.\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,7 +41,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.  --test-marker  Enable the test marker within the build.\r
+echo.  --pgo-job  The job to use for PGO training; implies --pgo\r
+echo.             (default: "-m test --pgo")\r
 exit /b 127\r
 \r
 :Run\r
@@ -51,6 +55,12 @@ set dir=%~dp0
 set parallel=/m\r
 set verbose=/nologo /v:m\r
 set kill=\r
+set do_pgo=\r
+set pgo_job=-m test --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
@@ -63,6 +73,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
 if "%~1"=="--test-marker" (set UseTestMarker=true) & shift & goto CheckOpts\r
 if "%~1"=="-V" shift & goto Version\r
 rem These use the actual property names used by MSBuild.  We could just let\r
@@ -78,15 +90,49 @@ if "%IncludeTkinter%"=="" set IncludeTkinter=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
@@ -98,7 +144,8 @@ msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
  /p:UseTestMarker=%UseTestMarker%^\r
  %1 %2 %3 %4 %5 %6 %7 %8 %9\r
 \r
-@goto :eof\r
+@echo off\r
+goto :eof\r
 \r
 :Version\r
 rem Display the current build version information\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