msbuild and clang

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

msbuild and clang

Russell Wallace
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?

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: msbuild and clang

Hans Wennborg-2
On Mon, Jun 8, 2015 at 11:44 AM, Russell Wallace
<[hidden email]> 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/
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: msbuild and clang

Reid Kleckner-2
On Mon, Jun 8, 2015 at 11:55 AM, Hans Wennborg <[hidden email]> wrote:
On Mon, Jun 8, 2015 at 11:44 AM, Russell Wallace
<[hidden email]> 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:

Ultimately, you need to get -emit-llvm-bc down to clang -cc1. You'll probably need to play with -Xclang to make that happen.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: msbuild and clang

Régis Portalez
Msbuild provides you the exec task, which allows You to do as many thing as the command line does.

You can also write your own tasks in c# If you have some advanced requirements.

Cheers



De : [hidden email]
Envoyé : ‎08/‎06/‎2015 21:46
À : [hidden email]
Cc : [hidden email]
Objet : Re: [LLVMdev] msbuild and clang

On Mon, Jun 8, 2015 at 11:55 AM, Hans Wennborg <[hidden email]> wrote:
On Mon, Jun 8, 2015 at 11:44 AM, Russell Wallace
<[hidden email]> 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:

Ultimately, you need to get -emit-llvm-bc down to clang -cc1. You'll probably need to play with -Xclang to make that happen.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: msbuild and clang

Russell Wallace
In reply to this post by Hans Wennborg-2
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:


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?

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: msbuild and clang

Reid Kleckner-2
We haven't hit this yet. Can you disable tracker.exe? There's some XML attribute you can flip for it.

On Tue, Jun 9, 2015 at 6:10 AM, Russell Wallace <[hidden email]> wrote:
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:


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?

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: msbuild and clang

Russell Wallace
Right, tracker can be disabled with /p:TrackFileAccess=false and that gets over that hurdle. It's now failing with

fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86' 

I'm trying to specify 64-bit across the board; in particular, I'm using 64-bit clang, I have the environment variable set Platform=X64 and the argument /p:Platform="x64" to msbuild. Any idea why it's still talking about a 32-bit target machine type? The build with the Microsoft compiler was successfully 64-bit even without those options explicitly set.

On Tue, Jun 9, 2015 at 5:38 PM, Reid Kleckner <[hidden email]> wrote:
We haven't hit this yet. Can you disable tracker.exe? There's some XML attribute you can flip for it.

On Tue, Jun 9, 2015 at 6:10 AM, Russell Wallace <[hidden email]> wrote:
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:


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?

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev