Building Python with clang-cl

Taking another shot at building Python with clang-cl, this time going by the SVN version, using the following commands

cd \python-2.7.10\pcbuild
rd /q /s amd64
rd /q /s win32-temp-debug
rd /q /s win32-temp-release
rd /q /s x64-temp-debug
rd /q /s x64-temp-release
set Platform=X64
msbuild /t:clean,build /p:Configuration=Release /p:CLToolExe=clang-cl.exe /p:CLToolPath=c:\llvm-svn\build\Release\bin\ /p:TrackFileAccess=false /p:Platform=“x64” /fileLogger pcbuild.sln

It seems to generate an invalid object file from one particular source file, kill_python.c. This is the output when compiling that file

c:\llvm-svn\build\Release\bin\clang-cl.exe /c /I…\Include /I…\PC /Zi /nologo /W3 /WX- /O2 /Ob1 /Oi /GL /D _WIN64 /D _M_X64 /D NDEBUG /D _WIN32 /GF /Gm- /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Fo"C:\Python-2.7.10\PCbuild\x64-temp-Release\kill_python\" /Fd"C:\Python-2.7.10\PCbuild\x64-temp-Release\kill_python\vc120.pdb" /Gd /TC /errorReport:queue /USECL:MS_OPTERON /GS- kill_python.c
clang-cl.exe : warning : argument unused during compilation: ‘/Gm-’ [C:\Python-2.7.10\PCbuild\kill_python.vcxproj]
clang-cl.exe : warning : argument unused during compilation: ‘/GS’ [C:\Python-2.7.10\PCbuild\kill_python.vcxproj]
In file included from :299:
(6,12): warning : extra tokens at end of #undef directive [-Wextra-tokens] [C:\Python-2.7.10\PCbuild\kill_python.vcxproj]
#undef SECL:MS_OPTERON
^
//
kill_python.c(46,60): warning : format specifies type ‘int’ but the argument has type ‘DWORD’ (aka ‘unsigned long’) [-Wformat] [C:\Python-2.7.10\PCbuild\kill_python.vcxproj]
printf(“CreateToolhelp32Snapshot[1] failed: %d\n”, GetLastError());
~~ ^~~~~~~~~~~~~~
%lu
kill_python.c(51,50): warning : format specifies type ‘int’ but the argument has type ‘DWORD’ (aka ‘unsigned long’) [-Wformat] [C:\Python-2.7.10\PCbuild\kill_python.vcxproj]
printf(“Module32FirstW[1] failed: %d\n”, GetLastError());
~~ ^~~~~~~~~~~~~~
%lu
kill_python.c(73,9): warning : comparison of array ‘path’ equal to a null pointer is always false [-Wtautological-pointer-compare] [C:\Python-2.7.10\PCbuild\kill_python.vcxproj]
if (path == NULL) {
^~~~ ~~~~
kill_python.c(93,60): warning : format specifies type ‘int’ but the argument has type ‘DWORD’ (aka ‘unsigned long’) [-Wformat] [C:\Python-2.7.10\PCbuild\kill_python.vcxproj]
printf(“CreateToolhelp32Snapshot[2] failed: %d\n”, GetLastError());
~~ ^~~~~~~~~~~~~~
%lu
kill_python.c(98,48): warning : format specifies type ‘int’ but the argument has type ‘DWORD’ (aka ‘unsigned long’) [-Wformat] [C:\Python-2.7.10\PCbuild\kill_python.vcxproj]
printf(“Process32FirstW failed: %d\n”, GetLastError());
~~ ^~~~~~~~~~~~~~
%lu
kill_python.c(132,54): warning : format specifies type ‘int’ but the argument has type ‘DWORD’ (aka ‘unsigned long’) [-Wformat] [C:\Python-2.7.10\PCbuild\kill_python.vcxproj]
printf(“Module32FirstW[2] failed: %d\n”, GetLastError());
~~ ^~~~~~~~~~~~~~
%lu
kill_python.c(150,52): warning : format specifies type ‘int’ but the argument has type ‘DWORD’ (aka ‘unsigned long’) [-Wformat] [C:\Python-2.7.10\PCbuild\kill_python.vcxproj]
printf(“OpenProcess failed: %d\n”, GetLastError());
~~ ^~~~~~~~~~~~~~
%lu
kill_python.c(157,57): warning : format specifies type ‘int’ but the argument has type ‘DWORD’ (aka ‘unsigned long’) [-Wformat] [C:\Python-2.7.10\PCbuild\kill_python.vcxproj]
printf(“TerminateProcess failed: %d\n”, GetLastError());
~~ ^~~~~~~~~~~~~~
%lu
9 warnings generated.

And the link error message

C:\Python-2.7.10\PCbuild\x64-temp-Release\kill_python\kill_python.obj : fatal error LNK1107: invalid or corrupt file: cannot read at 0x1A44 [C:\Python-2.7.10\PCbuild\kill_python.vcxproj]

I tried dumpbin on kill_python.obj, and dumpbin agrees it’s an invalid object file.