Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e2c9adb

Browse files
committed
Closes #25348: Merge with 3.5
2 parents 9179c40 + bed30c3 commit e2c9adb

3 files changed

Lines changed: 56 additions & 53 deletions

File tree

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ Tests
581581
Build
582582
-----
583583

584+
- Issue #25348: Added ``--pgo`` and ``--pgo-job`` arguments to
585+
``PCbuild\build.bat`` for building with Profile-Guided Optimization. The
586+
old ``PCbuild\build_pgo.bat`` script is removed.
587+
584588
- Issue #25827: Add support for building with ICC to ``configure``, including
585589
a new ``--with-icc`` flag.
586590

PCbuild/build.bat

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ echo. -M Disable parallel build
2525
echo. -v Increased output messages
2626
echo. -k Attempt to kill any running Pythons before building (usually done
2727
echo. automatically by the pythoncore project)
28+
echo. --pgo Build with Profile-Guided Optimization. This flag
29+
echo. overrides -c and -d
30+
echo. --test-marker Enable the test marker within the build.
2831
echo.
2932
echo.Available flags to avoid building certain modules.
3033
echo.These flags have no effect if '-e' is not given:
@@ -38,7 +41,8 @@ echo. -p x64 ^| Win32
3841
echo. Set the platform (default: Win32)
3942
echo. -t Build ^| Rebuild ^| Clean ^| CleanAll
4043
echo. Set the target manually
41-
echo. --test-marker Enable the test marker within the build.
44+
echo. --pgo-job The job to use for PGO training; implies --pgo
45+
echo. (default: "-m test --pgo")
4246
exit /b 127
4347

4448
:Run
@@ -51,6 +55,12 @@ set dir=%~dp0
5155
set parallel=/m
5256
set verbose=/nologo /v:m
5357
set kill=
58+
set do_pgo=
59+
set pgo_job=-m test --pgo
60+
set on_64_bit=true
61+
62+
rem This may not be 100% accurate, but close enough.
63+
if "%ProgramFiles(x86)%"=="" (set on_64_bit=false)
5464

5565
:CheckOpts
5666
if "%~1"=="-h" goto Usage
@@ -63,6 +73,8 @@ if "%~1"=="-m" (set parallel=/m) & shift & goto CheckOpts
6373
if "%~1"=="-M" (set parallel=) & shift & goto CheckOpts
6474
if "%~1"=="-v" (set verbose=/v:n) & shift & goto CheckOpts
6575
if "%~1"=="-k" (set kill=true) & shift & goto CheckOpts
76+
if "%~1"=="--pgo" (set do_pgo=true) & shift & goto CheckOpts
77+
if "%~1"=="--pgo-job" (set do_pgo=true) & (set pgo_job=%~2) & shift & shift & goto CheckOpts
6678
if "%~1"=="--test-marker" (set UseTestMarker=true) & shift & goto CheckOpts
6779
if "%~1"=="-V" shift & goto Version
6880
rem These use the actual property names used by MSBuild. We could just let
@@ -78,15 +90,49 @@ if "%IncludeTkinter%"=="" set IncludeTkinter=true
7890

7991
if "%IncludeExternals%"=="true" call "%dir%get_externals.bat"
8092

81-
if "%platf%"=="x64" (set vs_platf=x86_amd64)
93+
if "%platf%"=="x64" (
94+
if "%on_64_bit%"=="true" (
95+
rem This ought to always be correct these days...
96+
set vs_platf=amd64
97+
) else (
98+
if "%do_pgo%"=="true" (
99+
echo.ERROR: Cannot cross-compile with PGO
100+
echo. 32bit operating system detected, if this is incorrect,
101+
echo. make sure the ProgramFiles(x86^) environment variable is set
102+
exit /b 1
103+
)
104+
set vs_platf=x86_amd64
105+
)
106+
)
82107

83108
rem Setup the environment
84109
call "%dir%env.bat" %vs_platf% >nul
85110

86-
if "%kill%"=="true" (
87-
msbuild /v:m /nologo /target:KillPython "%dir%\pythoncore.vcxproj" /p:Configuration=%conf% /p:Platform=%platf% /p:KillPython=true
111+
if "%kill%"=="true" call :Kill
112+
113+
if "%do_pgo%"=="true" (
114+
set conf=PGInstrument
115+
call :Build
116+
del /s "%dir%\*.pgc"
117+
del /s "%dir%\..\Lib\*.pyc"
118+
echo on
119+
call "%dir%\..\python.bat" %pgo_job%
120+
@echo off
121+
call :Kill
122+
set conf=PGUpdate
88123
)
124+
goto Build
89125

126+
:Kill
127+
echo on
128+
msbuild "%dir%\pythoncore.vcxproj" /t:KillPython %verbose%^
129+
/p:Configuration=%conf% /p:Platform=%platf%^
130+
/p:KillPython=true
131+
132+
@echo off
133+
goto :eof
134+
135+
:Build
90136
rem Call on MSBuild to do the work, echo the command.
91137
rem Passing %1-9 is not the preferred option, but argument parsing in
92138
rem batch is, shall we say, "lackluster"
@@ -98,7 +144,8 @@ msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
98144
/p:UseTestMarker=%UseTestMarker%^
99145
%1 %2 %3 %4 %5 %6 %7 %8 %9
100146

101-
@goto :eof
147+
@echo off
148+
goto :eof
102149

103150
:Version
104151
rem Display the current build version information

PCbuild/build_pgo.bat

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)