Added information on the GCC front end.
[oota-llvm.git] / docs / FAQ.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   <title>LLVM: Frequently Asked Questions</title>
6   <style>
7     @import url("llvm.css");
8     .question { font-weight: bold }
9     .answer   { margin-left: 2em  }
10   </style>
11 </head>
12 <body>
13
14 <div class="doc_title">
15   LLVM: Frequently Asked Questions
16 </div>
17
18 <ol>
19   <li><a href="#license">License</a>
20   <ol>
21   <li>Why are the LLVM source code and the front-end distributed under different
22   licenses?</li>
23   <li>Does the University of Illinois Open Source License really qualify as an
24   "open source" license?</li>
25   <li>Can I modify LLVM source code and redistribute the modified source?</li>
26   <li>Can I modify LLVM source code and redistribute binaries or other tools
27   based on it, without redistributing the source?</li>
28   </ol></li>
29
30   <li><a href="#source">Source code</a>
31   <ol>
32   <li>In what language is LLVM written?</li>
33   <li>How portable is the LLVM source code?</li>
34   </ol></li>
35
36   <li><a href="#build">Build Problems</a>
37   <ol>
38   <li>When I run configure, it finds the wrong C compiler.</li>
39   <li>I compile the code, and I get some error about <tt>/localhome</tt>.</li>
40   <li>The <tt>configure</tt> script finds the right C compiler, but it uses the
41   LLVM linker from a previous build.  What do I do?</li>
42   <li>When creating a dynamic library, I get a strange GLIBC error.</li>
43   <li>I've updated my source tree from CVS, and now my build is trying to use a
44   file/directory that doesn't exist.</li>
45   <li>I've modified a Makefile in my source tree, but my build tree keeps using
46   the old version.  What do I do?</li>
47   <li>I've upgraded to a new version of LLVM, and I get strange build
48   errors.</li>
49   <li>I've built LLVM and am testing it, but the tests freeze.</li>
50   <li>Why do test results differ when I perform different types of builds?</li>
51   </ol></li>
52 </ol>
53
54 <!-- *********************************************************************** -->
55 <div class="doc_section">
56   <a name="license">License</a>
57 </div>
58 <!-- *********************************************************************** -->
59
60 <div class="question">
61 <p>Why are the LLVM source code and the front-end distributed under different
62 licenses?</p>
63 </div>
64         
65 <div class="answer">
66 <p>The C/C++ front-ends are based on GCC and must be distributed under the GPL.
67 Our aim is to distribute LLVM source code under a <em>much less restrictive</em>
68 license, in particular one that does not compel users who distribute tools based
69 on modifying the source to redistribute the modified source code as well.</p>
70 </div>
71
72 <div class="question">
73 <p>Does the University of Illinois Open Source License really qualify as an
74 "open source" license?</p>
75 </div>
76
77 <div class="answer">
78 <p>Yes, the license is <a
79 href="http://www.opensource.org/licenses/UoI-NCSA.php">certified</a> by the Open
80 Source Initiative (OSI).</p>
81 </div>
82
83 <div class="question">
84 <p>Can I modify LLVM source code and redistribute the modified source?</p>
85 </div>
86
87 <div class="answer">
88 <p>Yes.  The modified source distribution must retain the copyright notice and
89 follow the three bulletted conditions listed in the <a
90 href="http://llvm.cs.uiuc.edu/releases/1.0/LICENSE.TXT">LLVM license</a>.</p>
91 </div>
92
93 <div class="question">
94 <p>Can I modify LLVM source code and redistribute binaries or other tools based
95 on it, without redistributing the source?</p>
96 </div>
97
98 <div class="answer">
99 <p>Yes, this is why we distribute LLVM under a less restrictive license than
100 GPL, as explained in the first question above.</p>
101 </div>
102
103 <!-- *********************************************************************** -->
104 <div class="doc_section">
105   <a name="source">Source Code</a>
106 </div>
107 <!-- *********************************************************************** -->
108
109 <div class="question">
110 <p>In what language is LLVM written?</p>
111 </div>
112
113 <div class="answer">
114 <p>All of the LLVM tools and libraries are written in C++ with extensive use of
115 the STL.</p>
116 </div>
117
118 <div class="question">
119 <p>How portable is the LLVM source code?</p>
120 </div>
121
122 <div class="answer">
123 <p>The LLVM source code should be portable to most modern UNIX-like operating
124 systems.  Most of the code is written in standard C++ with operating system
125 services abstracted to a support library.  The tools required to build and test
126 LLVM have been ported to a plethora of platforms.</p>
127
128 <p>Some porting problems may exist in the following areas:</p>
129
130 <ul>
131
132   <li>The GCC front end code is not as portable as the LLVM suite, so it may not
133   compile as well on unsupported platforms.</li>
134
135   <li>The Python test classes are more UNIX-centric than they should be, so
136   porting to non-UNIX like platforms (i.e. Windows, MacOS 9) will require some
137   effort.</li>
138
139   <li>The LLVM build system relies heavily on UNIX shell tools, like the Bourne
140   Shell and sed.  Porting to systems without these tools (MacOS 9, Plan 9) will
141   require more effort.</li>
142
143 </ul>
144
145 </div>
146
147 <!-- *********************************************************************** -->
148 <div class="doc_section">
149   <a name="build">Build Problems</a>
150 </div>
151 <!-- *********************************************************************** -->
152
153 <div class="question">
154 <p>When I run configure, it finds the wrong C compiler.</p>
155 </div>
156
157 <div class="answer">
158
159 <p>The <tt>configure</tt> script attempts to locate first <tt>gcc</tt> and then
160 <tt>cc</tt>, unless it finds compiler paths set in <tt>CC</tt> and <tt>CXX</tt>
161 for the C and C++ compiler, respectively.</p>
162
163 <p>If <tt>configure</tt> finds the wrong compiler, either adjust your
164 <tt>PATH</tt> environment variable or set <tt>CC</tt> and <tt>CXX</tt>
165 explicitly.</p>
166
167 </div>
168
169 <div class="question">
170 <p>I compile the code, and I get some error about <tt>/localhome</tt>.</p>
171 </div>
172
173 <div class="answer">
174
175 <p>There are several possible causes for this.  The first is that you didn't set
176 a pathname properly when using <tt>configure</tt>, and it defaulted to a
177 pathname that we use on our research machines.</p>
178
179 <p>Another possibility is that we hardcoded a path in our Makefiles.  If you see
180 this, please email the LLVM bug mailing list with the name of the offending
181 Makefile and a description of what is wrong with it.</p>
182
183 </div>
184
185 <div class="question">
186 <p>The <tt>configure</tt> script finds the right C compiler, but it uses the
187 LLVM linker from a previous build.  What do I do?</p>
188 </div>
189
190 <div class="answer">
191 <p>The <tt>configure</tt> script uses the <tt>PATH</tt> to find executables, so
192 if it's grabbing the wrong linker/assembler/etc, there are two ways to fix
193 it:</p>
194
195 <ol>
196                 
197   <li><p>Adjust your <tt>PATH</tt> environment variable so that the correct
198   program appears first in the <tt>PATH</tt>.  This may work, but may not be
199   convenient when you want them <i>first</i> in your path for other
200   work.</p></li>
201
202   <li><p>Run <tt>configure</tt> with an alternative <tt>PATH</tt> that is
203   correct. In a Borne compatible shell, the syntax would be:</p>
204                 
205       <p><tt>PATH=<the path without the bad program> ./configure ...</tt></p>
206
207       <p>This is still somewhat inconvenient, but it allows <tt>configure</tt>
208       to do its work without having to adjust your <tt>PATH</tt>
209       permanently.</p></li>
210         
211 </ol>
212
213 </div>
214
215 <div class="question">
216 <p>When creating a dynamic library, I get a strange GLIBC error.</p>
217 </div>
218
219 <div class="answer">
220 <p>Under some operating systems (i.e. Linux), libtool does not work correctly if
221 GCC was compiled with the --disable-shared option.  To work around this, install
222 your own version of GCC that has shared libraries enabled by default.</p>
223 </div>
224
225 <div class="question">
226 <p>I've updated my source tree from CVS, and now my build is trying to use a
227 file/directory that doesn't exist.</p>
228 </div>
229
230 <div class="answer">
231 <p>You need to re-run configure in your object directory.  When new Makefiles
232 are added to the source tree, they have to be copied over to the object tree in
233 order to be used by the build.</p>
234 </div>
235
236 <div class="question">
237 <p>I've modified a Makefile in my source tree, but my build tree keeps using the
238 old version.  What do I do?</p>
239 </div>
240
241 <div class="answer">
242
243 <p>If the Makefile already exists in your object tree, you
244 can just run the following command in the top level directory of your object
245 tree:</p>
246
247 <p><tt>./config.status &lt;relative path to Makefile&gt;</tt><p>
248
249 <p>If the Makefile is new, you will have to modify the configure script to copy
250 it over.</p>
251
252 </div>
253
254 <div class="question">
255 <p>I've upgraded to a new version of LLVM, and I get strange build errors.</p>
256 </div>
257
258 <div class="answer">
259
260 <p>Sometimes, changes to the LLVM source code alters how the build system works.
261 Changes in libtool, autoconf, or header file dependencies are especially prone
262 to this sort of problem.</p>
263
264 <p>The best thing to try is to remove the old files and re-build.  In most
265 cases, this takes care of the problem.  To do this, just type <tt>make
266 clean</tt> and then <tt>make</tt> in the directory that fails to build.</p>
267
268 </div>
269
270 <div class="question">
271 <p>I've built LLVM and am testing it, but the tests freeze.</p>
272 </div>
273
274 <div class="answer">
275
276 <p>This is most likely occurring because you built a profile or release
277 (optimized) build of LLVM and have not specified the same information on the
278 <tt>gmake</tt> command line.</p>
279
280 <p>For example, if you built LLVM with the command:</p>
281
282 <p><tt>gmake ENABLE_PROFILING=1</tt>
283
284 <p>...then you must run the tests with the following commands:</p>
285
286 <p><tt>cd llvm/test<br>gmake  ENABLE_PROFILING=1</tt></p>
287
288 </div>
289
290 <div class="question">
291 <p>Why do test results differ when I perform different types of builds?</p>
292 </div>
293
294 <div class="answer">
295
296 <p>The LLVM test suite is dependent upon several features of the LLVM tools and
297 libraries.</p>
298
299 <p>First, the debugging assertions in code are not enabled in optimized or
300 profiling builds.  Hence, tests that used to fail may pass.</p>
301         
302 <p>Second, some tests may rely upon debugging options or behavior that is only
303 available in the debug build.  These tests will fail in an optimized or profile
304 build.</p>
305
306 </div>
307
308 <!-- *********************************************************************** -->
309 <div class="doc_section">
310   <a name="cfe">GCC Front End</a>
311 </div>
312
313 <div class="question">
314 <p>
315 When I compile software that uses a configure script, the configure script
316 thinks my system has all of the header files and libraries it is testing for.
317 How do I get configure to work correctly?
318 </p>
319 </div>
320
321 <div class="answer">
322 <p>
323 The configure script is getting things wrong because the LLVM linker allows
324 symbols to be undefined at link time (so that they can be resolved during JIT
325 or translation to the C back end).  That is why configure thinks your system
326 "has everything."
327 </p>
328 <p>
329 To work around this, perform the following steps:
330 </p>
331
332 <ol>
333   <li>
334   Make sure the CC and CXX environment variables contains the full path to the
335   LLVM GCC front end.
336   </li>
337
338   <li>
339   Make sure that the regular C compiler is first in your PATH.
340   </li>
341
342   <li>
343   Add the string "-Wl,-native" to your CFLAGS environment variable.
344   </li>
345 </ol>
346
347 <p>
348 This will allow the gccld linker to create a native code executable instead of
349 a shell script that runs the JIT.  Creating native code requires standard
350 linkage, which in turn will allow the configure script to find out if code is
351 not linking on your system because the feature isn't available on your system.
352 </p>
353 </div>
354
355 <div class="question"
356 <p>
357 When I compile code using the LLVM GCC front end, it complains that it cannot
358 find crtend.o.
359 </p>
360 </div>
361
362 <div class="answer"
363 <p>
364 In order to find crtend.o, you must have the directory in which it lives in
365 your LLVM_LIB_SEARCH_PATH environment variable.  For the binary distribution of
366 the LLVM GCC front end, this will be the full path of the bytecode-libs
367 directory inside of the LLVM GCC distribution.
368 </p>
369 </div>
370 <!-- *********************************************************************** -->
371 <!-- *********************************************************************** -->
372
373 <hr>
374 <div class="doc_footer">
375   <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a>
376   <br>
377   Last modified: $Date$
378 </div>
379
380 </body>
381 </html>