Build Clang and LLVM on Win 8

Hi all,
I’m new to Clang and LLVM and I’d like to use them on Win 8 with Code::Blocks.

I’m having problems in running cmake.

I did the following:

  • Installed cmake

  • installed Code::Blocks

  • Installed python (cmake was complaining if it was not installed)

  • Dowloaded sources fron svn (LLVM, clang, compilre-rt and test-suite.

When I run cmake I got The following error:
\build>CMake -G “CodeBlocks - MinGW Makefiles” …\llvm
– Could NOT find LibXml2 (missing: LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
– Target triple: x86_64-w64-mingw32
– Native target architecture is X86
– Threads enabled.
– Found PythonInterp: C:/Python33/python.exe (found version “3.3.2”)
– Constructing LLVMBuild project information
CMake Error at CMakeLists.txt:299 (message):
Unexpected failure executing llvm-build: Traceback (most recent call last):

File "/llvm/utils/llvm-b
uild/llvm-build", line 3, in
import llvmbuild
File "\llvm\utils\llvm-b
uild\llvmbuild_init_.py", line 1, in
from main import main

ImportError: No module named ‘main’

– Configuring incomplete, errors occurred!

So I thought that I missed to configure something.
I tried to run the configure script as per the web instructions, but I got an error because the configure script is only for linux

\build>…\llvm\configure --p****refix="c:\llvm\tools"
“…\llvm\configure” is not an internal/external command, an executable or batch file.

May anyone please help me?
I downloaded the last version of LLVM (3.4).

Thanks in advance,
Giorgio Franceschetti

Giorgio Franceschetti <g.franceschetti@vidya.it> writes:

When I run cmake I got The following error:
*<project folder>\build>CMake -G "CodeBlocks - MinGW Makefiles" ..\llvm*
/-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARIES
LIBXML2_INCLUDE_DIR)//
//-- Target triple: x86_64-w64-mingw32//
//-- Native target architecture is X86//
//-- Threads enabled.//
//-- Found PythonInterp: C:/Python33/python.exe (found version "3.3.2")//
//-- Constructing LLVMBuild project information//
//CMake Error at CMakeLists.txt:299 (message)://
// Unexpected failure executing llvm-build: Traceback (most recent
call last)://

I think that you installed the wrong version of Python. IIRC llvm-build
requires Python 2.X

There was a patch on the commit list to try to make some of our scripts
work for both 2 and 3. I should dig it up and review it.

My initial impression was that still probably nobody uses python 3, so it's
not worth adding support that will break. But if users actually have
python 3, maybe it's worth it.

Reid Kleckner <rnk@google.com> writes:

My initial impression was that still probably nobody uses python 3, so it's
not worth adding support that will break. But if users actually have
python 3, maybe it's worth it.

I think that on this case the problem was not people who actually have
python 3, but people who see Python as a requirement for building LLVM
and go to python.org and download the "most recent" version, i.e. python
3, because they are unaware of the incompatibilities. Believe it or not,
there are developers who don't know about the Python mess :slight_smile:

If adding support for version 3 is problematic, a check that gives a
helpful message would be a good start. If it can't be implemented on the
python scripts, it could be implemented on the cmake/configure scripts.

BTW, http://llvm.org/docs/GettingStarted.html mentions Python as a
requirement for the automated test suite (not for the build.) Says
version >=2.4. A user reading that would assume that version 3.X is ok,
or no Python at all if he only wishes to play with LLVM.

Giorgio Franceschetti <g.franceschetti@vidya.it> writes:

...

I think that you installed the wrong version of Python. IIRC llvm-build
requires Python 2.X

There was a patch on the commit list to try to make some of our scripts work for both 2 and 3. I should dig it up and review it.

See http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130715/181547.html

My initial impression was that still probably nobody uses python 3, so it's not worth adding support that will break. But if users actually have python 3, maybe it's worth it.

I guess it is slow in coming, but when it gains a certain critical mass, the 2.x series will be doomed quickly. In any case, the patch looks fairly minimal, except for globally replacing "print foo" with "print(foo)", which I wish the Python guys hadn't done. :slight_smile:

-Dimitry

Hi all,
   yes, I do not know python and I installed it only for being able to build LLVM.
Now I have installed version 2.7.

I tried with codeblock project generation, but I'm still getting errors.

So I moved to visual studio as per "getting started" guide.

I run the command: cmake -G "Visual Studio 11" ..\llvm from my build folder.

