From 390cc8a262468cd6381ef2193d1bc257a36d0917 Mon Sep 17 00:00:00 2001 From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com> Date: Mon, 23 Mar 2026 20:06:56 +0100 Subject: [PATCH] fix building the jit stencils on Windows when the interpreter is built with a different clang version. --- ...-03-23-20-06-35.gh-issue-146210.C01Rmq.rst | 2 ++ Tools/jit/_llvm.py | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Build/2026-03-23-20-06-35.gh-issue-146210.C01Rmq.rst diff --git a/Misc/NEWS.d/next/Build/2026-03-23-20-06-35.gh-issue-146210.C01Rmq.rst b/Misc/NEWS.d/next/Build/2026-03-23-20-06-35.gh-issue-146210.C01Rmq.rst new file mode 100644 index 00000000000000..ce59a9a3a571b4 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-03-23-20-06-35.gh-issue-146210.C01Rmq.rst @@ -0,0 +1,2 @@ +Fix building the jit stencils on Windows when the interpreter is built with +a different clang version. Patch by Chris Eibl. diff --git a/Tools/jit/_llvm.py b/Tools/jit/_llvm.py index 8b68c1e8636af7..215013aa213305 100644 --- a/Tools/jit/_llvm.py +++ b/Tools/jit/_llvm.py @@ -42,9 +42,26 @@ async def _run(tool: str, args: typing.Iterable[str], echo: bool = False) -> str async with _CORES: if echo: print(shlex.join(command)) + + if os.name == "nt": + env = os.environ.copy() + try: + # https://github.com/python/cpython/issues/146210 + # When the Python iterpreter is built with + # "/p:PlatformToolset=ClangCL" "/p:LLVMInstallDir=..."" + # msbuild populates the INCLUDE variable based on this + # clang version, which might be different to the one used + # for building the jit stencils. Mixing those include paths + # can cause mysterious build errors, so we remove the + # variable from the environment when invoking LLVM tools. + del env["INCLUDE"] + except KeyError: + pass + else: + env = None try: process = await asyncio.create_subprocess_exec( - *command, stdout=subprocess.PIPE + *command, stdout=subprocess.PIPE, env=env ) except FileNotFoundError: return None