classification
Title: Python does not support standalone MSVC v143 (VS 2022) Build Tools
Type: Stage: patch review
Components: Build, Windows Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: February291948, kumaraditya303, malin, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords: patch

Created on 2021-11-16 14:35 by February291948, last changed 2021-11-30 16:42 by kumaraditya303.

Pull Requests
URL Status Linked Edit
PR 29577 open February291948, 2021-11-16 14:42
Messages (9)
msg406405 - (view) Author: theeshallnotknowethme (February291948) * Date: 2021-11-16 14:35
Python does not support building with Visual Studio 2022, which is the latest officially released stable version [1].

[1] https://devblogs.microsoft.com/visualstudio/visual-studio-2022-now-available/
msg406411 - (view) Author: theeshallnotknowethme (February291948) * Date: 2021-11-16 15:30
Rephrasing: Python does not support building with standalone MSVC v143 Build Tools, which is the version of MS Build Tools under Visual Studio 2022 (version 17.0). Visual Studio 2022 is the latest stable release of Visual Studio [1].

[1] https://devblogs.microsoft.com/visualstudio/visual-studio-2022-now-available/
msg406464 - (view) Author: Ma Lin (malin) * Date: 2021-11-17 10:07
There are 5 link errors when building the PGO build.
Command: build --pgo
msg406475 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-11-17 16:17
Could you post the errors?
msg406518 - (view) Author: Ma Lin (malin) * Date: 2021-11-18 04:20
They are LNK1268 error:

LINK : fatal error LNK1268: inconsistent option 'pdbthreads:5' specified with /USEPROFILE but not with /GENPROFILE [e:\dev\cpython\PCbuild\_queue.vcx
proj]

LINK : fatal error LNK1268: inconsistent option 'pdbthreads:1' specified with /USEPROFILE but not with /GENPROFILE [e:\dev\cpython\PCbuild\_asyncio.v
cxproj]

LINK : fatal error LNK1268: inconsistent option 'pdbthreads:5' specified with /USEPROFILE but not with /GENPROFILE [e:\dev\cpython\PCbuild\_elementtr
ee.vcxproj]

LINK : fatal error LNK1268: inconsistent option 'cgthreads:8' specified with /USEPROFILE but not with /GENPROFILE [e:\dev\cpython\PCbuild\_hashlib.vc
xproj]

...
msg406635 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-11-20 00:57
Looks like the fix for those errors is to specify the arguments to the linker in PCbuild/pyproject.props

 <AdditionalOptions Condition="$(Configuration) != 'Debug'">/OPT:REF,NOICF /CGTHREADS:1 /PDBTHREADS:1 %(AdditionalOptions)</AdditionalOptions>

I don't particularly know what a good number of threads is for this. One seems safe, but maybe we can get faster builds with more?
msg407356 - (view) Author: Kumar Aditya (kumaraditya303) * Date: 2021-11-30 09:31
I have installed VS 2022 with v143 of MSVC.
I get this error when compiling 

```console
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.ta 
rgets(436,5): error MSB8020: The build tools for Visual Studio 2019 (Platform Toolset = 'v142') cannot  
be found. To build using the v142 build tools, please install Visual Studio 2019 build tools.  Alternat 
ively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click  
the solution, and then selecting "Retarget solution". [D:\cpython\PCbuild\_freeze_module.vcxproj]       
    0 Warning(s)
    1 Error(s)
```
msg407382 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-11-30 15:39
An easy workaround for people encountering this is to set the PlatformToolset environment variable to v143 before building:

$env:PlatformToolset = "v143"

(or in CMD: set PlatformToolset=v143)

Alternatively, you should be able to install the v142 toolset through VS 2022. For now, it's still the official toolset, though we'll definitely move to v143 before 3.11.
msg407384 - (view) Author: Kumar Aditya (kumaraditya303) * Date: 2021-11-30 16:42
Thanks Steve, installing v142 is indeed my current workaround but would be
great to support v143 as it is the latest version.

On Tue, Nov 30, 2021, 21:09 Steve Dower <report@bugs.python.org> wrote:

>
> Steve Dower <steve.dower@python.org> added the comment:
>
> An easy workaround for people encountering this is to set the
> PlatformToolset environment variable to v143 before building:
>
> $env:PlatformToolset = "v143"
>
> (or in CMD: set PlatformToolset=v143)
>
> Alternatively, you should be able to install the v142 toolset through VS
> 2022. For now, it's still the official toolset, though we'll definitely
> move to v143 before 3.11.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue45816>
> _______________________________________
>
History
Date User Action Args
2021-11-30 16:42:42kumaraditya303setmessages: + msg407384
2021-11-30 15:39:25steve.dowersetmessages: + msg407382
2021-11-30 09:31:06kumaraditya303setnosy: + kumaraditya303
messages: + msg407356
2021-11-20 00:57:16steve.dowersetmessages: + msg406635
2021-11-18 04:20:36malinsetmessages: + msg406518
2021-11-17 16:17:03steve.dowersetmessages: + msg406475
2021-11-17 10:07:30malinsetnosy: + malin
messages: + msg406464
2021-11-16 15:30:18February291948settitle: Python does not support building with Visual Studio 2022 -> Python does not support standalone MSVC v143 (VS 2022) Build Tools
nosy: + paul.moore, tim.golden, zach.ware, steve.dower

messages: + msg406411

components: + Windows
2021-11-16 14:42:29February291948setkeywords: + patch
stage: patch review
pull_requests: + pull_request27821
2021-11-16 14:35:04February291948create