I'm trying to compile some large programs with clang on Windows (with a view to compiling to bit code and then running some whole program optimisations on the bit code). Take for example the Python 2.7 interpreter: As is typically the case, the usual build procedure involves running msbuild which invokes the Microsoft compiler. The most obvious procedure would then be to substitute clang-cl.exe for cl.exe and thereby take advantage of msbuild supplying correct flags, include paths et cetera. What's the recommended procedure for this - rename clang-cl.exe to cl.exe and put it earlier in your path? clang-cl requires some extra flags to get it to generate bit code instead of object files - what's the recommended way to get that when msbuild doesn't by default supply such flags? Are there any existing tutorials or anything describing techniques for this? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150608/f3001031/attachment.html>
On Mon, Jun 8, 2015 at 11:44 AM, Russell Wallace <russell.wallace at gmail.com> wrote:> I'm trying to compile some large programs with clang on Windows (with a view > to compiling to bit code and then running some whole program optimisations > on the bit code). > > Take for example the Python 2.7 interpreter: > > As is typically the case, the usual build procedure involves running msbuild > which invokes the Microsoft compiler. > > The most obvious procedure would then be to substitute clang-cl.exe for > cl.exe and thereby take advantage of msbuild supplying correct flags, > include paths et cetera. > > What's the recommended procedure for this - rename clang-cl.exe to cl.exe > and put it earlier in your path?Yes, that's how Clang's Visual Studio integration currently works.> clang-cl requires some extra flags to get it to generate bit code instead of > object files - what's the recommended way to get that when msbuild doesn't > by default supply such flags?I'm not that familiar with msbuild, but in Visual Studio you can add extra flags for your project under Configuration Properties -> C/C++ -> Command Line.> Are there any existing tutorials or anything describing techniques for this?I don't know of any tutorials, but did you try installing Clang via the release packages [1] or weekly snapshots [2]? That will install Clang as a "Platform Toolset" that you can just select from inside Visual Studio. That's generally the easiest way to try it out. Cheers, Hans [1]. http://llvm.org/releases/download.html [2]. http://llvm.org/builds/
On Mon, Jun 8, 2015 at 11:55 AM, Hans Wennborg <hans at chromium.org> wrote:> On Mon, Jun 8, 2015 at 11:44 AM, Russell Wallace > <russell.wallace at gmail.com> wrote: > > I'm trying to compile some large programs with clang on Windows (with a > view > > to compiling to bit code and then running some whole program > optimisations > > on the bit code). > > > > Take for example the Python 2.7 interpreter: > > > > As is typically the case, the usual build procedure involves running > msbuild > > which invokes the Microsoft compiler. > > > > The most obvious procedure would then be to substitute clang-cl.exe for > > cl.exe and thereby take advantage of msbuild supplying correct flags, > > include paths et cetera. > > > > What's the recommended procedure for this - rename clang-cl.exe to cl.exe > > and put it earlier in your path? > > Yes, that's how Clang's Visual Studio integration currently works. > > > clang-cl requires some extra flags to get it to generate bit code > instead of > > object files - what's the recommended way to get that when msbuild > doesn't > > by default supply such flags? > > I'm not that familiar with msbuild, but in Visual Studio you can add > extra flags for your project under Configuration Properties -> C/C++ > -> Command Line.If you are feeling particularly evil and hackish, you can use the undocumented CCC_OVERRIDE_OPTIONS environment variable: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?view=markup#l98 Ultimately, you need to get -emit-llvm-bc down to clang -cc1. You'll probably need to play with -Xclang to make that happen. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150608/7d6c643f/attachment.html>
Okay, so trying a straight compile of the Python interpreter with clang-cl, I used the following commands: cd \python-2.7.10\pcbuild copy C:\llvm\build\Release\bin\clang-cl.exe cl.exe 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 msbuild /p:Configuration=Release /v:diag /fileLogger pcbuild.sln (The second line is the one that substitutes clang-cl - with that removed, everything is successful) The build failed with the following error message: Tracking command: C:\Program Files (x86)\MSBuild\12.0\bin\Tracker.exe /d "C:\Program Files (x86)\MSBuild\12.0\bin\FileTracker.dll" /i C:\Python-2.7.10\PCbuild\x64-temp-Release\kill_python\kill_python.tlog /r C:\PYTHON-2.7.10\PCBUILD\KILL_PYTHON.C /b MSBuildConsole_CancelEvent306536dcec844c0c97517539ced8ed5d /c C:\Python-2.7.10\PCbuild\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 TRACKER : error TRK0002: Failed to execute command: "C:\Python-2.7.10\PCbuild\CL.exe @C:\Users\w\AppData\Local\Temp\tmp4af7576aa6b5441391fa4aea101d878d.rsp". The operation identifier is not valid. [C:\Python-2.7.10\PCbuild\kill_python.vcxproj] I'm not quite sure what to make of this, but a Google search for 'the operation identifier is not valid' turned up this: https://connect.microsoft.com/VisualStudio/feedback/details/714228/visual-studio-11-various-problems-caused-by-its-use-of-3-bit-compiler-even-when-installed-on-64-bit-windows Which is not actually the same thing, but suggests that error message is msbuild's way of saying something in the toolchain is incompatible with something else. Any idea what's wrong here? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150609/10b01e65/attachment.html>