Compiling clang/LLVM on win results in compile errors - how to fix?

Tag: cmake , clang , llvm , emscripten , asm.js Author: liushuigeng Date: 2014-02-01

I've stumbled upon problems installing clang/LLVM on my Win 7 64-bit machine for setting up Emscripten in my Visual Studio 2010 Setup. I was following the official howto from Emscripten at and stumbled into problems regarding the needed compilation of clang/LLVM.

svn co llvm

cd llvm\tools

svn co clang

cd ..\\..

mkdir build

cmake -G "Visual Studio 10" ..\llvm

msbuild LLVM.sln /p:Configuration=Release

The result is alot of errors similiar to this one:

CUSTOMBUILD : error : error reading '10.0\VC\bin\llvm\tools\clang\test\Index\ pch-opaque-value.cpp' [c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\b in\build\tools\clang\test\check-clang.vcxproj] CUSTOMBUILD : error : error reading '10.0\VC\bin\llvm\tools\clang\test\Index\ pch-with-errors.m' [c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\ build\tools\clang\test\check-clang.vcxproj]

Obviously, a path starting at '10.0\VC...' is totally invalid.. its missing the 'C:\Program Files (x86)\Microsoft Visual Studio ' in front.. (I've checked there is a file like that in test\Index\ - it is!

My question is: how do I fix that ? a) Can I setup an additional include path that is like 'C:\folder\MS Visual ' (including space) ?

What I have tried so far: a) Doing it from Visual Studio Prompt and normal Prompt. Using default and custom location. b) Running MSBUILD like

msbuild LLVM.sln /p:Configuration=Release /p:"VCBuildAdditionalOptions= C:\Program Files (x86)\Microsoft Visual Studio " c) Trying to change PATH/Systemroot.. Destroyed my systemroot in the meantime for unknown reasons (It complaimed about a wrong path like "C:\Program " and erased it obviously).

I am seriously stuck and dont know any further than these steps. Setting up an include path does not seem to help - though I'm wondering if the CMAKE stuff had problems with space's or what is going on.

Since the authors of Emscripten and probably LLVM call their windows support "experimental", I'm not the only one having troubles trying to set up LLVM/clang for later use with Visual Studio 2010 (not 2012..). I'm sorry for the bad formatting, for some reason SO won't allow me neat formatting today.. I'm using a nightly browser build though.

I regularly build llvm/clang with the ninja CMake generator (running ninja from the VS2012 x86 Native Tools Command Prompt), so I know that works at least.

Best Answer

If you just need a build of LLVM, you can generate NMake Makefiles and build with nmake instead of msbuild. It seems that there is a quoting issue somewhere (might be CMake, CmakeLists.txt, msbuild, who knows).

On second thought, this might be a problem with environment variables. How did you set up PATH? Try from a new "Visual Studio Developer Command Prompt".


Well it pops up a missing mspdb100.dll - I guess that some wrong path have resetten the total environement variables for visual studio command prompt. Anybody got a copy of those for a Visual Studio 2010 installation ? Opening cmd.exe and typing ping is broken too, I guess thats cause my systemroot got emptied somewhere down the road.
@user1610743 that should be impossible if you're not running the build as administrator, which would be immensely foolish. In any case, it seems to be your environment.
NMake worked seemlessly after restoring my $path. It was really empty. I am currently checking if Emscripten works seemlessly now with Visual Studio AddIn. Thank you for your help so far!