Skip to content

GH-131473: tweak PreferredToolArchitecture for bundled clang-cl #131689

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

Merged
merged 2 commits into from
Mar 24, 2025

Conversation

chris-eibl
Copy link
Member

@chris-eibl chris-eibl commented Mar 24, 2025

This PR tweaks PreferredToolArchitecture so that the clang-cl bundled with VS can do PGO builds by just invoking

build.bat -p x64 --pgo "/p:PlatformToolset=ClangCL"

or

build.bat -p Win32 --pgo "/p:PlatformToolset=ClangCL"

without the need to add the appropriate PreferredToolArchitecture like

build.bat -p x64 --pgo "/p:PlatformToolset=ClangCL" "/p:PreferredToolArchitecture=x64"

or

build.bat -p Win32 --pgo "/p:PlatformToolset=ClangCL" "/p:PreferredToolArchitecture=x86"

Otherwise, the respective clang_rt.profile.lib is not found.

IMHO this is convenient for users who just want to use the bundled version of clang-cl.

Users who like to use a different version will have to use an appropriate bitness of clang-cl and point LLVMInstallDir to it.
No need for PreferredToolArchitecture in this case, anyway. Hence, the "tweaking" is only done when LLVMInstallDir is empty,
so that <VS install path>\Community\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.ClangCl.Common.props:

    <_DefaultLLVMInstallDir Condition="'$(_DefaultLLVMInstallDir)' == '' AND '$(PreferredToolArchitecture)' == 'arm64'">$(VsInstallRoot)\VC\Tools\Llvm\ARM64</_DefaultLLVMInstallDir>
    <_DefaultLLVMInstallDir Condition="'$(_DefaultLLVMInstallDir)' == '' AND '$(PreferredToolArchitecture)' == 'x64'">$(VsInstallRoot)\VC\Tools\Llvm\x64</_DefaultLLVMInstallDir>
    <_DefaultLLVMInstallDir Condition="'$(_DefaultLLVMInstallDir)' == '' AND '$(PreferredToolArchitecture)' != 'x64'">$(VsInstallRoot)\VC\Tools\Llvm</_DefaultLLVMInstallDir>
    <LLVMInstallDir Condition="'$(LLVMInstallDir)' == ''">$(_DefaultLLVMInstallDir)</LLVMInstallDir>

will set the the LLVMInstallDir to the correct bundled installation folder.

For details please see the issue.

@chris-eibl chris-eibl requested a review from a team as a code owner March 24, 2025 20:00
@zooba zooba merged commit c3b8d73 into python:main Mar 24, 2025
42 checks passed
@chris-eibl chris-eibl deleted the PreferredToolArchitecture branch March 25, 2025 05:32
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 1, 2025
… Studio bundled clang-cl (pythonGH-131689)

tweak PreferredToolArchitecture for bundled clang-cl
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
… Studio bundled clang-cl (pythonGH-131689)

tweak PreferredToolArchitecture for bundled clang-cl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants