1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8">
6 <title>Getting Started with LLVM System for Microsoft Visual Studio
</title>
7 <link rel=
"stylesheet" href=
"llvm.css" type=
"text/css">
11 <div class=
"doc_title">
12 Getting Started with the LLVM System using Microsoft Visual Studio
16 <li><a href=
"#overview">Overview
</a>
17 <li><a href=
"#requirements">Requirements
</a>
19 <li><a href=
"#hardware">Hardware
</a>
20 <li><a href=
"#software">Software
</a>
22 <li><a href=
"#quickstart">Getting Started
</a>
23 <li><a href=
"#tutorial">An Example Using the LLVM Tool Chain
</a>
24 <li><a href=
"#problems">Common Problems
</a>
25 <li><a href=
"#links">Links
</a>
28 <div class=
"doc_author">
29 <p>Written by:
<a href=
"http://llvm.org">The LLVM Team
</a></p>
33 <!-- *********************************************************************** -->
34 <div class=
"doc_section">
35 <a name=
"overview"><b>Overview
</b></a>
37 <!-- *********************************************************************** -->
39 <div class=
"doc_text">
41 <p>Welcome to LLVM on Windows! This document only covers LLVM on Windows using
42 Visual Studio, not mingw or cygwin. In order to get started, you first need to
43 know some basic information.
</p>
45 <p>There are many different projects that compose LLVM. The first is the LLVM
46 suite. This contains all of the tools, libraries, and header files needed to
47 use the low level virtual machine. It contains an assembler, disassembler,
48 bitcode analyzer and bitcode optimizer. It also contains a test suite that can
49 be used to test the LLVM tools.
</p>
51 <p>Another useful project on Windows is
52 <a href=
"http://clang.llvm.org/">clang
</a>. Clang is a C family
53 ([Objective]C/C++) compiler. Clang mostly works on Windows, but does not
54 currently understand all of the Microsoft extensions to C and C++. Because of
55 this, clang cannot parse the C++ standard library included with Visual Studio,
56 nor parts of the Windows Platform SDK. However, most standard C programs do
57 compile. Clang can be used to emit bitcode, directly emit object files or
58 even linked executables using Visual Studio's
<tt>link.exe
</tt></p>
60 <p>The large LLVM test suite cannot be run on the Visual Studio port at this
63 <p>Most of the tools build and work.
<tt>bugpoint
</tt> does build, but does
66 <p>Additional information about the LLVM directory structure and tool chain
67 can be found on the main
<a href=
"GettingStarted.html">Getting Started
</a>
72 <!-- *********************************************************************** -->
73 <div class=
"doc_section">
74 <a name=
"requirements"><b>Requirements
</b></a>
76 <!-- *********************************************************************** -->
78 <div class=
"doc_text">
80 <p>Before you begin to use the LLVM system, review the requirements given
81 below. This may save you some trouble by knowing ahead of time what hardware
82 and software you will need.
</p>
86 <!-- ======================================================================= -->
87 <div class=
"doc_subsection">
88 <a name=
"hardware"><b>Hardware
</b></a>
91 <div class=
"doc_text">
93 <p>Any system that can adequately run Visual Studio .NET
2005 SP1 is fine.
94 The LLVM source tree and object files, libraries and executables will consume
95 approximately
3GB.
</p>
99 <!-- ======================================================================= -->
100 <div class=
"doc_subsection"><a name=
"software"><b>Software
</b></a></div>
101 <div class=
"doc_text">
103 <p>You will need Visual Studio .NET
2005 SP1 or higher. The VS2005 SP1
104 beta and the normal VS2005 still have bugs that are not completely
105 compatible. Earlier versions of Visual Studio do not support the C++ standard
106 well enough and will not work.
</p>
108 <p>You will also need the
<a href=
"http://www.cmake.org/">CMake
</a> build
109 system since it generates the project files you will use to build with.
</p>
111 <p>If you would like to run the LLVM tests you will need
112 <a href=
"http://www.python.org/">Python
</a>. Versions
2.4-
2.7 are known to
113 work. You will need
<a href=
"http://gnuwin32.sourceforge.net/">"GnuWin32"</a>
116 <p>Do not install the LLVM directory tree into a path containing spaces (e.g.
117 C:\Documents and Settings\...) as the configure step will fail.
</p>
121 <!-- *********************************************************************** -->
122 <div class=
"doc_section">
123 <a name=
"quickstart"><b>Getting Started
</b></a>
125 <!-- *********************************************************************** -->
127 <div class=
"doc_text">
129 <p>Here's the short story for getting up and running quickly with LLVM:
</p>
132 <li>Read the documentation.
</li>
133 <li>Seriously, read the documentation.
</li>
134 <li>Remember that you were warned twice about reading the documentation.
</li>
136 <li>Get the Source Code
138 <li>With the distributed files:
140 <li><tt>cd
<i>where-you-want-llvm-to-live
</i></tt>
141 <li><tt>gunzip --stdout llvm-
<i>version
</i>.tar.gz | tar -xvf -
</tt>
142 <i> or use WinZip
</i>
143 <li><tt>cd llvm
</tt></li>
146 <li>With anonymous Subversion access:
148 <li><tt>cd
<i>where-you-want-llvm-to-live
</i></tt></li>
149 <li><tt>svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
</tt></li>
150 <li><tt>cd llvm
</tt></li>
154 <li> Use
<a href=
"http://www.cmake.org/">CMake
</a> to generate up-to-date
157 <li>Once CMake is installed then the simplest way is to just start the
158 CMake GUI, select the directory where you have LLVM extracted to, and the
159 default options should all be fine. One option you may really want to
160 change, regardless of anything else, might be the CMAKE_INSTALL_PREFIX
161 setting to select a directory to INSTALL to once compiling is complete,
162 although installation is not mandatory for using LLVM. Another important
163 option is LLVM_TARGETS_TO_BUILD, which controls the LLVM target
164 architectures that are included on the build.
165 <li>See the
<a href=
"CMake.html">LLVM CMake guide
</a> for
166 detailed information about how to configure the LLVM
171 <li>Start Visual Studio
173 <li>In the directory you created the project files will have
174 an
<tt>llvm.sln
</tt> file, just double-click on that to open
178 <li>Build the LLVM Suite:
180 <li>The projects may still be built individually, but
181 to build them all do not just select all of them in batch build (as some
182 are meant as configuration projects), but rather select and build just
183 the ALL_BUILD project to build everything, or the INSTALL project, which
184 first builds the ALL_BUILD project, then installs the LLVM headers, libs,
185 and other useful things to the directory set by the CMAKE_INSTALL_PREFIX
186 setting when you first configured CMake.
</li>
187 <li>The Fibonacci project is a sample program that uses the JIT.
188 Modify the project's debugging properties to provide a numeric
189 command line argument or run it from the command line. The
190 program will print the corresponding fibonacci value.
</li>
193 <li>Test LLVM on Visual Studio:
195 <li>If %PATH% does not contain GnuWin32, you may specify LLVM_LIT_TOOLS_DIR
196 on CMake for the path to GnuWin32.
</li>
197 <li>You can run LLVM tests to build the project
"check".
</li>
201 <!-- FIXME: Is it up-to-date? -->
204 <li>The LLVM tests can be run by
<tt>cd
</tt>ing to the llvm source directory
207 <div class=
"doc_code">
213 <p>Note that quite a few of these test will fail.
</p>
216 <li>A specific test or test directory can be run with:
</li>
218 <div class=
"doc_code">
220 % llvm-lit test/path/to/test
228 <!-- *********************************************************************** -->
229 <div class=
"doc_section">
230 <a name=
"tutorial">An Example Using the LLVM Tool Chain
</a>
232 <!-- *********************************************************************** -->
234 <div class=
"doc_text">
237 <li><p>First, create a simple C file, name it 'hello.c':
</p>
239 <div class=
"doc_code">
241 #include
<stdio.h
>
243 printf(
"hello world\n");
248 <li><p>Next, compile the C file into a LLVM bitcode file:
</p>
250 <div class=
"doc_code">
252 % clang -c hello.c -emit-llvm -o hello.bc
256 <p>This will create the result file
<tt>hello.bc
</tt> which is the LLVM
257 bitcode that corresponds the the compiled program and the library
258 facilities that it required. You can execute this file directly using
259 <tt>lli
</tt> tool, compile it to native assembly with the
<tt>llc
</tt>,
260 optimize or analyze it further with the
<tt>opt
</tt> tool, etc.
</p>
262 <p>Alternatively you can directly output an executable with clang with:
265 <div class=
"doc_code">
267 % clang hello.c -o hello.exe
271 <p>The
<tt>-o hello.exe
</tt> is required because clang currently outputs
272 <tt>a.out
</tt> when neither
<tt>-o
</tt> nor
<tt>-c
</tt> are given.
</p>
274 <li><p>Run the program using the just-in-time compiler:
</p>
276 <div class=
"doc_code">
282 <li><p>Use the
<tt>llvm-dis
</tt> utility to take a look at the LLVM assembly
285 <div class=
"doc_code">
287 % llvm-dis
< hello.bc | more
291 <li><p>Compile the program to object code using the LLC code generator:
</p>
293 <div class=
"doc_code">
295 % llc -filetype=obj hello.bc
299 <li><p>Link to binary using Microsoft link:
</p>
301 <div class=
"doc_code">
303 % link hello.obj -defaultlib:libcmt
307 <li><p>Execute the native code program:
</p>
309 <div class=
"doc_code">
318 <!-- *********************************************************************** -->
319 <div class=
"doc_section">
320 <a name=
"problems">Common Problems
</a>
322 <!-- *********************************************************************** -->
324 <div class=
"doc_text">
326 <p>If you are having problems building or using LLVM, or if you have any other
327 general questions about LLVM, please consult the
<a href=
"FAQ.html">Frequently
328 Asked Questions
</a> page.
</p>
332 <!-- *********************************************************************** -->
333 <div class=
"doc_section">
334 <a name=
"links">Links
</a>
336 <!-- *********************************************************************** -->
338 <div class=
"doc_text">
340 <p>This document is just an
<b>introduction
</b> to how to use LLVM to do
341 some simple things... there are many more interesting and complicated things
342 that you can do that aren't documented here (but we'll gladly accept a patch
343 if you want to write something up!). For more information about LLVM, check
347 <li><a href=
"http://llvm.org/">LLVM homepage
</a></li>
348 <li><a href=
"http://llvm.org/doxygen/">LLVM doxygen tree
</a></li>
353 <!-- *********************************************************************** -->
357 <a href=
"http://jigsaw.w3.org/css-validator/check/referer"><img
358 src=
"http://jigsaw.w3.org/css-validator/images/vcss-blue" alt=
"Valid CSS"></a>
359 <a href=
"http://validator.w3.org/check/referer"><img
360 src=
"http://www.w3.org/Icons/valid-html401-blue" alt=
"Valid HTML 4.01"></a>
362 <a href=
"http://llvm.org">The LLVM Compiler Infrastructure
</a><br>
363 Last modified: $Date$