It lists a lot of file not found during the execution, but at the end it does create th visual studio projects.
Based on the web guide, it should be successful.
First question, is it really?

Then, I open visual studio and run the solution compilation.

But, after a long time, I got a lot of errors stating that it is not possible to find the stdbool.h file + a few others.
Example:
error C1083: Impossibile aprire il file inclusione 'stdbool.h': No such file or directory (<my

\llvm\projects\compiler-rt\lib\floatuntisf.c) <my \llvm\projects\compiler-rt\lib\int_lib.h 37 1 clang_rt.x86_64

error C2061: errore di sintassi: identificatore '__attribute__' (<my

\llvm\projects\compiler-rt\lib\int_util.c) <my \llvm\projects\compiler-rt\lib\int_util.h 27 1 clang_rt.x86_64

error C2059: errore di sintassi: ';' (<my

\llvm\projects\compiler-rt\lib\int_util.c) <my \llvm\projects\compiler-rt\lib\int_util.h 27 1 clang_rt.x86_64

error C2182: 'noreturn': utilizzo non valido del tipo 'void' (<my

\llvm\projects\compiler-rt\lib\int_util.c) <my \llvm\projects\compiler-rt\lib\int_util.h 27 1 clang_rt.x86_64

error C1083: Impossibile aprire il file inclusione 'stdbool.h': No such file or directory (<my

\llvm\projects\compiler-rt\lib\int_util.c) <my \llvm\projects\compiler-rt\lib\int_lib.h 37 1 clang_rt.x86_64

What could it be?

Any help is appreciated,

    Giorgio

I also tried to build LLVM with 3.3 sources.

Same problems.

Even worse, Visual Studio hangs and I had to kill the process.

What could it be? Is Visual Studio 2012 working with LLVM/clang?

Or LLVM/Clang is not supposed to work on windows (I saw also that there are no binaries ready for the windows platform).

Thanks in advance,
   Giorgio

Hi Giorgio,

here is another description how to compile LLVM on Windows:
http://wiki.dlang.org/Building_and_hacking_LDC_on_Windows_using_MSVC

Maybe this is helpful. I created this for Windows 7 but I also repeated it successfully on Windows 8.

Regards
Kai

On my PC it does not work.

I'm able to generate and open the Visual studio project (VS 11 Win64).

I have tried with cmake on command line, with the cmake gui, release 3.4 and 3.3.

But when I try to compile the solution I get a loot of errors about a missing stdbool.h file.

Does anyone have any hint?

Giorgio

Giorgio Franceschetti <g.franceschetti@vidya.it> writes:

I also tried to build LLVM with 3.3 sources.
Same problems.

If you omit compiler-rt, does it work? (compiler-rt is not a required
component.)

Even worse, Visual Studio hangs and I had to kill the process.

What could it be? Is Visual Studio 2012 working with LLVM/clang?

Or LLVM/Clang is not supposed to work on windows (I saw also that
there are no binaries ready for the windows platform).

For the most part, LLVM works fine on Windows, with some limitations.
Clang has serious shortcomings, more so if you build it with VS (Mingw
is better because Clang can use the headers and standard C++ library
that comes with MinGW, but not the standard C++ library that comes with
VS.)

It lists a lot of file not found during the execution, but at the
end it does create th visual studio projects.
Based on the web guide, it should be successful.
First question, is it really?

Yes. What you are seeing are the platform checks, where the build system
looks for the presence of functions, headers, etc and then generates a
configuration file with that information.

Thanks for your reply.

Compiler-rt was a problem. From the documentation I thought it was mandatory (so what is it used for?),

but it was giving all those error about stdbool.h missing that I reported.

Now things got better, but I have still problems.

I receive an error that seems related to the fact that the grep command is missing.

Is it possible? If grep is needed, how can I found it in Windows?

Thanks in advance,
   Giorgio

Hi Giorgio,

I receive an error that seems related to the fact that the grep command
is missing.

Is it possible? If grep is needed, how can I found it in Windows?

See here:
http://clang.llvm.org/hacking.html#testingWindows

grep (and a few other required tools) are in the GnuWin32 tools.

Thanks,

Greg Bedwell
SN Systems - Sony Computer Entertainment Group

Thanks Greg,

   I was finally able to compile successfully both on Visual Studio 2012 and Code::Blocks.

But, while the compilation done with Visual Studio seems to be complete, with Code::Blocks there are some programs missing (notably clang and clang++)...

Anyone can explain me why?

Thanks in advance,
   Giorgio