blob: 87e6c13f3565445fb20206bd546df825327da60e [file] [log] [blame]
Misha Brukmana6538852003-11-06 21:55:44 +00001<!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>
John Criswellc310f622003-10-13 16:13:06 +000013
Misha Brukmana6538852003-11-06 21:55:44 +000014<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>
Chris Lattner306acee2003-12-22 04:06:12 +000051 <li>Compiling LLVM with GCC 3.3.2 fails, what should I do?</li>
Misha Brukmana6538852003-11-06 21:55:44 +000052 </ol></li>
John Criswell76c1e382003-11-18 16:08:49 +000053
Chris Lattnercc33d702003-11-19 05:53:12 +000054 <li><a href="#cfe">Using the GCC Front End</a>
John Criswell76c1e382003-11-18 16:08:49 +000055 <ol>
56 <li>
57 When I compile software that uses a configure script, the configure script
58 thinks my system has all of the header files and libraries it is testing
59 for. How do I get configure to work correctly?
60 </li>
61
62 <li>
63 When I compile code using the LLVM GCC front end, it complains that it
64 cannot find crtend.o.
65 </li>
66 </ol>
67 </li>
Chris Lattnercc33d702003-11-19 05:53:12 +000068
69 <li><a href="#cfe_code">Questions about code generated by the GCC front-end</a>
70 <ol>
71 <li>What is this <tt>__main()</tt> call that gets inserted into
72 <tt>main()</tt>?</li>
Chris Lattnera28e3ce2003-12-16 22:33:55 +000073 <li>Where did all of my code go??</li>
Chris Lattnerc50bbc92004-03-29 19:14:35 +000074 <li>What is this <tt>llvm.global_ctors</tt> and
75 <tt>_GLOBAL__I__tmp_webcompile...</tt> stuff that happens when I
76 #include &lt;iostream&gt;?</li>
Chris Lattnercc33d702003-11-19 05:53:12 +000077 </ol>
78 </li>
Misha Brukmana6538852003-11-06 21:55:44 +000079</ol>
80
81<!-- *********************************************************************** -->
82<div class="doc_section">
83 <a name="license">License</a>
84</div>
85<!-- *********************************************************************** -->
86
87<div class="question">
88<p>Why are the LLVM source code and the front-end distributed under different
89licenses?</p>
90</div>
91
92<div class="answer">
93<p>The C/C++ front-ends are based on GCC and must be distributed under the GPL.
94Our aim is to distribute LLVM source code under a <em>much less restrictive</em>
95license, in particular one that does not compel users who distribute tools based
96on modifying the source to redistribute the modified source code as well.</p>
97</div>
98
99<div class="question">
100<p>Does the University of Illinois Open Source License really qualify as an
101"open source" license?</p>
102</div>
103
104<div class="answer">
105<p>Yes, the license is <a
106href="http://www.opensource.org/licenses/UoI-NCSA.php">certified</a> by the Open
107Source Initiative (OSI).</p>
108</div>
109
110<div class="question">
111<p>Can I modify LLVM source code and redistribute the modified source?</p>
112</div>
113
114<div class="answer">
115<p>Yes. The modified source distribution must retain the copyright notice and
116follow the three bulletted conditions listed in the <a
John Criswellcd161192004-03-12 18:20:15 +0000117href="http://llvm.cs.uiuc.edu/releases/1.2/LICENSE.TXT">LLVM license</a>.</p>
Misha Brukmana6538852003-11-06 21:55:44 +0000118</div>
119
120<div class="question">
121<p>Can I modify LLVM source code and redistribute binaries or other tools based
122on it, without redistributing the source?</p>
123</div>
124
125<div class="answer">
126<p>Yes, this is why we distribute LLVM under a less restrictive license than
127GPL, as explained in the first question above.</p>
128</div>
129
130<!-- *********************************************************************** -->
131<div class="doc_section">
132 <a name="source">Source Code</a>
133</div>
134<!-- *********************************************************************** -->
135
136<div class="question">
137<p>In what language is LLVM written?</p>
138</div>
139
140<div class="answer">
141<p>All of the LLVM tools and libraries are written in C++ with extensive use of
142the STL.</p>
143</div>
144
145<div class="question">
146<p>How portable is the LLVM source code?</p>
147</div>
148
149<div class="answer">
150<p>The LLVM source code should be portable to most modern UNIX-like operating
151systems. Most of the code is written in standard C++ with operating system
152services abstracted to a support library. The tools required to build and test
153LLVM have been ported to a plethora of platforms.</p>
154
155<p>Some porting problems may exist in the following areas:</p>
156
157<ul>
158
159 <li>The GCC front end code is not as portable as the LLVM suite, so it may not
160 compile as well on unsupported platforms.</li>
161
162 <li>The Python test classes are more UNIX-centric than they should be, so
163 porting to non-UNIX like platforms (i.e. Windows, MacOS 9) will require some
164 effort.</li>
165
166 <li>The LLVM build system relies heavily on UNIX shell tools, like the Bourne
167 Shell and sed. Porting to systems without these tools (MacOS 9, Plan 9) will
168 require more effort.</li>
169
170</ul>
171
172</div>
173
174<!-- *********************************************************************** -->
175<div class="doc_section">
176 <a name="build">Build Problems</a>
177</div>
178<!-- *********************************************************************** -->
179
180<div class="question">
181<p>When I run configure, it finds the wrong C compiler.</p>
182</div>
183
184<div class="answer">
185
186<p>The <tt>configure</tt> script attempts to locate first <tt>gcc</tt> and then
187<tt>cc</tt>, unless it finds compiler paths set in <tt>CC</tt> and <tt>CXX</tt>
188for the C and C++ compiler, respectively.</p>
189
190<p>If <tt>configure</tt> finds the wrong compiler, either adjust your
191<tt>PATH</tt> environment variable or set <tt>CC</tt> and <tt>CXX</tt>
192explicitly.</p>
193
194</div>
195
196<div class="question">
197<p>I compile the code, and I get some error about <tt>/localhome</tt>.</p>
198</div>
199
200<div class="answer">
201
202<p>There are several possible causes for this. The first is that you didn't set
203a pathname properly when using <tt>configure</tt>, and it defaulted to a
204pathname that we use on our research machines.</p>
205
206<p>Another possibility is that we hardcoded a path in our Makefiles. If you see
207this, please email the LLVM bug mailing list with the name of the offending
208Makefile and a description of what is wrong with it.</p>
209
210</div>
211
212<div class="question">
213<p>The <tt>configure</tt> script finds the right C compiler, but it uses the
214LLVM linker from a previous build. What do I do?</p>
215</div>
216
217<div class="answer">
218<p>The <tt>configure</tt> script uses the <tt>PATH</tt> to find executables, so
219if it's grabbing the wrong linker/assembler/etc, there are two ways to fix
220it:</p>
221
222<ol>
223
224 <li><p>Adjust your <tt>PATH</tt> environment variable so that the correct
225 program appears first in the <tt>PATH</tt>. This may work, but may not be
226 convenient when you want them <i>first</i> in your path for other
227 work.</p></li>
228
229 <li><p>Run <tt>configure</tt> with an alternative <tt>PATH</tt> that is
230 correct. In a Borne compatible shell, the syntax would be:</p>
231
232 <p><tt>PATH=<the path without the bad program> ./configure ...</tt></p>
233
234 <p>This is still somewhat inconvenient, but it allows <tt>configure</tt>
235 to do its work without having to adjust your <tt>PATH</tt>
236 permanently.</p></li>
237
238</ol>
239
240</div>
241
242<div class="question">
243<p>When creating a dynamic library, I get a strange GLIBC error.</p>
244</div>
245
246<div class="answer">
247<p>Under some operating systems (i.e. Linux), libtool does not work correctly if
248GCC was compiled with the --disable-shared option. To work around this, install
249your own version of GCC that has shared libraries enabled by default.</p>
250</div>
251
252<div class="question">
253<p>I've updated my source tree from CVS, and now my build is trying to use a
254file/directory that doesn't exist.</p>
255</div>
256
257<div class="answer">
258<p>You need to re-run configure in your object directory. When new Makefiles
259are added to the source tree, they have to be copied over to the object tree in
260order to be used by the build.</p>
261</div>
262
263<div class="question">
264<p>I've modified a Makefile in my source tree, but my build tree keeps using the
265old version. What do I do?</p>
266</div>
267
268<div class="answer">
269
270<p>If the Makefile already exists in your object tree, you
271can just run the following command in the top level directory of your object
272tree:</p>
273
274<p><tt>./config.status &lt;relative path to Makefile&gt;</tt><p>
275
276<p>If the Makefile is new, you will have to modify the configure script to copy
277it over.</p>
278
279</div>
280
281<div class="question">
282<p>I've upgraded to a new version of LLVM, and I get strange build errors.</p>
283</div>
284
285<div class="answer">
286
287<p>Sometimes, changes to the LLVM source code alters how the build system works.
288Changes in libtool, autoconf, or header file dependencies are especially prone
289to this sort of problem.</p>
290
291<p>The best thing to try is to remove the old files and re-build. In most
292cases, this takes care of the problem. To do this, just type <tt>make
293clean</tt> and then <tt>make</tt> in the directory that fails to build.</p>
294
295</div>
296
297<div class="question">
298<p>I've built LLVM and am testing it, but the tests freeze.</p>
299</div>
300
301<div class="answer">
302
303<p>This is most likely occurring because you built a profile or release
304(optimized) build of LLVM and have not specified the same information on the
305<tt>gmake</tt> command line.</p>
306
307<p>For example, if you built LLVM with the command:</p>
308
309<p><tt>gmake ENABLE_PROFILING=1</tt>
310
311<p>...then you must run the tests with the following commands:</p>
312
313<p><tt>cd llvm/test<br>gmake ENABLE_PROFILING=1</tt></p>
314
315</div>
316
317<div class="question">
318<p>Why do test results differ when I perform different types of builds?</p>
319</div>
320
321<div class="answer">
322
323<p>The LLVM test suite is dependent upon several features of the LLVM tools and
324libraries.</p>
325
326<p>First, the debugging assertions in code are not enabled in optimized or
327profiling builds. Hence, tests that used to fail may pass.</p>
328
329<p>Second, some tests may rely upon debugging options or behavior that is only
330available in the debug build. These tests will fail in an optimized or profile
331build.</p>
332
333</div>
334
Chris Lattner8a0b9242003-12-08 05:43:19 +0000335<div class="question">
Chris Lattner306acee2003-12-22 04:06:12 +0000336<p>Compiling LLVM with GCC 3.3.2 fails, what should I do?</p>
Chris Lattner8a0b9242003-12-08 05:43:19 +0000337</div>
338
339<div class="answer">
Chris Lattner306acee2003-12-22 04:06:12 +0000340<p>This is <a href="http://gcc.gnu.org/PR?13392">a bug in GCC</a>, and
341 affects projects other than LLVM. Try upgrading or downgrading your GCC.</p>
Chris Lattner8a0b9242003-12-08 05:43:19 +0000342</div>
343
Misha Brukmana6538852003-11-06 21:55:44 +0000344<!-- *********************************************************************** -->
John Criswell6ea30b02003-11-18 16:05:23 +0000345<div class="doc_section">
Chris Lattnercc33d702003-11-19 05:53:12 +0000346 <a name="cfe">Using the GCC Front End</a>
John Criswell6ea30b02003-11-18 16:05:23 +0000347</div>
348
349<div class="question">
350<p>
351When I compile software that uses a configure script, the configure script
352thinks my system has all of the header files and libraries it is testing for.
353How do I get configure to work correctly?
354</p>
355</div>
356
357<div class="answer">
358<p>
359The configure script is getting things wrong because the LLVM linker allows
360symbols to be undefined at link time (so that they can be resolved during JIT
361or translation to the C back end). That is why configure thinks your system
362"has everything."
363</p>
364<p>
365To work around this, perform the following steps:
366</p>
367
368<ol>
369 <li>
370 Make sure the CC and CXX environment variables contains the full path to the
371 LLVM GCC front end.
372 </li>
373
374 <li>
375 Make sure that the regular C compiler is first in your PATH.
376 </li>
377
378 <li>
379 Add the string "-Wl,-native" to your CFLAGS environment variable.
380 </li>
381</ol>
382
383<p>
384This will allow the gccld linker to create a native code executable instead of
385a shell script that runs the JIT. Creating native code requires standard
386linkage, which in turn will allow the configure script to find out if code is
387not linking on your system because the feature isn't available on your system.
388</p>
389</div>
390
Chris Lattnercc33d702003-11-19 05:53:12 +0000391<div class="question">
John Criswell6ea30b02003-11-18 16:05:23 +0000392<p>
393When I compile code using the LLVM GCC front end, it complains that it cannot
John Criswellcd161192004-03-12 18:20:15 +0000394find libcrtend.a.
John Criswell6ea30b02003-11-18 16:05:23 +0000395</p>
396</div>
397
Chris Lattnercc33d702003-11-19 05:53:12 +0000398<div class="answer">
John Criswell6ea30b02003-11-18 16:05:23 +0000399<p>
John Criswellcd161192004-03-12 18:20:15 +0000400In order to find libcrtend.a, you must have the directory in which it lives in
John Criswell6ea30b02003-11-18 16:05:23 +0000401your LLVM_LIB_SEARCH_PATH environment variable. For the binary distribution of
402the LLVM GCC front end, this will be the full path of the bytecode-libs
403directory inside of the LLVM GCC distribution.
404</p>
405</div>
Chris Lattnercc33d702003-11-19 05:53:12 +0000406
407
408<!-- *********************************************************************** -->
409<div class="doc_section">
410 <a name="cfe_code">Questions about code generated by the GCC front-end</a>
411</div>
412
Chris Lattnera28e3ce2003-12-16 22:33:55 +0000413<div class="question"><p>
Chris Lattnercc33d702003-11-19 05:53:12 +0000414What is this <tt>__main()</tt> call that gets inserted into <tt>main()</tt>?
Chris Lattnera28e3ce2003-12-16 22:33:55 +0000415</p></div>
Chris Lattnercc33d702003-11-19 05:53:12 +0000416
417<div class="answer">
418<p>
419The <tt>__main</tt> call is inserted by the C/C++ compiler in order to guarantee
420that static constructors and destructors are called when the program starts up
421and shuts down. In C, you can create static constructors and destructors by
422using GCC extensions, and in C++ you can do so by creating a global variable
423whose class has a ctor or dtor.
424</p>
425
426<p>
427The actual implementation of <tt>__main</tt> lives in the
428<tt>llvm/runtime/GCCLibraries/crtend/</tt> directory in the source-base, and is
429linked in automatically when you link the program.
430</p>
Chris Lattnercc33d702003-11-19 05:53:12 +0000431</div>
432
Chris Lattnera28e3ce2003-12-16 22:33:55 +0000433<!--=========================================================================-->
Chris Lattnercc33d702003-11-19 05:53:12 +0000434
Chris Lattnera28e3ce2003-12-16 22:33:55 +0000435<div class="question"><p>
436Where did all of my code go??
437</p></div>
438
439<div class="answer">
440<p>
441If you are using the LLVM demo page, you may often wonder what happened to all
442of the code that you typed in. Remember that the demo script is running the
John Criswell02f61c12003-12-23 22:22:10 +0000443code through the LLVM optimizers, so if your code doesn't actually do anything
Chris Lattnera28e3ce2003-12-16 22:33:55 +0000444useful, it might all be deleted.
445</p>
446
447<p>
448To prevent this, make sure that the code is actually needed. For example, if
449you are computing some expression, return the value from the function instead of
450leaving it in a local variable. If you really want to constrain the optimizer,
451you can read from and assign to <tt>volatile</tt> global variables.
452</p>
453</div>
Chris Lattnercc33d702003-11-19 05:53:12 +0000454
Chris Lattnerc50bbc92004-03-29 19:14:35 +0000455<!--=========================================================================-->
456
457<div class="question"><p>
458What is this <tt>llvm.global_ctors</tt> and <tt>_GLOBAL__I__tmp_webcompile...</tt> stuff that happens when I #include &lt;iostream&gt;?
459</p></div>
460
461<div class="answer">
462<p>
463If you #include the &lt;iostream&gt; header into a C++ translation unit, the
464file will probably use the <tt>std::cin</tt>/<tt>std::cout</tt>/... global
465objects. However, C++ does not guarantee an order of initialization between
466static objects in different translation units, so if a static ctor/dtor in your
467.cpp file used <tt>std::cout</tt>, for example, the object would not necessarily
468be automatically initialized before your use.
469</p>
470
471<p>
472To make <tt>std::cout</tt> and friends work correctly in these scenarios, the
473STL that we use declares a static object that gets created in every translation
474unit that includes &lt;iostream&gt;. This object has a static constructor and
475destructor that initializes and destroys the global iostream objects before they
476could possibly be used in the file. The code that you see in the .ll file
477corresponds to the constructor and destructor registration code.
478</p>
479
480<p>
481If you would like to make it easier to <b>understand</b> the LLVM code generated
482by the compiler in the demo page, consider using printf instead of iostreams to
483print values.
484</p>
485</div>
486
487
488 <li>
489
490
John Criswell6ea30b02003-11-18 16:05:23 +0000491<!-- *********************************************************************** -->
492<!-- *********************************************************************** -->
John Criswellc310f622003-10-13 16:13:06 +0000493
494<hr>
Misha Brukmana6538852003-11-06 21:55:44 +0000495<div class="doc_footer">
496 <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a>
497 <br>
498 Last modified: $Date$
499</div>
John Criswellf08c5d82003-10-24 22:48:20 +0000500
John Criswellc310f622003-10-13 16:13:06 +0000501</body>
502</html>