@@ -52,6 +52,42 @@ Release
5252 settings, though without PGO.
5353
5454
55+ Building Python using Clang/LLVM
56+ --------------------------------
57+
58+ See https://learn.microsoft.com/en-us/cpp/build/clang-support-msbuild?view=msvc-170
59+ how to install and use clang-cl bundled with Microsoft Visual Studio.
60+ You can use the IDE to switch to clang-cl for local development,
61+ but because this alters the *.vcxproj files, the recommended way is
62+ to use build.bat:
63+
64+ build.bat "/p:PlatformToolset=ClangCL" "/p:PreferredToolArchitecture=x64"
65+
66+ All other build.bat options remain to work as with MSVC, so this
67+ will create a 64bit release binary. PreferredToolArchitecture is needed,
68+ because msbuild by default selects the 32bit architecture of the toolset,
69+ which uses -m32 as the default target architecture.
70+
71+ You can also use a specific version of clang-cl downloaded from
72+ https://github.com/llvm/llvm-project/releases, e.g.
73+ clang+llvm-18.1.8-x86_64-pc-windows-msvc.tar.xz.
74+ Given you have extracted that to <my-clang-dir>, you can use it like so
75+ build.bat --pgo "/p:PlatformToolset=ClangCL" "/p:LLVMInstallDir=<my-clang-dir> "/p:LLVMToolsVersion=18"
76+
77+ Here, PreferredToolArchitecture is not needed, because this is a 64bit
78+ platform toolset, but LLVMToolsVersion has to be set accordingly.
79+ Setting the major version is enough, although you can be specific
80+ and use 18.1.8 in the above example, too.
81+
82+ Even --pgo works out of the box, except you do want to run the PGO task
83+ on a different host than the build host. In this case you must pass
84+ "/p:CLANG_PROFILE_PATH=<relative-path-to-instrumented-dir-on-remote-host>"
85+ in the PGInstrument step to make sure the profile data is generated
86+ into the instrumented directory when running the PGO task.
87+ Like in the MSVC case, after fetching (or manually copying) the instrumented
88+ folder back into your build tree, you can continue with the PGUpdate
89+ step with no further parameters.
90+
5591Building Python using the build.bat script
5692----------------------------------------------
5793
0 commit comments