blob: 9db6cc7d18239ed29644f4e79f32933148767416 [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>
Misha Brukman7ce62cc2004-06-01 18:51:03 +00006 <style type="text/css">
Misha Brukmana6538852003-11-06 21:55:44 +00007 @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>
John Criswelld1799612004-03-29 20:23:11 +000052 <li>When I use the test suite, all of the C Backend tests fail. What is
53 wrong?</li>
Misha Brukman1739aec2004-09-09 16:36:47 +000054 <li>After CVS update, rebuilding gives the error "No rule to make
55 target".</li>
Misha Brukmana6538852003-11-06 21:55:44 +000056 </ol></li>
John Criswell76c1e382003-11-18 16:08:49 +000057
Chris Lattnercc33d702003-11-19 05:53:12 +000058 <li><a href="#cfe">Using the GCC Front End</a>
John Criswell76c1e382003-11-18 16:08:49 +000059 <ol>
60 <li>
61 When I compile software that uses a configure script, the configure script
62 thinks my system has all of the header files and libraries it is testing
63 for. How do I get configure to work correctly?
64 </li>
65
66 <li>
67 When I compile code using the LLVM GCC front end, it complains that it
Chris Lattner7911ce22004-05-23 21:07:27 +000068 cannot find libcrtend.a.
John Criswell76c1e382003-11-18 16:08:49 +000069 </li>
70 </ol>
71 </li>
Chris Lattnercc33d702003-11-19 05:53:12 +000072
73 <li><a href="#cfe_code">Questions about code generated by the GCC front-end</a>
74 <ol>
75 <li>What is this <tt>__main()</tt> call that gets inserted into
76 <tt>main()</tt>?</li>
Chris Lattnera28e3ce2003-12-16 22:33:55 +000077 <li>Where did all of my code go??</li>
Chris Lattnerc50bbc92004-03-29 19:14:35 +000078 <li>What is this <tt>llvm.global_ctors</tt> and
79 <tt>_GLOBAL__I__tmp_webcompile...</tt> stuff that happens when I
80 #include &lt;iostream&gt;?</li>
Chris Lattnercc33d702003-11-19 05:53:12 +000081 </ol>
82 </li>
Misha Brukmana6538852003-11-06 21:55:44 +000083</ol>
84
Chris Lattner7911ce22004-05-23 21:07:27 +000085<div class="doc_author">
86 <p>Written by <a href="http://llvm.cs.uiuc.edu">The LLVM Team</a></p>
87</div>
88
89
Misha Brukmana6538852003-11-06 21:55:44 +000090<!-- *********************************************************************** -->
91<div class="doc_section">
92 <a name="license">License</a>
93</div>
94<!-- *********************************************************************** -->
95
96<div class="question">
97<p>Why are the LLVM source code and the front-end distributed under different
98licenses?</p>
99</div>
100
101<div class="answer">
102<p>The C/C++ front-ends are based on GCC and must be distributed under the GPL.
103Our aim is to distribute LLVM source code under a <em>much less restrictive</em>
104license, in particular one that does not compel users who distribute tools based
105on modifying the source to redistribute the modified source code as well.</p>
106</div>
107
108<div class="question">
109<p>Does the University of Illinois Open Source License really qualify as an
110"open source" license?</p>
111</div>
112
113<div class="answer">
114<p>Yes, the license is <a
115href="http://www.opensource.org/licenses/UoI-NCSA.php">certified</a> by the Open
116Source Initiative (OSI).</p>
117</div>
118
119<div class="question">
120<p>Can I modify LLVM source code and redistribute the modified source?</p>
121</div>
122
123<div class="answer">
124<p>Yes. The modified source distribution must retain the copyright notice and
125follow the three bulletted conditions listed in the <a
Misha Brukman237dc2a2004-12-03 23:58:18 +0000126href="http://llvm.cs.uiuc.edu/releases/1.3/LICENSE.TXT">LLVM license</a>.</p>
Misha Brukmana6538852003-11-06 21:55:44 +0000127</div>
128
129<div class="question">
130<p>Can I modify LLVM source code and redistribute binaries or other tools based
131on it, without redistributing the source?</p>
132</div>
133
134<div class="answer">
135<p>Yes, this is why we distribute LLVM under a less restrictive license than
136GPL, as explained in the first question above.</p>
137</div>
138
139<!-- *********************************************************************** -->
140<div class="doc_section">
141 <a name="source">Source Code</a>
142</div>
143<!-- *********************************************************************** -->
144
145<div class="question">
146<p>In what language is LLVM written?</p>
147</div>
148
149<div class="answer">
150<p>All of the LLVM tools and libraries are written in C++ with extensive use of
151the STL.</p>
152</div>
153
154<div class="question">
155<p>How portable is the LLVM source code?</p>
156</div>
157
158<div class="answer">
159<p>The LLVM source code should be portable to most modern UNIX-like operating
160systems. Most of the code is written in standard C++ with operating system
161services abstracted to a support library. The tools required to build and test
162LLVM have been ported to a plethora of platforms.</p>
163
164<p>Some porting problems may exist in the following areas:</p>
165
166<ul>
167
168 <li>The GCC front end code is not as portable as the LLVM suite, so it may not
169 compile as well on unsupported platforms.</li>
170
Misha Brukmana6538852003-11-06 21:55:44 +0000171 <li>The LLVM build system relies heavily on UNIX shell tools, like the Bourne
172 Shell and sed. Porting to systems without these tools (MacOS 9, Plan 9) will
173 require more effort.</li>
174
175</ul>
176
177</div>
178
179<!-- *********************************************************************** -->
180<div class="doc_section">
181 <a name="build">Build Problems</a>
182</div>
183<!-- *********************************************************************** -->
184
185<div class="question">
186<p>When I run configure, it finds the wrong C compiler.</p>
187</div>
188
189<div class="answer">
190
191<p>The <tt>configure</tt> script attempts to locate first <tt>gcc</tt> and then
192<tt>cc</tt>, unless it finds compiler paths set in <tt>CC</tt> and <tt>CXX</tt>
193for the C and C++ compiler, respectively.</p>
194
195<p>If <tt>configure</tt> finds the wrong compiler, either adjust your
196<tt>PATH</tt> environment variable or set <tt>CC</tt> and <tt>CXX</tt>
197explicitly.</p>
198
199</div>
200
201<div class="question">
202<p>I compile the code, and I get some error about <tt>/localhome</tt>.</p>
203</div>
204
205<div class="answer">
206
207<p>There are several possible causes for this. The first is that you didn't set
208a pathname properly when using <tt>configure</tt>, and it defaulted to a
209pathname that we use on our research machines.</p>
210
211<p>Another possibility is that we hardcoded a path in our Makefiles. If you see
212this, please email the LLVM bug mailing list with the name of the offending
213Makefile and a description of what is wrong with it.</p>
214
215</div>
216
217<div class="question">
218<p>The <tt>configure</tt> script finds the right C compiler, but it uses the
219LLVM linker from a previous build. What do I do?</p>
220</div>
221
222<div class="answer">
223<p>The <tt>configure</tt> script uses the <tt>PATH</tt> to find executables, so
224if it's grabbing the wrong linker/assembler/etc, there are two ways to fix
225it:</p>
226
227<ol>
228
229 <li><p>Adjust your <tt>PATH</tt> environment variable so that the correct
230 program appears first in the <tt>PATH</tt>. This may work, but may not be
231 convenient when you want them <i>first</i> in your path for other
232 work.</p></li>
233
234 <li><p>Run <tt>configure</tt> with an alternative <tt>PATH</tt> that is
235 correct. In a Borne compatible shell, the syntax would be:</p>
236
Misha Brukman7ce62cc2004-06-01 18:51:03 +0000237 <p><tt>PATH=[the path without the bad program] ./configure ...</tt></p>
Misha Brukmana6538852003-11-06 21:55:44 +0000238
239 <p>This is still somewhat inconvenient, but it allows <tt>configure</tt>
240 to do its work without having to adjust your <tt>PATH</tt>
241 permanently.</p></li>
242
243</ol>
244
245</div>
246
247<div class="question">
248<p>When creating a dynamic library, I get a strange GLIBC error.</p>
249</div>
250
251<div class="answer">
252<p>Under some operating systems (i.e. Linux), libtool does not work correctly if
253GCC was compiled with the --disable-shared option. To work around this, install
254your own version of GCC that has shared libraries enabled by default.</p>
255</div>
256
257<div class="question">
258<p>I've updated my source tree from CVS, and now my build is trying to use a
259file/directory that doesn't exist.</p>
260</div>
261
262<div class="answer">
263<p>You need to re-run configure in your object directory. When new Makefiles
264are added to the source tree, they have to be copied over to the object tree in
265order to be used by the build.</p>
266</div>
267
268<div class="question">
269<p>I've modified a Makefile in my source tree, but my build tree keeps using the
270old version. What do I do?</p>
271</div>
272
273<div class="answer">
274
275<p>If the Makefile already exists in your object tree, you
276can just run the following command in the top level directory of your object
277tree:</p>
278
279<p><tt>./config.status &lt;relative path to Makefile&gt;</tt><p>
280
281<p>If the Makefile is new, you will have to modify the configure script to copy
282it over.</p>
283
284</div>
285
286<div class="question">
287<p>I've upgraded to a new version of LLVM, and I get strange build errors.</p>
288</div>
289
290<div class="answer">
291
292<p>Sometimes, changes to the LLVM source code alters how the build system works.
293Changes in libtool, autoconf, or header file dependencies are especially prone
294to this sort of problem.</p>
295
296<p>The best thing to try is to remove the old files and re-build. In most
297cases, this takes care of the problem. To do this, just type <tt>make
298clean</tt> and then <tt>make</tt> in the directory that fails to build.</p>
299
300</div>
301
302<div class="question">
303<p>I've built LLVM and am testing it, but the tests freeze.</p>
304</div>
305
306<div class="answer">
307
308<p>This is most likely occurring because you built a profile or release
309(optimized) build of LLVM and have not specified the same information on the
310<tt>gmake</tt> command line.</p>
311
312<p>For example, if you built LLVM with the command:</p>
313
314<p><tt>gmake ENABLE_PROFILING=1</tt>
315
316<p>...then you must run the tests with the following commands:</p>
317
318<p><tt>cd llvm/test<br>gmake ENABLE_PROFILING=1</tt></p>
319
320</div>
321
322<div class="question">
323<p>Why do test results differ when I perform different types of builds?</p>
324</div>
325
326<div class="answer">
327
328<p>The LLVM test suite is dependent upon several features of the LLVM tools and
329libraries.</p>
330
331<p>First, the debugging assertions in code are not enabled in optimized or
332profiling builds. Hence, tests that used to fail may pass.</p>
333
334<p>Second, some tests may rely upon debugging options or behavior that is only
335available in the debug build. These tests will fail in an optimized or profile
336build.</p>
337
338</div>
339
Chris Lattner8a0b9242003-12-08 05:43:19 +0000340<div class="question">
Chris Lattner306acee2003-12-22 04:06:12 +0000341<p>Compiling LLVM with GCC 3.3.2 fails, what should I do?</p>
Chris Lattner8a0b9242003-12-08 05:43:19 +0000342</div>
343
344<div class="answer">
Chris Lattner306acee2003-12-22 04:06:12 +0000345<p>This is <a href="http://gcc.gnu.org/PR?13392">a bug in GCC</a>, and
346 affects projects other than LLVM. Try upgrading or downgrading your GCC.</p>
Chris Lattner8a0b9242003-12-08 05:43:19 +0000347</div>
348
John Criswelld1799612004-03-29 20:23:11 +0000349<div class="question">
350<p>
351When I use the test suite, all of the C Backend tests fail. What is
352wrong?
353</p>
354</div>
355
356<div class="answer">
357<p>
358If you build LLVM and the C Backend tests fail in <tt>llvm/test/Programs</tt>,
359then chances are good that the directory pointed to by the LLVM_LIB_SEARCH_PATH
360environment variable does not contain the libcrtend.a library.
361</p>
362
363<p>
364To fix it, verify that LLVM_LIB_SEARCH_PATH points to the correct directory
365and that libcrtend.a is inside. For pre-built LLVM GCC front ends, this
366should be the absolute path to
Reid Spencer201ddef2004-12-14 22:07:29 +0000367<tt>cfrontend/&lt;<i>platform</i>&gt;/llvm-gcc/lib</tt>. If you've
John Criswelld1799612004-03-29 20:23:11 +0000368built your own LLVM GCC front end, then ensure that you've built and installed
369the libraries in <tt>llvm/runtime</tt> and have LLVM_LIB_SEARCH_PATH pointing
Reid Spencer201ddef2004-12-14 22:07:29 +0000370to the <tt>$LLVMGCCDIR/lib</tt> subdirectory.
John Criswelld1799612004-03-29 20:23:11 +0000371</p>
372</div>
373
Misha Brukman1739aec2004-09-09 16:36:47 +0000374<div class="question">
375<p>After CVS update, rebuilding gives the error "No rule to make target".</p>
376</div>
377
378<div class="answer">
379<p>If the error is of the form:</p>
380
381<div class="doc_code">
382<tt>
383gmake[2]: *** No rule to make target `/path/to/somefile', needed by
384`/path/to/another/file.d'.<br>
385Stop.
386</tt>
387</div>
388
389<p>This may occur anytime files are moved within the CVS repository or removed
390entirely. In this case, the best solution is to erase all <tt>.d</tt> files,
391which list dependencies for source files, and rebuild:</p>
392
393<div class="doc_code">
394<pre>
395% cd $LLVM_OBJ_DIR
396% rm -f `find . -name \*\.d`
397% gmake
398</pre>
399</div>
400
401<p>In other cases, it may be necessary to run <tt>make clean</tt> before
402rebuilding.</p>
403</div>
404
Misha Brukmana6538852003-11-06 21:55:44 +0000405<!-- *********************************************************************** -->
John Criswell6ea30b02003-11-18 16:05:23 +0000406<div class="doc_section">
Chris Lattnercc33d702003-11-19 05:53:12 +0000407 <a name="cfe">Using the GCC Front End</a>
John Criswell6ea30b02003-11-18 16:05:23 +0000408</div>
409
410<div class="question">
411<p>
412When I compile software that uses a configure script, the configure script
413thinks my system has all of the header files and libraries it is testing for.
414How do I get configure to work correctly?
415</p>
416</div>
417
418<div class="answer">
419<p>
420The configure script is getting things wrong because the LLVM linker allows
421symbols to be undefined at link time (so that they can be resolved during JIT
422or translation to the C back end). That is why configure thinks your system
423"has everything."
424</p>
425<p>
426To work around this, perform the following steps:
427</p>
428
429<ol>
430 <li>
431 Make sure the CC and CXX environment variables contains the full path to the
432 LLVM GCC front end.
433 </li>
434
435 <li>
436 Make sure that the regular C compiler is first in your PATH.
437 </li>
438
439 <li>
440 Add the string "-Wl,-native" to your CFLAGS environment variable.
441 </li>
442</ol>
443
444<p>
445This will allow the gccld linker to create a native code executable instead of
446a shell script that runs the JIT. Creating native code requires standard
447linkage, which in turn will allow the configure script to find out if code is
448not linking on your system because the feature isn't available on your system.
449</p>
450</div>
451
Chris Lattnercc33d702003-11-19 05:53:12 +0000452<div class="question">
John Criswell6ea30b02003-11-18 16:05:23 +0000453<p>
454When I compile code using the LLVM GCC front end, it complains that it cannot
John Criswellcd161192004-03-12 18:20:15 +0000455find libcrtend.a.
John Criswell6ea30b02003-11-18 16:05:23 +0000456</p>
457</div>
458
Chris Lattnercc33d702003-11-19 05:53:12 +0000459<div class="answer">
John Criswell6ea30b02003-11-18 16:05:23 +0000460<p>
John Criswellcd161192004-03-12 18:20:15 +0000461In order to find libcrtend.a, you must have the directory in which it lives in
John Criswell6ea30b02003-11-18 16:05:23 +0000462your LLVM_LIB_SEARCH_PATH environment variable. For the binary distribution of
Reid Spencer201ddef2004-12-14 22:07:29 +0000463the LLVM GCC front end, this will be the full path of the <tt>lib</tt>
John Criswell6ea30b02003-11-18 16:05:23 +0000464directory inside of the LLVM GCC distribution.
465</p>
466</div>
Chris Lattnercc33d702003-11-19 05:53:12 +0000467
468
469<!-- *********************************************************************** -->
470<div class="doc_section">
471 <a name="cfe_code">Questions about code generated by the GCC front-end</a>
472</div>
473
Chris Lattnera28e3ce2003-12-16 22:33:55 +0000474<div class="question"><p>
Chris Lattnercc33d702003-11-19 05:53:12 +0000475What is this <tt>__main()</tt> call that gets inserted into <tt>main()</tt>?
Chris Lattnera28e3ce2003-12-16 22:33:55 +0000476</p></div>
Chris Lattnercc33d702003-11-19 05:53:12 +0000477
478<div class="answer">
479<p>
480The <tt>__main</tt> call is inserted by the C/C++ compiler in order to guarantee
481that static constructors and destructors are called when the program starts up
482and shuts down. In C, you can create static constructors and destructors by
483using GCC extensions, and in C++ you can do so by creating a global variable
484whose class has a ctor or dtor.
485</p>
486
487<p>
488The actual implementation of <tt>__main</tt> lives in the
489<tt>llvm/runtime/GCCLibraries/crtend/</tt> directory in the source-base, and is
490linked in automatically when you link the program.
491</p>
Chris Lattnercc33d702003-11-19 05:53:12 +0000492</div>
493
Chris Lattnera28e3ce2003-12-16 22:33:55 +0000494<!--=========================================================================-->
Chris Lattnercc33d702003-11-19 05:53:12 +0000495
Chris Lattnera28e3ce2003-12-16 22:33:55 +0000496<div class="question"><p>
497Where did all of my code go??
498</p></div>
499
500<div class="answer">
501<p>
502If you are using the LLVM demo page, you may often wonder what happened to all
503of the code that you typed in. Remember that the demo script is running the
John Criswell02f61c12003-12-23 22:22:10 +0000504code through the LLVM optimizers, so if your code doesn't actually do anything
Chris Lattnera28e3ce2003-12-16 22:33:55 +0000505useful, it might all be deleted.
506</p>
507
508<p>
509To prevent this, make sure that the code is actually needed. For example, if
510you are computing some expression, return the value from the function instead of
511leaving it in a local variable. If you really want to constrain the optimizer,
512you can read from and assign to <tt>volatile</tt> global variables.
513</p>
514</div>
Chris Lattnercc33d702003-11-19 05:53:12 +0000515
Chris Lattnerc50bbc92004-03-29 19:14:35 +0000516<!--=========================================================================-->
517
Misha Brukman237dc2a2004-12-03 23:58:18 +0000518<div class="question">
519<p> What is this <tt>llvm.global_ctors</tt> and
520<tt>_GLOBAL__I__tmp_webcompile...</tt> stuff that happens when I #include
521&lt;iostream&gt;?</p>
522</div>
Chris Lattnerc50bbc92004-03-29 19:14:35 +0000523
524<div class="answer">
Misha Brukman237dc2a2004-12-03 23:58:18 +0000525
526<p>If you #include the &lt;iostream&gt; header into a C++ translation unit, the
Chris Lattnerc50bbc92004-03-29 19:14:35 +0000527file will probably use the <tt>std::cin</tt>/<tt>std::cout</tt>/... global
528objects. However, C++ does not guarantee an order of initialization between
529static objects in different translation units, so if a static ctor/dtor in your
530.cpp file used <tt>std::cout</tt>, for example, the object would not necessarily
Misha Brukman237dc2a2004-12-03 23:58:18 +0000531be automatically initialized before your use.</p>
Chris Lattnerc50bbc92004-03-29 19:14:35 +0000532
Misha Brukman237dc2a2004-12-03 23:58:18 +0000533<p>To make <tt>std::cout</tt> and friends work correctly in these scenarios, the
Chris Lattnerc50bbc92004-03-29 19:14:35 +0000534STL that we use declares a static object that gets created in every translation
Misha Brukman237dc2a2004-12-03 23:58:18 +0000535unit that includes <tt>&lt;iostream&gt;</tt>. This object has a static
536constructor and destructor that initializes and destroys the global iostream
537objects before they could possibly be used in the file. The code that you see
538in the .ll file corresponds to the constructor and destructor registration code.
Chris Lattnerc50bbc92004-03-29 19:14:35 +0000539</p>
540
Misha Brukman237dc2a2004-12-03 23:58:18 +0000541<p>If you would like to make it easier to <b>understand</b> the LLVM code
542generated by the compiler in the demo page, consider using <tt>printf()</tt>
543instead of <tt>iostream</tt>s to print values.</p>
544
Chris Lattnerc50bbc92004-03-29 19:14:35 +0000545</div>
546
John Criswell6ea30b02003-11-18 16:05:23 +0000547<!-- *********************************************************************** -->
John Criswellc310f622003-10-13 16:13:06 +0000548
549<hr>
Misha Brukman7ce62cc2004-06-01 18:51:03 +0000550<address>
551 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
552 src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
553 <a href="http://validator.w3.org/check/referer"><img
554 src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
555
556 <a href="http://llvm.cs.uiuc.edu">LLVM Compiler Infrastructure</a><br>
Misha Brukmana6538852003-11-06 21:55:44 +0000557 Last modified: $Date$
Misha Brukman7ce62cc2004-06-01 18:51:03 +0000558</address>
John Criswellf08c5d82003-10-24 22:48:20 +0000559
John Criswellc310f622003-10-13 16:13:06 +0000560</body>
561</html>