chris-eibl · GitHub

Bug report

Bug description:

When using https://github.com/llvm/llvm-project/releases/tag/llvmorg-22.1.1 and

build.bat  --experimental-jit-off -p x64 "/p:PlatformToolset=ClangCL" "/p:LLVMInstallDir=D:\dev\cpython\externals\llvm-22.1.1" "/p:LLVMToolsVersion=22"

to build the interpreter, building the stencils fails:

C:\Program Files\Microsoft Visual Studio\18\Professional\VC\Tools\MSVC\14.50.35717\include\vcruntime.h(399,51): error G58EA42A4: unknown type name 'uintptr_t'; did you mean 'intptr_t'? [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Professional\VC\Tools\MSVC\14.50.35717\include\vcruntime.h(400,67): error G58EA42A4: unknown type name 'uintptr_t'; did you mean 'intptr_t'? [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Professional\VC\Tools\MSVC\14.50.35717\include\vcruntime.h(404,8): error G58EA42A4: unknown type name 'uintptr_t'; did you mean 'intptr_t'? [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt.h(380,16): error G58EA42A4: unknown type name 'uintptr_t'; did you mean 'intptr_t'? [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h(277,49): error G58EA42A4: unknown type name 'va_list' [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h(286,49): error G58EA42A4: unknown type name 'va_list' [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h(295,49): error G58EA42A4: unknown type name 'va_list' [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h(303,49): error G58EA42A4: unknown type name 'va_list' [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h(317,39): error G58EA42A4: unknown type name 'va_list' [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h(332,49): error G58EA42A4: unknown type name 'va_list' [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h(348,43): error G58EA42A4: unknown type name 'va_list' [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h(365,49): error G58EA42A4: unknown type name 'va_list' [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h(379,39): error G58EA42A4: unknown type name 'va_list' [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h(393,49): error G58EA42A4: unknown type name 'va_list' [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h(406,39): error G58EA42A4: unknown type name 'va_list' [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h(420,49): error G58EA42A4: unknown type name 'va_list' [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h(435,43): error G58EA42A4: unknown type name 'va_list' [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h(451,49): error G58EA42A4: unknown type name 'va_list' [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h(464,39): error G58EA42A4: unknown type name 'va_list' [D:\dev\cpython\PCbuild\pythoncore.vcxproj]
EXEC : fatal error : too many errors emitted, stopping now [-ferror-limit=] [D:\dev\cpython\PCbuild\pythoncore.vcxproj]

This is because during building the interpreter, the respective include path of clang is smuggled into the INCLUDE environment variable1:

INCLUDE=D:\dev\cpython\externals\llvm-22.1.1\llvm-21.1.4.0\lib\clang\22\include;<other include paths>

and the clang

_LLVM_VERSION = "21"
_EXTERNALS_LLVM_TAG = "llvm-21.1.4.0"

used to build the jit stencils picks it up. Since these are two different versions, the hiccup is no surprise (but that it manifests in errors in vcruntime and ucrt is).

Instead of tying the two LLVM versions together like discussed in #138452, I now rather think it would be better to just empty2 the INCLUDE variable when running Tools\jit\build.py. Either by adding EnvironmentVariables="INCLUDE=" to

<Exec Command='$(PythonForBuild) "$(PySourcePath)Tools\jit\build.py" $(JITArgs) --output-dir "$(GeneratedJitStencilsDir)" --pyconfig-dir "$(PySourcePath)PC"'/>

or by adapting Tools\jit\build.py.

@zooba, @Fidget-Spinner, @savannahostrowski: WDYT? I'd happily create a PR if this seems the correct approach to you.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs

Footnotes

  1. I think `MSBuild support for LLVM (clang-cl) toolset does this

  2. I've tested locally that this fixes building the jit stencils.

Read the original on github.com ↗