Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python does not support standalone MSVC v143 (VS 2022) Build Tools #89974

Closed
thatbirdguythatuknownot mannequin opened this issue Nov 16, 2021 · 10 comments
Closed

Python does not support standalone MSVC v143 (VS 2022) Build Tools #89974

thatbirdguythatuknownot mannequin opened this issue Nov 16, 2021 · 10 comments
Labels
3.11 only security fixes build The build process and cross-build OS-windows

Comments

@thatbirdguythatuknownot
Copy link
Mannequin

BPO 45816
Nosy @pfmoore, @tjguk, @zware, @zooba, @animalize, @kumaraditya303, @thatbirdguythatuknownot
PRs
  • gh-89974: Support building with VS 2022 #29577
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-12-03.19:48:45.031>
    created_at = <Date 2021-11-16.14:35:04.395>
    labels = ['build', 'OS-windows', '3.11']
    title = 'Python does not support standalone MSVC v143 (VS 2022) Build Tools'
    updated_at = <Date 2021-12-03.19:48:45.031>
    user = 'https://github.com/thatbirdguythatuknownot'

    bugs.python.org fields:

    activity = <Date 2021-12-03.19:48:45.031>
    actor = 'steve.dower'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-12-03.19:48:45.031>
    closer = 'steve.dower'
    components = ['Build', 'Windows']
    creation = <Date 2021-11-16.14:35:04.395>
    creator = 'Crowthebird'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45816
    keywords = ['patch']
    message_count = 10.0
    messages = ['406405', '406411', '406464', '406475', '406518', '406635', '407356', '407382', '407384', '407599']
    nosy_count = 7.0
    nosy_names = ['paul.moore', 'tim.golden', 'zach.ware', 'steve.dower', 'malin', 'kumaraditya', 'Crowthebird']
    pr_nums = ['29577']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue45816'
    versions = ['Python 3.11']

    @thatbirdguythatuknownot
    Copy link
    Mannequin Author

    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/

    @thatbirdguythatuknownot thatbirdguythatuknownot mannequin added 3.11 only security fixes build The build process and cross-build labels Nov 16, 2021
    @thatbirdguythatuknownot
    Copy link
    Mannequin Author

    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/

    @thatbirdguythatuknownot thatbirdguythatuknownot mannequin changed the title Python does not support building with Visual Studio 2022 Python does not support standalone MSVC v143 (VS 2022) Build Tools Nov 16, 2021
    @thatbirdguythatuknownot thatbirdguythatuknownot mannequin changed the title Python does not support building with Visual Studio 2022 Python does not support standalone MSVC v143 (VS 2022) Build Tools Nov 16, 2021
    @animalize
    Copy link
    Mannequin

    animalize mannequin commented Nov 17, 2021

    There are 5 link errors when building the PGO build.
    Command: build --pgo

    @zooba
    Copy link
    Member

    zooba commented Nov 17, 2021

    Could you post the errors?

    @animalize
    Copy link
    Mannequin

    animalize mannequin commented Nov 18, 2021

    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]

    ...

    @zooba
    Copy link
    Member

    zooba commented Nov 20, 2021

    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?

    @kumaraditya303
    Copy link
    Contributor

    I have installed VS 2022 with v143 of MSVC.
    I get this error when compiling

    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)

    @zooba
    Copy link
    Member

    zooba commented Nov 30, 2021

    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.

    @kumaraditya303
    Copy link
    Contributor

    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\>


    @zooba
    Copy link
    Member

    zooba commented Dec 3, 2021

    New changeset d930170 by Crowthebird in branch 'main':
    bpo-45816: Support building with VS 2022 (v143 toolset) on Windows (GH-29577)
    d930170

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes build The build process and cross-build OS-windows
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants