====== Python のビルド ====== ソースコード: [[https://github.com/python/cpython|GitHub - python/cpython: The Python programming language]]\\ ===== Visual Studio 2019 ===== > git clone -b v3.7.4 https://github.com/python/cpython.git Python-3.7.4 > cd Python-3.7.4 > PCbuild\build.bat -e -d -p x64 > PCbuild\amd64\python_d.exe Python 3.7.4 (tags/v3.7.4-dirty:e09359112e, Aug 15 2019, 11:50:09) [MSC v.1922 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import ssl >>> ===== Visual Studio 2019 (clang-cl) ===== 2019/08/15 現在、Visual Studio 2019 の clang-cl.exe ではビルドエラーが発生して Python のビルドはできない。\\ > PCbuild\build.bat -e -d -p x64 Using py -3.7 (found 3.7 with py.exe) Fetching external libraries... bzip2-1.0.6 already exists, skipping. sqlite-3.28.0.0 already exists, skipping. xz-5.2.2 already exists, skipping. zlib-1.2.11 already exists, skipping. Fetching external binaries... openssl-bin-1.1.1c already exists, skipping. tcltk-8.6.9.0 already exists, skipping. Finished. Using "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" (found in the PATH) c:\Users\tomoyan\.PythonInstaller\build\Python-3.7.4>"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" "c:\Users\tomoyan\.PythonInstaller\build\Python-3.7.4\PCbuild\pcbuild.proj" /t:Build /m /nologo /v:m /p:Configuration="Release - Clang" /p:Platform=x64 /p:IncludeExternals=true /p:IncludeSSL=true /p:IncludeTkinter=true /p:UseTestMarker= /p:GIT="C:\Program Files\Git\cmd\git.exe" /p:LLVMInstallDir="C:\Program Files\\LLVM" Killing any running python.exe instances... Getting build info from "C:\Program Files\Git\cmd\git.exe" Building tags/v3.7.4-dirty:e09359112e tags/v3.7.4^0 c:\Users\tomoyan\.PythonInstaller\build\Python-3.7.4\PCbuild\pythoncore.vcxproj(500,5): warning : Toolset ClangCL is no t used for official builds. Your build may have errors or incompatibilities. In file included from :334: (10,9): warning : '_M_X64' macro redefined [-Wmacro-redefined] [c:\Users\tomoyan\.PythonInstaller\build\ Python-3.7.4\PCbuild\pythoncore.vcxproj] (328,9): message : previous definition is here [c:\Users\tomoyan\.PythonInstaller\build\Python-3.7.4\PCbuild \pythoncore.vcxproj] (328,9): message : In file included from ..\Modules\_tracemalloc.c:1: [c:\Users\tomoyan\.PythonInstaller\buil d\Python-3.7.4\PCbuild\pythoncore.vcxproj] (328,9): message : In file included from c:\Users\tomoyan\.PythonInstaller\build\Python-3.7.4\Include\Python. h:87: [c:\Users\tomoyan\.PythonInstaller\build\Python-3.7.4\PCbuild\pythoncore.vcxproj] c:\Users\tomoyan\.PythonInstaller\build\Python-3.7.4\Include/pytime.h(123,59): warning : declaration of 'struct timeva l' will not be visible outside of this function [-Wvisibility] [c:\Users\tomoyan\.PythonInstaller\build\Python-3.7.4\PC build\pythoncore.vcxproj] c:\Users\tomoyan\.PythonInstaller\build\Python-3.7.4\Include/pytime.h(130,12): warning : declaration of 'struct timeva l' will not be visible outside of this function [-Wvisibility] [c:\Users\tomoyan\.PythonInstaller\build\Python-3.7.4\PC build\pythoncore.vcxproj] c:\Users\tomoyan\.PythonInstaller\build\Python-3.7.4\Include/pytime.h(135,12): warning : declaration of 'struct timeva l' will not be visible outside of this function [-Wvisibility] [c:\Users\tomoyan\.PythonInstaller\build\Python-3.7.4\PC build\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(82,9): error : declaration of anonymous struct must be a definition [c:\Users\tomoyan\.Pytho nInstaller\build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(82,1): warning : typedef requires a name [-Wmissing-declarations] [c:\Users\tomoyan\.PythonI nstaller\build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(95,9): warning : #pragma pack(pop, ...) failed: stack empty [-Wignored-pragmas] [c:\Users\to moyan\.PythonInstaller\build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(102,5): error : unknown type name 'frame_t' [c:\Users\tomoyan\.PythonInstaller\build\Python- 3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(322,11): error : unknown type name 'frame_t'; did you mean 'trace_t'? [c:\Users\tomoyan\.Pyt honInstaller\build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(122,3): message : 'trace_t' declared here [c:\Users\tomoyan\.PythonInstaller\build\Python-3. 7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(335,21): error : no member named 'lineno' in 'trace_t' [c:\Users\tomoyan\.PythonInstaller\bu ild\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(335,39): error : no member named 'lineno' in 'trace_t' [c:\Users\tomoyan\.PythonInstaller\bu ild\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(338,21): error : no member named 'filename' in 'trace_t' [c:\Users\tomoyan\.PythonInstaller\ build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(338,41): error : no member named 'filename' in 'trace_t' [c:\Users\tomoyan\.PythonInstaller\ build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(348,47): error : unknown type name 'frame_t'; did you mean 'trace_t'? [c:\Users\tomoyan\.Pyt honInstaller\build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(122,3): message : 'trace_t' declared here [c:\Users\tomoyan\.PythonInstaller\build\Python-3. 7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(355,12): error : no member named 'filename' in 'trace_t' [c:\Users\tomoyan\.PythonInstaller\ build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(359,12): error : no member named 'lineno' in 'trace_t' [c:\Users\tomoyan\.PythonInstaller\bu ild\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(415,12): error : no member named 'filename' in 'trace_t' [c:\Users\tomoyan\.PythonInstaller\ build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(426,5): error : unknown type name 'frame_t'; did you mean 'trace_t'? [c:\Users\tomoyan\.Pyth onInstaller\build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(122,3): message : 'trace_t' declared here [c:\Users\tomoyan\.PythonInstaller\build\Python-3. 7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(431,46): error : no member named 'filename' in 'trace_t' [c:\Users\tomoyan\.PythonInstaller\ build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(432,33): error : no member named 'lineno' in 'trace_t' [c:\Users\tomoyan\.PythonInstaller\bu ild\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(493,26): error : use of undeclared identifier 'frame_t' [c:\Users\tomoyan\.PythonInstaller\b uild\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(106,39): message : expanded from macro 'TRACEBACK_SIZE' [c:\Users\tomoyan\.PythonInstaller\b uild\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(1069,40): error : use of undeclared identifier 'frame_t' [c:\Users\tomoyan\.PythonInstaller\ build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(109,61): message : expanded from macro 'MAX_NFRAME' [c:\Users\tomoyan\.PythonInstaller\build \Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(1072,27): error : use of undeclared identifier 'frame_t' [c:\Users\tomoyan\.PythonInstaller\ build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(109,61): message : expanded from macro 'MAX_NFRAME' [c:\Users\tomoyan\.PythonInstaller\build \Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(1089,12): error : use of undeclared identifier 'frame_t' [c:\Users\tomoyan\.PythonInstaller\ build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(106,39): message : expanded from macro 'TRACEBACK_SIZE' [c:\Users\tomoyan\.PythonInstaller\b uild\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(1189,19): error : unknown type name 'frame_t'; did you mean 'trace_t'? [c:\Users\tomoyan\.Py thonInstaller\build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(122,3): message : 'trace_t' declared here [c:\Users\tomoyan\.PythonInstaller\build\Python-3. 7.4\PCbuild\pythoncore.vcxproj] ..\Modules\_tracemalloc.c(122,3): message : fatal error: too many errors emitted, stopping now [-ferror-limit=] [c:\Use rs\tomoyan\.PythonInstaller\build\Python-3.7.4\PCbuild\pythoncore.vcxproj] ===== 参考文献 ===== [[https://devguide.python.org/clang/|28. Dynamic Analysis with Clang — Python Developer's Guide]]\\ [[tw>tomoyan596/status/1405696106319683584|scoopのPythonは... $ python -VV Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] Visual Studio 2019 Update 8 VC++ Version 14.28でビルドされていいますけど、これは本家も同じなのですかねぇ🤔 バイナリ互換性が保証されてるからだとは思いますけど... / Twitter]]\\ [[tw>tomoyan596/status/1405705072890187780|PythonをClangコンパイルしてLLVMで最適化するより、PythonコードにNumba JITをかまして生成されるマシンコードをLLVMで最適化した方が良さげですねぇ🥰 / Twitter]]\\ [[https://pythondev.readthedocs.io/windows.html|Compile CPython on Windows — Python Development 1.0 documentation]]\\ [[wpjp>Clang|Clang - Wikipedia]]\\