<p>To emphasize, there is no C/C++ front end currently available.
<tt>llvm-gcc</tt> is based on GCC, which cannot be bootstrapped using VC++.
Eventually there should be a <tt>llvm-gcc</tt> based on Cygwin or MinGW that
- is usable. There is also the option of generating bytecode files on Unix and
+ is usable. There is also the option of generating bitcode files on Unix and
copying them over to Windows. But be aware the odds of linking C++ code
compiled with <tt>llvm-gcc</tt> with code compiled with VC++ is essentially
zero.</p>
<ol>
<li>Read the documentation.</li>
- <li>Read the documentation.</li>
+ <li>Seriously, read the documentation.</li>
<li>Remember that you were warned twice about reading the documentation.</li>
<li>Get the Source Code
<li><tt>cd llvm</tt></li>
</ol></li>
- <li>With anonymous CVS access:
+ <li>With anonymous Subversion access:
<ol>
<li><tt>cd <i>where-you-want-llvm-to-live</i></tt></li>
- <li><tt>cvs -d
- :pserver:anon@llvm-cvs.cs.uiuc.edu:/var/cvs/llvm login</tt></li>
- <li>Hit the return key when prompted for the password.
- <li><tt>cvs -z3 -d :pserver:anon@llvm-cvs.cs.uiuc.edu:/var/cvs/llvm
- co llvm</tt></li>
+ <li><tt>svn co http://llvm.org/svn/llvm-project/llvm-top/trunk llvm-top
+ </tt></li>
+ <li><tt>make checkout MODULE=llvm</tt>
<li><tt>cd llvm</tt></li>
- <li><tt>cvs up -P -d</tt></li>
</ol></li>
</ul></li>
</ol>
-<p>It is strongly encouraged that you get the latest version from CVS. Much
-progress has been made since the 1.4 release.</p>
+<p>It is strongly encouraged that you get the latest version from Subversion as
+changes are continually making the VS support better.</p>
</div>
All these paths are absolute:</p>
<dl>
- <dt>SRC_ROOT
- <dd>
- This is the top level directory of the LLVM source tree.
- <p>
-
- <dt>OBJ_ROOT
- <dd>
- This is the top level directory of the LLVM object tree (i.e. the
- tree where object files and compiled programs will be placed. It
- is fixed at SRC_ROOT/win32).
- <p>
+ <dt>SRC_ROOT</dt>
+ <dd><p>This is the top level directory of the LLVM source tree.</p></dd>
+
+ <dt>OBJ_ROOT</dt>
+ <dd><p>This is the top level directory of the LLVM object tree (i.e. the
+ tree where object files and compiled programs will be placed. It is
+ fixed at SRC_ROOT/win32).</p></dd>
</dl>
</div>
<p>The object files are placed under <tt>OBJ_ROOT/Debug</tt> for debug builds
and <tt>OBJ_ROOT/Release</tt> for release (optimized) builds. These include
- both executables and libararies that your application can link against.
+ both executables and libararies that your application can link against.</p>
<p>The files that <tt>configure</tt> would create when building on Unix are
created by the <tt>Configure</tt> project and placed in
<tt>OBJ_ROOT/llvm</tt>. You application must have OBJ_ROOT in its include
- search path just before <tt>SRC_ROOT/include</tt>.
+ search path just before <tt>SRC_ROOT/include</tt>.</p>
</div>
<div class="doc_text">
<ol>
- <li>First, create a simple C file, name it 'hello.c':
- <pre>
- #include <stdio.h>
- int main() {
- printf("hello world\n");
- return 0;
- }
- </pre></li>
-
- <li><p>Next, compile the C file into a LLVM bytecode file:</p>
- <p><tt>% llvm-gcc hello.c -o hello</tt></p>
-
- <p>Note that you should have already built the tools and they have to be
- in your path, at least <tt>gccas</tt> and <tt>gccld</tt>.</p>
-
- <p>This will create two result files: <tt>hello</tt> and
- <tt>hello.bc</tt>. The <tt>hello.bc</tt> is the LLVM bytecode that
- corresponds the the compiled program and the library facilities that it
- required. <tt>hello</tt> is a simple shell script that runs the bytecode
- file with <tt>lli</tt>, making the result directly executable. Note that
- all LLVM optimizations are enabled by default, so there is no need for a
- "-O3" switch.</p>
+ <li><p>First, create a simple C file, name it 'hello.c':</p>
+
+<div class="doc_code">
+<pre>
+#include <stdio.h>
+int main() {
+ printf("hello world\n");
+ return 0;
+}
+</pre></div></li>
+
+ <li><p>Next, compile the C file into a LLVM bitcode file:</p>
+
+<div class="doc_code">
+<pre>
+% llvm-gcc -c hello.c -emit-llvm -o hello.bc
+</pre>
+</div>
+
+ <p>This will create the result file <tt>hello.bc</tt> which is the LLVM
+ bitcode that corresponds the the compiled program and the library
+ facilities that it required. You can execute this file directly using
+ <tt>lli</tt> tool, compile it to native assembly with the <tt>llc</tt>,
+ optimize or analyze it further with the <tt>opt</tt> tool, etc.</p>
<p><b>Note: while you cannot do this step on Windows, you can do it on a
- Unix system and transfer <tt>hello.bc</tt> to Windows.</b></p></li>
+ Unix system and transfer <tt>hello.bc</tt> to Windows. Important:
+ transfer as a binary file!</b></p></li>
<li><p>Run the program using the just-in-time compiler:</p>
- <p><tt>% lli hello.bc</tt></p></li>
+<div class="doc_code">
+<pre>
+% lli hello.bc
+</pre>
+</div>
+
+ <p>Note: this will only work for trivial C programs. Non-trivial programs
+ (and any C++ program) will have dependencies on the GCC runtime that
+ won't be satisfied by the Microsoft runtime libraries.</p></li>
<li><p>Use the <tt>llvm-dis</tt> utility to take a look at the LLVM assembly
code:</p>
- <p><tt>% llvm-dis < hello.bc | more</tt><p></li>
+<div class="doc_code">
+<pre>
+% llvm-dis < hello.bc | more
+</pre>
+</div></li>
<li><p>Compile the program to C using the LLC code generator:</p>
- <p><tt>% llc -march=c hello.bc</tt></p></li>
+<div class="doc_code">
+<pre>
+% llc -march=c hello.bc
+</pre>
+</div></li>
<li><p>Compile to binary using Microsoft C:</p>
- <p><tt>% cl hello.cbe.c</tt></p></li>
+<div class="doc_code">
+<pre>
+% cl hello.cbe.c
+</pre>
+</div>
+
+ <p>Note: this will only work for trivial C programs. Non-trivial programs
+ (and any C++ program) will have dependencies on the GCC runtime that
+ won't be satisfied by the Microsoft runtime libraries.</p></li>
<li><p>Execute the native code program:</p>
- <p><tt>% hello.cbe.exe</tt></p></li>
-
+<div class="doc_code">
+<pre>
+% hello.cbe.exe
+</pre>
+</div></li>
</ol>
</div>
<li><a href="http://llvm.org/">LLVM homepage</a></li>
<li><a href="http://llvm.org/doxygen/">LLVM doxygen tree</a></li>
<li><a href="http://llvm.org/docs/Projects.html">Starting a Project
- that Uses LLVM</a></li>
+ that Uses LLVM</a></li>
</ul>
</div>