blob: 24ea162fa615ebe155b82426507f36146530f67a [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>
John Criswelld000e1d2003-12-18 16:43:17 +000017 <li><a href="#license">License Information</a>
Brian Gaeke7af03e92003-11-12 20:47:30 +000018</ol>
19
20<div class="doc_text">
21 <p><b>Written by Brian R. Gaeke</b></p>
22</div>
23
24<!-- *********************************************************************** -->
25<div class="doc_section">
26 <a name="cautionarynote">A Cautionary Note</a>
27</div>
28<!-- *********************************************************************** -->
29
30<div class="doc_text">
31<p>This document is intended to explain the process of building the
32LLVM C/C++ front-end, based on GCC 3.4, from its source code. You
33would have to do this, for example, if you are porting LLVM to a new
34architecture or operating system.</p>
Brian Gaeke46079d22003-10-21 21:58:38 +000035
36<p><b>NOTE:</b> This is currently a somewhat fragile, error-prone
Misha Brukmanb9e57892003-10-28 21:09:29 +000037process, and you should <b>only</b> try to do it if:</p>
38
39<ol>
40 <li>you really, really, really can't use the binaries we distribute</li>
41 <li>you need GCC to fix some of the header files on your system</li>
42 <li>you are an elite GCC hacker.</li>
43</ol>
Brian Gaeke46079d22003-10-21 21:58:38 +000044
45<p>We welcome patches to help make this process simpler.</p>
Brian Gaeke7af03e92003-11-12 20:47:30 +000046</div>
Brian Gaeke46079d22003-10-21 21:58:38 +000047
Misha Brukman83bd33a2003-10-23 01:48:33 +000048<!-- *********************************************************************** -->
49<div class="doc_section">
50 <a name="instructions">Instructions</a>
51</div>
52<!-- *********************************************************************** -->
53
54<div class="doc_text">
55<p>
Brian Gaeke46079d22003-10-21 21:58:38 +000056<ol>
57<li><p>Configure and build the LLVM libraries and tools using:</p>
58<pre>
59 % cd llvm
60 % ./configure [options...]
61 % gmake tools-only
62</pre>
63 <p>The use of the non-default target "tools-only" means that the
64 LLVM tools and libraries will build, and the binaries will be
65 deposited in llvm/tools/Debug, but the runtime (bytecode)
Misha Brukman83bd33a2003-10-23 01:48:33 +000066 libraries will not build.</p></li>
Brian Gaeke46079d22003-10-21 21:58:38 +000067
68<li><p>Add the directory containing the tools to your PATH.</p>
69<pre>
Misha Brukman83bd33a2003-10-23 01:48:33 +000070 % set path = ( `cd llvm/tools/Debug &amp;&amp; pwd` $path )
71</pre></li>
Brian Gaeke46079d22003-10-21 21:58:38 +000072
Misha Brukman83bd33a2003-10-23 01:48:33 +000073<li><p>Unpack the C/C++ front-end source into cfrontend/src.</p></li>
Brian Gaeke46079d22003-10-21 21:58:38 +000074
75<li><p>Edit src/configure. Change the first line (starting w/ #!) to
Misha Brukman83bd33a2003-10-23 01:48:33 +000076 contain the correct full pathname of sh.</p></li>
Brian Gaeke46079d22003-10-21 21:58:38 +000077
78<li><p>Make "build" and "install" directories as siblings of the "src"
79 tree.</p>
80<pre>
81 % pwd
82 /usr/local/example/cfrontend/src
83 % cd ..
84 % mkdir build install
85 % set CFEINSTALL = `pwd`/install
Misha Brukman83bd33a2003-10-23 01:48:33 +000086</pre></li>
Brian Gaeke46079d22003-10-21 21:58:38 +000087
John Criswell2998d3f2003-12-10 20:04:13 +000088<li><p>Configure, build, and install the C front-end:</p>
John Criswell55072842003-12-08 19:59:14 +000089
90<p>
91<b>Linux/x86:</b>
92</p>
93
Brian Gaeke46079d22003-10-21 21:58:38 +000094<pre>
95 % cd build
John Criswell2998d3f2003-12-10 20:04:13 +000096 % ../src/configure --prefix=$CFEINSTALL --disable-threads --disable-nls --disable-shared \
Brian Gaeke46079d22003-10-21 21:58:38 +000097 --enable-languages=c,c++
98 % gmake all-gcc
99 % setenv LLVM_LIB_SEARCH_PATH `pwd`/gcc
100 % gmake all; gmake install
101</pre>
102
John Criswell55072842003-12-08 19:59:14 +0000103<p>
Brian Gaeke7e9bd802004-01-28 20:54:41 +0000104<b>Solaris/SPARC:</b>
John Criswell55072842003-12-08 19:59:14 +0000105</p>
106
107<p>
Brian Gaeke7e9bd802004-01-28 20:54:41 +0000108For Solaris/SPARC, LLVM only supports the SPARC V9. Therefore, the
109configure command line should specify sparcv9, as shown below. Also,
110note that Solaris has trouble with various wide (multibyte) character
111functions from C as referenced from C++, so we typically configure with
112--disable-c-mbchar (cf. <a href="http://llvm.cs.uiuc.edu/PR206">Bug 206</a>).
John Criswell55072842003-12-08 19:59:14 +0000113</p>
114
115<pre>
116 % cd build
Brian Gaeke7e9bd802004-01-28 20:54:41 +0000117 % ../src/configure --prefix=$CFEINSTALL --disable-threads --disable-nls \
118 --disable-shared --enable-languages=c,c++ --host=sparcv9-sun-solaris2.8 \
119 --disable-c-mbchar
John Criswell55072842003-12-08 19:59:14 +0000120 % gmake all-gcc
121 % setenv LLVM_LIB_SEARCH_PATH `pwd`/gcc
Brian Gaeke7e9bd802004-01-28 20:54:41 +0000122 % gmake all; gmake install
John Criswell55072842003-12-08 19:59:14 +0000123</pre>
124
Chris Lattnere38c6282003-10-23 03:55:23 +0000125 <p><b>Common Problem:</b> You may get error messages regarding the fact
Brian Gaeke46079d22003-10-21 21:58:38 +0000126 that LLVM does not support inline assembly. Here are two common
127 fixes:</p>
128
129 <ul>
130 <li><p><b>Fix 1:</b> If you have system header files that include
131 inline assembly, you may have to modify them to remove the inline
132 assembly, and install the modified versions in
Misha Brukman83bd33a2003-10-23 01:48:33 +0000133 <code>$CFEINSTALL/<i>target-triplet</i>/sys-include</code>.</p></li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000134
135 <li><b>Fix 2:</b> If you are building the C++ front-end on a CPU we
136 haven't tried yet, you will probably have to edit the appropriate
137 version of atomicity.h under
138 <code>src/libstdc++-v3/config/cpu/<i>name-of-cpu</i>/atomicity.h</code>
Misha Brukman83bd33a2003-10-23 01:48:33 +0000139 and apply a patch so that it does not use inline assembly.</p></li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000140 </ul>
141
Chris Lattnere38c6282003-10-23 03:55:23 +0000142 <p><b>Porting to a new architecture:</b> If you are porting the new front-end
143 to a new architecture, or compiling in a different configuration that we have
144 previously, there are probably several changes you will have to make to the GCC
145 target to get it to work correctly. These include:<p>
Brian Gaeke46079d22003-10-21 21:58:38 +0000146
147 <ul>
Chris Lattnere38c6282003-10-23 03:55:23 +0000148 <li>Often targets include special or assembler linker flags which
149 <tt>gccas</tt>/<tt>gccld</tt> does not understand. In general, these can
150 just be removed.</li>
151 <li>LLVM currently does not support any floating point values other than
152 32-bit and 64-bit IEEE floating point. The primary effect of this is
153 that you may have to map "long double" onto "double".</li>
154 <li>The profiling hooks in GCC do not apply at all to the LLVM front-end.
155 These may need to be disabled.</li>
156 <li>No inline assembly for position independent code. At the LLVM level,
157 everything is position independent.</li>
158 <li>We handle <tt>.init</tt> and <tt>.fini</tt> differently.</li>
Chris Lattner13964e02003-10-24 16:02:34 +0000159 <li>You may have to disable multilib support in your target. Using multilib
160 support causes the GCC compiler driver to add a lot of "<tt>-L</tt>"
161 options to the link line, which do not relate to LLVM and confuse
162 <tt>gccld</tt>. To disable multilibs, delete any
163 <tt>MULTILIB_OPTIONS</tt> lines from your target files.</li>
Chris Lattnere38c6282003-10-23 03:55:23 +0000164 <li>Did we mention that we don't support inline assembly? You'll probably
165 have to add some fixinclude hacks to disable it in the system
166 headers.</li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000167 </ul>
Misha Brukman83bd33a2003-10-23 01:48:33 +0000168</li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000169
170<li><p>Go back into the LLVM source tree proper. Edit Makefile.config
171to redefine <code>LLVMGCCDIR</code> to the full pathname of the
172<code>$CFEINSTALL</code> directory, which is the directory you just
173installed the C front-end into. (The ./configure script is likely to
Misha Brukman83bd33a2003-10-23 01:48:33 +0000174have set this to a directory which does not exist on your system.)</p></li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000175
176<li><p>If you edited header files during the C/C++ front-end build as
177described in "Fix 1" above, you must now copy those header files from
178<code>$CFEINSTALL/<i>target-triplet</i>/sys-include</code> to
179<code>$CFEINSTALL/lib/gcc/<i>target-triplet</i>/3.4-llvm/include</code>.
180(This should be the "include" directory in the same directory as the
181libgcc.a library, which you can find by running
Misha Brukman83bd33a2003-10-23 01:48:33 +0000182<code>$CFEINSTALL/bin/gcc --print-libgcc-file-name</code>.)</p></li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000183
184<li><p>Build and install the runtime (bytecode) libraries by running:</p>
185<pre>
186 % gmake -C runtime
187 % mkdir $CFEINSTALL/bytecode-libs
Brian Gaeke714caf22004-03-10 19:08:52 +0000188 % gmake -C runtime install-bytecode
Brian Gaeke46079d22003-10-21 21:58:38 +0000189 % setenv LLVM_LIB_SEARCH_PATH $CFEINSTALL/bytecode-libs
Misha Brukman83bd33a2003-10-23 01:48:33 +0000190</pre></li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000191
192<li><p>Test the newly-installed C frontend by one or more of the
193following means:</p>
194 <ul>
Chris Lattnere38c6282003-10-23 03:55:23 +0000195 <li> compiling and running a "hello, LLVM" program in C and C++.</li>
196 <li> running the tests under <tt>test/Programs</tt> using <code>gmake -C
Misha Brukman83bd33a2003-10-23 01:48:33 +0000197 test/Programs</code></li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000198 </ul>
Misha Brukman83bd33a2003-10-23 01:48:33 +0000199 </p>
200</li>
Brian Gaeke46079d22003-10-21 21:58:38 +0000201</ol>
Misha Brukman83bd33a2003-10-23 01:48:33 +0000202</div>
Brian Gaeke46079d22003-10-21 21:58:38 +0000203
204<!-- *********************************************************************** -->
John Criswelld000e1d2003-12-18 16:43:17 +0000205<div class="doc_section">
206 <a name="license">License Information</a>
207</div>
208
209<div class="doc_text">
210<p>
211The LLVM GCC frontend is licensed to you under the GNU General Public License
212and the GNU Lesser General Public License. Please see the files COPYING and
213COPYING.LIB for more details.
214</p>
215
216<p>
217The software also has the following additional copyrights:
218</p>
219
220<pre>
221Copyright (c) 1994
222Hewlett-Packard Company
223
224Permission to use, copy, modify, distribute and sell this software
225and its documentation for any purpose is hereby granted without fee,
226provided that the above copyright notice appear in all copies and
227that both that copyright notice and this permission notice appear
228in supporting documentation. Hewlett-Packard Company makes no
229representations about the suitability of this software for any
230purpose. It is provided "as is" without express or implied warranty.
231
232Copyright (c) 1996, 1997, 1998, 1999
233Silicon Graphics Computer Systems, Inc.
234
235Permission to use, copy, modify, distribute and sell this software
236and its documentation for any purpose is hereby granted without fee,
237provided that the above copyright notice appear in all copies and
238that both that copyright notice and this permission notice appear
239in supporting documentation. Silicon Graphics makes no
240representations about the suitability of this software for any
241purpose. It is provided "as is" without express or implied warranty.
242</pre>
243</div>
244
245<!-- *********************************************************************** -->
246<!-- *********************************************************************** -->
Brian Gaeke46079d22003-10-21 21:58:38 +0000247
Misha Brukmanb9e57892003-10-28 21:09:29 +0000248<hr>
249<div class="doc_footer">
Brian Gaeke7af03e92003-11-12 20:47:30 +0000250 <address>Brian Gaeke</address>
Misha Brukmanb9e57892003-10-28 21:09:29 +0000251 <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a>
252 <br>
253 Last modified: $Date$
254</div>
Brian Gaeke46079d22003-10-21 21:58:38 +0000255
Misha Brukman83bd33a2003-10-23 01:48:33 +0000256</body>
257</html>