blob: be844b9da895054c0f12190549a0acfc37b89735 [file] [log] [blame]
Brian Gaeke46079d22003-10-21 21:58:38 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Misha Brukman83bd33a2003-10-23 01:48:33 +00002<html>
3<head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5 <link rel="stylesheet" href="llvm.css" type="text/css" media="screen" />
Misha Brukmanb9e57892003-10-28 21:09:29 +00006 <title>Bootstrapping the LLVM C/C++ Front-End</title>
Misha Brukman83bd33a2003-10-23 01:48:33 +00007</head>
8<body>
Brian Gaeke46079d22003-10-21 21:58:38 +00009
Misha Brukman83bd33a2003-10-23 01:48:33 +000010<div class="doc_title">
Misha Brukmanb9e57892003-10-28 21:09:29 +000011 Bootstrapping the LLVM C/C++ Front-End
Misha Brukman83bd33a2003-10-23 01:48:33 +000012</div>
Brian Gaeke46079d22003-10-21 21:58:38 +000013
Brian Gaeke7af03e92003-11-12 20:47:30 +000014<ol>
15 <li><a href="#cautionarynote">A Cautionary Note</a>
16 <li><a href="#instructions">Instructions</a>
17</ol>
18
19<div class="doc_text">
20 <p><b>Written by Brian R. Gaeke</b></p>
21</div>
22
23<!-- *********************************************************************** -->
24<div class="doc_section">
25 <a name="cautionarynote">A Cautionary Note</a>
26</div>
27<!-- *********************************************************************** -->
28
29<div class="doc_text">
30<p>This document is intended to explain the process of building the
31LLVM C/C++ front-end, based on GCC 3.4, from its source code. You
32would have to do this, for example, if you are porting LLVM to a new
33architecture or operating system.</p>
Brian Gaeke46079d22003-10-21 21:58:38 +000034
35<p><b>NOTE:</b> This is currently a somewhat fragile, error-prone
Misha Brukmanb9e57892003-10-28 21:09:29 +000036process, and you should <b>only</b> try to do it if:</p>
37
38<ol>
39 <li>you really, really, really can't use the binaries we distribute</li>
40 <li>you need GCC to fix some of the header files on your system</li>
41 <li>you are an elite GCC hacker.</li>
42</ol>
Brian Gaeke46079d22003-10-21 21:58:38 +000043
44<p>We welcome patches to help make this process simpler.</p>
Brian Gaeke7af03e92003-11-12 20:47:30 +000045</div>
Brian Gaeke46079d22003-10-21 21:58:38 +000046
Misha Brukman83bd33a2003-10-23 01:48:33 +000047<!-- *********************************************************************** -->
48<div class="doc_section">
49 <a name="instructions">Instructions</a>
50</div>
51<!-- *********************************************************************** -->
52
53<div class="doc_text">
54<p>
Brian Gaeke46079d22003-10-21 21:58:38 +000055<ol>
56<li><p>Configure and build the LLVM libraries and tools using:</p>
57<pre>
58 % cd llvm
59 % ./configure [options...]
60 % gmake tools-only
61</pre>
62 <p>The use of the non-default target "tools-only" means that the
63 LLVM tools and libraries will build, and the binaries will be
64 deposited in llvm/tools/Debug, but the runtime (bytecode)
Misha Brukman83bd33a2003-10-23 01:48:33 +000065 libraries will not build.</p></li>
Brian Gaeke46079d22003-10-21 21:58:38 +000066
67<li><p>Add the directory containing the tools to your PATH.</p>
68<pre>
Misha Brukman83bd33a2003-10-23 01:48:33 +000069 % set path = ( `cd llvm/tools/Debug &amp;&amp; pwd` $path )
70</pre></li>
Brian Gaeke46079d22003-10-21 21:58:38 +000071
Misha Brukman83bd33a2003-10-23 01:48:33 +000072<li><p>Unpack the C/C++ front-end source into cfrontend/src.</p></li>
Brian Gaeke46079d22003-10-21 21:58:38 +000073
74<li><p>Edit src/configure. Change the first line (starting w/ #!) to
Misha Brukman83bd33a2003-10-23 01:48:33 +000075 contain the correct full pathname of sh.</p></li>
Brian Gaeke46079d22003-10-21 21:58:38 +000076
77<li><p>Make "build" and "install" directories as siblings of the "src"
78 tree.</p>
79<pre>
80 % pwd
81 /usr/local/example/cfrontend/src
82 % cd ..
83 % mkdir build install
84 % set CFEINSTALL = `pwd`/install
Misha Brukman83bd33a2003-10-23 01:48:33 +000085</pre></li>
Brian Gaeke46079d22003-10-21 21:58:38 +000086
John Criswell2998d3f2003-12-10 20:04:13 +000087<li><p>Configure, build, and install the C front-end:</p>
John Criswell55072842003-12-08 19:59:14 +000088
89<p>
90<b>Linux/x86:</b>
91</p>
92
Brian Gaeke46079d22003-10-21 21:58:38 +000093<pre>
94 % cd build
John Criswell2998d3f2003-12-10 20:04:13 +000095 % ../src/configure --prefix=$CFEINSTALL --disable-threads --disable-nls --disable-shared \
Brian Gaeke46079d22003-10-21 21:58:38 +000096 --enable-languages=c,c++
97 % gmake all-gcc
98 % setenv LLVM_LIB_SEARCH_PATH `pwd`/gcc
99 % gmake all; gmake install
100</pre>
101
John Criswell55072842003-12-08 19:59:14 +0000102<p>
103<b>Solaris/Sparc:</b>
104</p>
105
106<p>
107For Solaris/Sparc, LLVM only supports SparcV9. Therefore, the configure
108command line should like something like this:
109</p>
110
111<pre>
112 % cd build
John Criswell2998d3f2003-12-10 20:04:13 +0000113 % ../src/configure --prefix=$CFEINSTALL --disable-threads --disable-nls --disable-shared \
John Criswella84962c2003-12-10 15:27:29 +0000114 --enable-languages=c,c++ --host=sparcv9-sun-solaris2.8
John Criswell55072842003-12-08 19:59:14 +0000115 % gmake all-gcc
116 % setenv LLVM_LIB_SEARCH_PATH `pwd`/gcc
117 % gmake all; gmake install
118</pre>
119
Chris Lattnere38c6282003-10-23 03:55:23 +0000120 <p><b>Common Problem:</b> You may get error messages regarding the fact
Brian Gaeke46079d22003-10-21 21:58:38 +0000121 that LLVM does not support inline assembly. Here are two common
122 fixes:</p>
123
124 <ul>
125 <li><p><b>Fix 1:</b> If you have system header files that include
126 inline assembly, you may have to modify them to remove the inline
127 assembly, and install the modified versions in
Misha Brukman83bd33a2003-10-23 01:48:33 +0000128 <code>$CFEINSTALL/<i>target-triplet</i>/sys-include</code>.</p></li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000129
130 <li><b>Fix 2:</b> If you are building the C++ front-end on a CPU we
131 haven't tried yet, you will probably have to edit the appropriate
132 version of atomicity.h under
133 <code>src/libstdc++-v3/config/cpu/<i>name-of-cpu</i>/atomicity.h</code>
Misha Brukman83bd33a2003-10-23 01:48:33 +0000134 and apply a patch so that it does not use inline assembly.</p></li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000135 </ul>
136
Chris Lattnere38c6282003-10-23 03:55:23 +0000137 <p><b>Porting to a new architecture:</b> If you are porting the new front-end
138 to a new architecture, or compiling in a different configuration that we have
139 previously, there are probably several changes you will have to make to the GCC
140 target to get it to work correctly. These include:<p>
Brian Gaeke46079d22003-10-21 21:58:38 +0000141
142 <ul>
Chris Lattnere38c6282003-10-23 03:55:23 +0000143 <li>Often targets include special or assembler linker flags which
144 <tt>gccas</tt>/<tt>gccld</tt> does not understand. In general, these can
145 just be removed.</li>
146 <li>LLVM currently does not support any floating point values other than
147 32-bit and 64-bit IEEE floating point. The primary effect of this is
148 that you may have to map "long double" onto "double".</li>
149 <li>The profiling hooks in GCC do not apply at all to the LLVM front-end.
150 These may need to be disabled.</li>
151 <li>No inline assembly for position independent code. At the LLVM level,
152 everything is position independent.</li>
153 <li>We handle <tt>.init</tt> and <tt>.fini</tt> differently.</li>
Chris Lattner13964e02003-10-24 16:02:34 +0000154 <li>You may have to disable multilib support in your target. Using multilib
155 support causes the GCC compiler driver to add a lot of "<tt>-L</tt>"
156 options to the link line, which do not relate to LLVM and confuse
157 <tt>gccld</tt>. To disable multilibs, delete any
158 <tt>MULTILIB_OPTIONS</tt> lines from your target files.</li>
Chris Lattnere38c6282003-10-23 03:55:23 +0000159 <li>Did we mention that we don't support inline assembly? You'll probably
160 have to add some fixinclude hacks to disable it in the system
161 headers.</li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000162 </ul>
Misha Brukman83bd33a2003-10-23 01:48:33 +0000163</li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000164
165<li><p>Go back into the LLVM source tree proper. Edit Makefile.config
166to redefine <code>LLVMGCCDIR</code> to the full pathname of the
167<code>$CFEINSTALL</code> directory, which is the directory you just
168installed the C front-end into. (The ./configure script is likely to
Misha Brukman83bd33a2003-10-23 01:48:33 +0000169have set this to a directory which does not exist on your system.)</p></li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000170
171<li><p>If you edited header files during the C/C++ front-end build as
172described in "Fix 1" above, you must now copy those header files from
173<code>$CFEINSTALL/<i>target-triplet</i>/sys-include</code> to
174<code>$CFEINSTALL/lib/gcc/<i>target-triplet</i>/3.4-llvm/include</code>.
175(This should be the "include" directory in the same directory as the
176libgcc.a library, which you can find by running
Misha Brukman83bd33a2003-10-23 01:48:33 +0000177<code>$CFEINSTALL/bin/gcc --print-libgcc-file-name</code>.)</p></li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000178
179<li><p>Build and install the runtime (bytecode) libraries by running:</p>
180<pre>
181 % gmake -C runtime
182 % mkdir $CFEINSTALL/bytecode-libs
183 % gmake -C runtime install
184 % setenv LLVM_LIB_SEARCH_PATH $CFEINSTALL/bytecode-libs
Misha Brukman83bd33a2003-10-23 01:48:33 +0000185</pre></li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000186
187<li><p>Test the newly-installed C frontend by one or more of the
188following means:</p>
189 <ul>
Chris Lattnere38c6282003-10-23 03:55:23 +0000190 <li> compiling and running a "hello, LLVM" program in C and C++.</li>
191 <li> running the tests under <tt>test/Programs</tt> using <code>gmake -C
Misha Brukman83bd33a2003-10-23 01:48:33 +0000192 test/Programs</code></li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000193 </ul>
Misha Brukman83bd33a2003-10-23 01:48:33 +0000194 </p>
195</li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000196</ol>
Misha Brukman83bd33a2003-10-23 01:48:33 +0000197</div>
Brian Gaeke46079d22003-10-21 21:58:38 +0000198
199<!-- *********************************************************************** -->
Brian Gaeke46079d22003-10-21 21:58:38 +0000200
Misha Brukmanb9e57892003-10-28 21:09:29 +0000201<hr>
202<div class="doc_footer">
Brian Gaeke7af03e92003-11-12 20:47:30 +0000203 <address>Brian Gaeke</address>
Misha Brukmanb9e57892003-10-28 21:09:29 +0000204 <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a>
205 <br>
206 Last modified: $Date$
207</div>
Brian Gaeke46079d22003-10-21 21:58:38 +0000208
Misha Brukman83bd33a2003-10-23 01:48:33 +0000209</body>
210</html>