Removed cvs mirror comment
[oota-llvm.git] / docs / GettingStartedVS.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2                       "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
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">
8 </head>
9 <body>
10
11 <div class="doc_title">
12   Getting Started with the LLVM System using Microsoft Visual Studio
13 </div>
14
15 <ul>
16   <li><a href="#overview">Overview</a>
17   <li><a href="#quickstart">Getting Started Quickly (A Summary)</a>
18   <li><a href="#requirements">Requirements</a>
19     <ol>
20       <li><a href="#hardware">Hardware</a>
21       <li><a href="#software">Software</a>
22     </ol></li>
23
24   <li><a href="#starting">Getting Started with LLVM</a>
25     <ol>
26       <li><a href="#terminology">Terminology and Notation</a>
27       <li><a href="#objfiles">The Location of LLVM Object Files</a>
28     </ol></li>
29
30   <li><a href="#tutorial">An Example Using the LLVM Tool Chain</a>
31   <li><a href="#problems">Common Problems</a>
32   <li><a href="#links">Links</a>
33 </ul>
34
35 <div class="doc_author">
36   <p>Written by: 
37     <a href="mailto:jeffc@jolt-lang.org">Jeff Cohen</a>
38   </p>
39 </div>
40
41
42 <!-- *********************************************************************** -->
43 <div class="doc_section">
44   <a name="overview"><b>Overview</b></a>
45 </div>
46 <!-- *********************************************************************** -->
47
48 <div class="doc_text">
49
50   <p>The Visual Studio port at this time is experimental.  It is suitable for
51   use only if you are writing your own compiler front end or otherwise have a
52   need to dynamically generate machine code.  The JIT and interpreter are
53   functional, but it is currently not possible to generate assembly code which
54   is then assembled into an executable.  You can indirectly create executables
55   by using the C back end.</p>
56
57   <p>To emphasize, there is no C/C++ front end currently available.
58   <tt>llvm-gcc</tt> is based on GCC, which cannot be bootstrapped using VC++.
59   Eventually there should be a <tt>llvm-gcc</tt> based on Cygwin or MinGW that
60   is usable.  There is also the option of generating bytecode files on Unix and
61   copying them over to Windows.  But be aware the odds of linking C++ code
62   compiled with <tt>llvm-gcc</tt> with code compiled with VC++ is essentially
63   zero.</p>
64
65   <p>The LLVM test suite cannot be run on the Visual Studio port at this
66   time.</p>
67
68   <p>Most of the tools build and work.  <tt>llvm-db</tt> does not build at this
69   time.  <tt>bugpoint</tt> does build, but does not work.
70
71   <p>Additional information about the LLVM directory structure and tool chain
72   can be found on the main <a href="GettingStarted.html">Getting Started</a>
73   page.</P>
74
75 </div>
76
77 <!-- *********************************************************************** -->
78 <div class="doc_section">
79   <a name="quickstart"><b>Getting Started Quickly (A Summary)</b></a>
80 </div>
81 <!-- *********************************************************************** -->
82
83 <div class="doc_text">
84
85 <p>Here's the short story for getting up and running quickly with LLVM:</p>
86
87 <ol>
88   <li>Read the documentation.</li>
89   <li>Read the documentation.</li>
90   <li>Remember that you were warned twice about reading the documentation.</li>
91
92   <li>Get the Source Code
93   <ul>
94     <li>With the distributed files:
95     <ol>
96       <li><tt>cd <i>where-you-want-llvm-to-live</i></tt>
97       <li><tt>gunzip --stdout llvm-<i>version</i>.tar.gz | tar -xvf -</tt>
98       <i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or use WinZip</i>
99       <li><tt>cd llvm</tt></li>
100     </ol></li>
101
102     <li>With anonymous CVS access:
103     <ol>
104       <li><tt>cd <i>where-you-want-llvm-to-live</i></tt></li>
105       <li><tt>cvs -d
106           :pserver:anon@llvm-cvs.cs.uiuc.edu:/var/cvs/llvm login</tt></li>
107       <li>Hit the return key when prompted for the password.
108       <li><tt>cvs -z3 -d :pserver:anon@llvm-cvs.cs.uiuc.edu:/var/cvs/llvm 
109           co llvm</tt></li>
110       <li><tt>cd llvm</tt></li>
111       <li><tt>cvs up -P -d</tt></li>
112     </ol></li>
113   </ul></li>
114
115   <li>Start Visual Studio
116   <ol>
117     <li>Simply double click on the solution file <tt>llvm/win32/llvm.sln</tt>.
118     </li>
119   </ol></li>
120
121   <li>Build the LLVM Suite:
122   <ol>
123     <li>Simply build the solution.</li>
124     <li>The Fibonacci project is a sample program that uses the JIT.  Modify
125     the project's debugging properties to provide a numeric command line
126     argument.  The program will print the corresponding fibonacci value.</li>
127   </ol></li>
128
129 </ol>
130
131 <p>It is strongly encouraged that you get the latest version from CVS.  Much
132 progress has been made since the 1.4 release.</p>
133
134 </div>
135
136 <!-- *********************************************************************** -->
137 <div class="doc_section">
138   <a name="requirements"><b>Requirements</b></a>
139 </div>
140 <!-- *********************************************************************** -->
141
142 <div class="doc_text">
143
144   <p>Before you begin to use the LLVM system, review the requirements given
145   below.  This may save you some trouble by knowing ahead of time what hardware
146   and software you will need.</p>
147
148 </div>
149
150 <!-- ======================================================================= -->
151 <div class="doc_subsection">
152   <a name="hardware"><b>Hardware</b></a>
153 </div>
154
155 <div class="doc_text">
156
157   <p>Any system that can adequately run Visual Studio .NET 2003 is fine.  The
158   LLVM source tree and object files, libraries and executables will consume
159   approximately 3GB.</p>
160
161 </div>
162
163 <!-- ======================================================================= -->
164 <div class="doc_subsection"><a name="software"><b>Software</b></a></div>
165 <div class="doc_text">
166
167   <p>You will need Visual Studio .NET 2003.  Earlier versions cannot open the
168   solution/project files.  The VS 2005 beta can, but will migrate these files
169   to its own format in the process.  While it should work with the VS 2005
170   beta, there are no guarantees and there is no support for it at this time.
171   It has been reported that VC++ Express also works.</p>
172
173   <p>If you plan to modify any .y or .l files, you will need to have bison
174   and/or flex installed where Visual Studio can find them.  Otherwise, you do
175   not need them and the pre-generated files that come with the source tree
176   will be used.</p>
177
178 </div>
179
180 <!-- *********************************************************************** -->
181 <div class="doc_section">
182   <a name="starting"><b>Getting Started with LLVM</b></a>
183 </div>
184 <!-- *********************************************************************** -->
185
186 <div class="doc_text">
187
188 <p>The remainder of this guide is meant to get you up and running with
189 LLVM using Visual Studio and to give you some basic information about the LLVM
190 environment.</p>
191
192 </div>
193
194 <!-- ======================================================================= -->
195 <div class="doc_subsection">
196   <a name="terminology">Terminology and Notation</a>
197 </div>
198
199 <div class="doc_text">
200
201 <p>Throughout this manual, the following names are used to denote paths
202 specific to the local system and working environment.  <i>These are not
203 environment variables you need to set but just strings used in the rest
204 of this document below</i>.  In any of the examples below, simply replace
205 each of these names with the appropriate pathname on your local system.
206 All these paths are absolute:</p>
207
208 <dl>
209     <dt>SRC_ROOT
210     <dd>
211     This is the top level directory of the LLVM source tree.
212     <p>
213
214     <dt>OBJ_ROOT
215     <dd>
216     This is the top level directory of the LLVM object tree (i.e. the
217     tree where object files and compiled programs will be placed.  It
218     is fixed at SRC_ROOT/win32).
219     <p>
220 </dl>
221
222 </div>
223
224 <!-- ======================================================================= -->
225 <div class="doc_subsection">
226   <a name="objfiles">The Location of LLVM Object Files</a>
227 </div>
228
229 <div class="doc_text">
230
231   <p>The object files are placed under <tt>OBJ_ROOT/Debug</tt> for debug builds
232   and <tt>OBJ_ROOT/Release</tt> for release (optimized) builds.  These include
233   both executables and libararies that your application can link against.
234
235   <p>The files that <tt>configure</tt> would create when building on Unix are
236   created by the <tt>Configure</tt> project and placed in
237   <tt>OBJ_ROOT/llvm</tt>.  You application must have OBJ_ROOT in its include
238   search path just before <tt>SRC_ROOT/include</tt>.
239
240 </div>
241
242 <!-- *********************************************************************** -->
243 <div class="doc_section">
244   <a name="tutorial">An Example Using the LLVM Tool Chain</a>
245 </div>
246 <!-- *********************************************************************** -->
247
248 <div class="doc_text">
249
250 <ol>
251   <li>First, create a simple C file, name it 'hello.c':
252        <pre>
253    #include &lt;stdio.h&gt;
254    int main() {
255      printf("hello world\n");
256      return 0;
257    }
258        </pre></li>
259
260   <li><p>Next, compile the C file into a LLVM bytecode file:</p>
261       <p><tt>% llvm-gcc hello.c -o hello</tt></p>
262
263       <p>Note that you should have already built the tools and they have to be
264       in your path, at least <tt>gccas</tt> and <tt>gccld</tt>.</p>
265
266       <p>This will create two result files: <tt>hello</tt> and
267       <tt>hello.bc</tt>. The <tt>hello.bc</tt> is the LLVM bytecode that
268       corresponds the the compiled program and the library facilities that it
269       required.  <tt>hello</tt> is a simple shell script that runs the bytecode
270       file with <tt>lli</tt>, making the result directly executable.  Note that
271       all LLVM optimizations are enabled by default, so there is no need for a 
272       "-O3" switch.</p>
273       
274       <p><b>Note: while you cannot do this step on Windows, you can do it on a
275         Unix system and transfer <tt>hello.bc</tt> to Windows.</b></p></li>
276
277   <li><p>Run the program using the just-in-time compiler:</p>
278       
279       <p><tt>% lli hello.bc</tt></p></li>
280
281   <li><p>Use the <tt>llvm-dis</tt> utility to take a look at the LLVM assembly
282       code:</p>
283
284       <p><tt>% llvm-dis &lt; hello.bc | more</tt><p></li>
285
286   <li><p>Compile the program to C using the LLC code generator:</p>
287
288       <p><tt>% llc -march=c hello.bc</tt></p></li>
289
290   <li><p>Compile to binary using Microsoft C:</p>
291
292       <p><tt>% cl hello.cbe.c</tt></p></li>
293
294   <li><p>Execute the native code program:</p>
295
296       <p><tt>% hello.cbe.exe</tt></p></li>
297
298 </ol>
299
300 </div>
301
302 <!-- *********************************************************************** -->
303 <div class="doc_section">
304   <a name="problems">Common Problems</a>
305 </div>
306 <!-- *********************************************************************** -->
307
308 <div class="doc_text">
309
310 <p>If you are having problems building or using LLVM, or if you have any other
311 general questions about LLVM, please consult the <a href="FAQ.html">Frequently
312 Asked Questions</a> page.</p>
313
314 </div>
315
316 <!-- *********************************************************************** -->
317 <div class="doc_section">
318   <a name="links">Links</a>
319 </div>
320 <!-- *********************************************************************** -->
321
322 <div class="doc_text">
323
324 <p>This document is just an <b>introduction</b> to how to use LLVM to do
325 some simple things... there are many more interesting and complicated things
326 that you can do that aren't documented here (but we'll gladly accept a patch
327 if you want to write something up!).  For more information about LLVM, check
328 out:</p>
329
330 <ul>
331   <li><a href="http://llvm.org/">LLVM homepage</a></li>
332   <li><a href="http://llvm.org/doxygen/">LLVM doxygen tree</a></li>
333   <li><a href="http://llvm.org/docs/Projects.html">Starting a Project
334   that Uses LLVM</a></li>
335 </ul>
336
337 </div>
338
339 <!-- *********************************************************************** -->
340
341 <hr>
342 <address>
343   <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
344   src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
345   <a href="http://validator.w3.org/check/referer"><img
346   src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a>
347
348   <a href="mailto:jeffc@jolt-lang.org">Jeff Cohen</a><br>
349   <a href="http://llvm.org">The LLVM Compiler Infrastructure</a><br>
350   Last modified: $Date$
351 </address>
352 </body>
353 </html>