mirror of
https://github.com/python/cpython.git
synced 2025-11-20 10:57:44 +00:00
Issue #25348: Add --pgo and --pgo-job flags to PCbuild\build.bat
This commit is contained in:
parent
a7c159ddf3
commit
bed30c37d8
3 changed files with 62 additions and 52 deletions
|
|
@ -151,6 +151,11 @@ Tests
|
||||||
Build
|
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
|
- Issue #25827: Add support for building with ICC to ``configure``, including
|
||||||
a new ``--with-icc`` flag.
|
a new ``--with-icc`` flag.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ echo. -M Disable parallel build
|
||||||
echo. -v Increased output messages
|
echo. -v Increased output messages
|
||||||
echo. -k Attempt to kill any running Pythons before building (usually done
|
echo. -k Attempt to kill any running Pythons before building (usually done
|
||||||
echo. automatically by the pythoncore project)
|
echo. automatically by the pythoncore project)
|
||||||
|
echo. --pgo Build with Profile-Guided Optimization. This flag
|
||||||
|
echo. overrides -c and -d
|
||||||
|
echo. --test-marker Enable the test marker within the build.
|
||||||
echo.
|
echo.
|
||||||
echo.Available flags to avoid building certain modules.
|
echo.Available flags to avoid building certain modules.
|
||||||
echo.These flags have no effect if '-e' is not given:
|
echo.These flags have no effect if '-e' is not given:
|
||||||
|
|
@ -38,7 +41,8 @@ echo. -p x64 ^| Win32
|
||||||
echo. Set the platform (default: Win32)
|
echo. Set the platform (default: Win32)
|
||||||
echo. -t Build ^| Rebuild ^| Clean ^| CleanAll
|
echo. -t Build ^| Rebuild ^| Clean ^| CleanAll
|
||||||
echo. Set the target manually
|
echo. Set the target manually
|
||||||
echo. --test-marker Enable the test marker within the build.
|
echo. --pgo-job The job to use for PGO training; implies --pgo
|
||||||
|
echo. (default: "-m test --pgo")
|
||||||
exit /b 127
|
exit /b 127
|
||||||
|
|
||||||
:Run
|
:Run
|
||||||
|
|
@ -51,6 +55,12 @@ set dir=%~dp0
|
||||||
set parallel=/m
|
set parallel=/m
|
||||||
set verbose=/nologo /v:m
|
set verbose=/nologo /v:m
|
||||||
set kill=
|
set kill=
|
||||||
|
set do_pgo=
|
||||||
|
set pgo_job=-m test --pgo
|
||||||
|
set on_64_bit=true
|
||||||
|
|
||||||
|
rem This may not be 100% accurate, but close enough.
|
||||||
|
if "%ProgramFiles(x86)%"=="" (set on_64_bit=false)
|
||||||
|
|
||||||
:CheckOpts
|
:CheckOpts
|
||||||
if "%~1"=="-h" goto Usage
|
if "%~1"=="-h" goto Usage
|
||||||
|
|
@ -63,6 +73,8 @@ if "%~1"=="-m" (set parallel=/m) & shift & goto CheckOpts
|
||||||
if "%~1"=="-M" (set parallel=) & shift & goto CheckOpts
|
if "%~1"=="-M" (set parallel=) & shift & goto CheckOpts
|
||||||
if "%~1"=="-v" (set verbose=/v:n) & shift & goto CheckOpts
|
if "%~1"=="-v" (set verbose=/v:n) & shift & goto CheckOpts
|
||||||
if "%~1"=="-k" (set kill=true) & shift & goto CheckOpts
|
if "%~1"=="-k" (set kill=true) & shift & goto CheckOpts
|
||||||
|
if "%~1"=="--pgo" (set do_pgo=true) & shift & goto CheckOpts
|
||||||
|
if "%~1"=="--pgo-job" (set do_pgo=true) & (set pgo_job=%~2) & shift & shift & goto CheckOpts
|
||||||
if "%~1"=="--test-marker" (set UseTestMarker=true) & shift & goto CheckOpts
|
if "%~1"=="--test-marker" (set UseTestMarker=true) & shift & goto CheckOpts
|
||||||
if "%~1"=="-V" shift & goto Version
|
if "%~1"=="-V" shift & goto Version
|
||||||
rem These use the actual property names used by MSBuild. We could just let
|
rem These use the actual property names used by MSBuild. We could just let
|
||||||
|
|
@ -78,15 +90,49 @@ if "%IncludeTkinter%"=="" set IncludeTkinter=true
|
||||||
|
|
||||||
if "%IncludeExternals%"=="true" call "%dir%get_externals.bat"
|
if "%IncludeExternals%"=="true" call "%dir%get_externals.bat"
|
||||||
|
|
||||||
if "%platf%"=="x64" (set vs_platf=x86_amd64)
|
if "%platf%"=="x64" (
|
||||||
|
if "%on_64_bit%"=="true" (
|
||||||
|
rem This ought to always be correct these days...
|
||||||
|
set vs_platf=amd64
|
||||||
|
) else (
|
||||||
|
if "%do_pgo%"=="true" (
|
||||||
|
echo.ERROR: Cannot cross-compile with PGO
|
||||||
|
echo. 32bit operating system detected, if this is incorrect,
|
||||||
|
echo. make sure the ProgramFiles(x86^) environment variable is set
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
set vs_platf=x86_amd64
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
rem Setup the environment
|
rem Setup the environment
|
||||||
call "%dir%env.bat" %vs_platf% >nul
|
call "%dir%env.bat" %vs_platf% >nul
|
||||||
|
|
||||||
if "%kill%"=="true" (
|
if "%kill%"=="true" call :Kill
|
||||||
msbuild /v:m /nologo /target:KillPython "%dir%\pythoncore.vcxproj" /p:Configuration=%conf% /p:Platform=%platf% /p:KillPython=true
|
|
||||||
)
|
|
||||||
|
|
||||||
|
if "%do_pgo%"=="true" (
|
||||||
|
set conf=PGInstrument
|
||||||
|
call :Build
|
||||||
|
del /s "%dir%\*.pgc"
|
||||||
|
del /s "%dir%\..\Lib\*.pyc"
|
||||||
|
echo on
|
||||||
|
call "%dir%\..\python.bat" %pgo_job%
|
||||||
|
@echo off
|
||||||
|
call :Kill
|
||||||
|
set conf=PGUpdate
|
||||||
|
)
|
||||||
|
goto Build
|
||||||
|
|
||||||
|
:Kill
|
||||||
|
echo on
|
||||||
|
msbuild "%dir%\pythoncore.vcxproj" /t:KillPython %verbose%^
|
||||||
|
/p:Configuration=%conf% /p:Platform=%platf%^
|
||||||
|
/p:KillPython=true
|
||||||
|
|
||||||
|
@echo off
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:Build
|
||||||
rem Call on MSBuild to do the work, echo the command.
|
rem Call on MSBuild to do the work, echo the command.
|
||||||
rem Passing %1-9 is not the preferred option, but argument parsing in
|
rem Passing %1-9 is not the preferred option, but argument parsing in
|
||||||
rem batch is, shall we say, "lackluster"
|
rem batch is, shall we say, "lackluster"
|
||||||
|
|
@ -98,7 +144,8 @@ msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
|
||||||
/p:UseTestMarker=%UseTestMarker%^
|
/p:UseTestMarker=%UseTestMarker%^
|
||||||
%1 %2 %3 %4 %5 %6 %7 %8 %9
|
%1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||||
|
|
||||||
@goto :eof
|
@echo off
|
||||||
|
goto :eof
|
||||||
|
|
||||||
:Version
|
:Version
|
||||||
rem Display the current build version information
|
rem Display the current build version information
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,6 @@
|
||||||
@echo off
|
@echo off
|
||||||
rem A batch program to build PGO (Profile guided optimization) by first
|
echo.DeprecationWarning:
|
||||||
rem building instrumented binaries, then running the testsuite, and
|
echo. This script is deprecated, use `build.bat --pgo` instead.
|
||||||
rem finally building the optimized code.
|
echo.
|
||||||
rem Note, after the first instrumented run, one can just keep on
|
|
||||||
rem building the PGUpdate configuration while developing.
|
|
||||||
|
|
||||||
setlocal
|
call "%~dp0build.bat" --pgo %*
|
||||||
set platf=Win32
|
|
||||||
set parallel=/m
|
|
||||||
set dir=%~dp0
|
|
||||||
|
|
||||||
rem use the performance testsuite. This is quick and simple
|
|
||||||
set job1="%dir%..\tools\pybench\pybench.py" -n 1 -C 1 --with-gc
|
|
||||||
set path1="%dir%..\tools\pybench"
|
|
||||||
|
|
||||||
rem or the whole testsuite for more thorough testing
|
|
||||||
set job2="%dir%..\lib\test\regrtest.py"
|
|
||||||
set path2="%dir%..\lib"
|
|
||||||
|
|
||||||
set job=%job1%
|
|
||||||
set clrpath=%path1%
|
|
||||||
|
|
||||||
:CheckOpts
|
|
||||||
if "%1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts
|
|
||||||
if "%1"=="-2" (set job=%job2%) & (set clrpath=%path2%) & shift & goto CheckOpts
|
|
||||||
if "%1"=="-M" (set parallel=) & shift & goto CheckOpts
|
|
||||||
|
|
||||||
|
|
||||||
rem We cannot cross compile PGO builds, as the optimization needs to be run natively
|
|
||||||
set vs_platf=x86
|
|
||||||
set PGO=%dir%win32-pgo
|
|
||||||
|
|
||||||
if "%platf%"=="x64" (set vs_platf=amd64) & (set PGO=%dir%amd64-pgo)
|
|
||||||
rem Setup the environment
|
|
||||||
call "%dir%env.bat" %vs_platf%
|
|
||||||
|
|
||||||
|
|
||||||
rem build the instrumented version
|
|
||||||
msbuild "%dir%pcbuild.proj" %parallel% /t:Build /p:Configuration=PGInstrument /p:Platform=%platf% %1 %2 %3 %4 %5 %6 %7 %8 %9
|
|
||||||
|
|
||||||
rem remove .pyc files, .pgc files and execute the job
|
|
||||||
"%PGO%\python.exe" "%dir%rmpyc.py" %clrpath%
|
|
||||||
del "%PGO%\*.pgc"
|
|
||||||
"%PGO%\python.exe" %job%
|
|
||||||
|
|
||||||
rem build optimized version
|
|
||||||
msbuild "%dir%pcbuild.proj" %parallel% /t:Build /p:Configuration=PGUpdate /p:Platform=%platf% %1 %2 %3 %4 %5 %6 %7 %8 %9
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue