1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
5 <title>LLVM: Frequently Asked Questions</title>
7 @import url("llvm.css");
8 .question { font-weight: bold }
9 .answer { margin-left: 2em }
14 <div class="doc_title">
15 LLVM: Frequently Asked Questions
19 <li><a href="#license">License</a>
21 <li>Why are the LLVM source code and the front-end distributed under different
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>
30 <li><a href="#source">Source code</a>
32 <li>In what language is LLVM written?</li>
33 <li>How portable is the LLVM source code?</li>
36 <li><a href="#build">Build Problems</a>
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
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 <li>Compiling LLVM with GCC 3.3 on SuSE 9 fails, what should I do?</li>
54 <li><a href="#cfe">Using the GCC Front End</a>
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?
63 When I compile code using the LLVM GCC front end, it complains that it
69 <li><a href="#cfe_code">Questions about code generated by the GCC front-end</a>
71 <li>What is this <tt>__main()</tt> call that gets inserted into
77 <!-- *********************************************************************** -->
78 <div class="doc_section">
79 <a name="license">License</a>
81 <!-- *********************************************************************** -->
83 <div class="question">
84 <p>Why are the LLVM source code and the front-end distributed under different
89 <p>The C/C++ front-ends are based on GCC and must be distributed under the GPL.
90 Our aim is to distribute LLVM source code under a <em>much less restrictive</em>
91 license, in particular one that does not compel users who distribute tools based
92 on modifying the source to redistribute the modified source code as well.</p>
95 <div class="question">
96 <p>Does the University of Illinois Open Source License really qualify as an
97 "open source" license?</p>
101 <p>Yes, the license is <a
102 href="http://www.opensource.org/licenses/UoI-NCSA.php">certified</a> by the Open
103 Source Initiative (OSI).</p>
106 <div class="question">
107 <p>Can I modify LLVM source code and redistribute the modified source?</p>
111 <p>Yes. The modified source distribution must retain the copyright notice and
112 follow the three bulletted conditions listed in the <a
113 href="http://llvm.cs.uiuc.edu/releases/1.0/LICENSE.TXT">LLVM license</a>.</p>
116 <div class="question">
117 <p>Can I modify LLVM source code and redistribute binaries or other tools based
118 on it, without redistributing the source?</p>
122 <p>Yes, this is why we distribute LLVM under a less restrictive license than
123 GPL, as explained in the first question above.</p>
126 <!-- *********************************************************************** -->
127 <div class="doc_section">
128 <a name="source">Source Code</a>
130 <!-- *********************************************************************** -->
132 <div class="question">
133 <p>In what language is LLVM written?</p>
137 <p>All of the LLVM tools and libraries are written in C++ with extensive use of
141 <div class="question">
142 <p>How portable is the LLVM source code?</p>
146 <p>The LLVM source code should be portable to most modern UNIX-like operating
147 systems. Most of the code is written in standard C++ with operating system
148 services abstracted to a support library. The tools required to build and test
149 LLVM have been ported to a plethora of platforms.</p>
151 <p>Some porting problems may exist in the following areas:</p>
155 <li>The GCC front end code is not as portable as the LLVM suite, so it may not
156 compile as well on unsupported platforms.</li>
158 <li>The Python test classes are more UNIX-centric than they should be, so
159 porting to non-UNIX like platforms (i.e. Windows, MacOS 9) will require some
162 <li>The LLVM build system relies heavily on UNIX shell tools, like the Bourne
163 Shell and sed. Porting to systems without these tools (MacOS 9, Plan 9) will
164 require more effort.</li>
170 <!-- *********************************************************************** -->
171 <div class="doc_section">
172 <a name="build">Build Problems</a>
174 <!-- *********************************************************************** -->
176 <div class="question">
177 <p>When I run configure, it finds the wrong C compiler.</p>
182 <p>The <tt>configure</tt> script attempts to locate first <tt>gcc</tt> and then
183 <tt>cc</tt>, unless it finds compiler paths set in <tt>CC</tt> and <tt>CXX</tt>
184 for the C and C++ compiler, respectively.</p>
186 <p>If <tt>configure</tt> finds the wrong compiler, either adjust your
187 <tt>PATH</tt> environment variable or set <tt>CC</tt> and <tt>CXX</tt>
192 <div class="question">
193 <p>I compile the code, and I get some error about <tt>/localhome</tt>.</p>
198 <p>There are several possible causes for this. The first is that you didn't set
199 a pathname properly when using <tt>configure</tt>, and it defaulted to a
200 pathname that we use on our research machines.</p>
202 <p>Another possibility is that we hardcoded a path in our Makefiles. If you see
203 this, please email the LLVM bug mailing list with the name of the offending
204 Makefile and a description of what is wrong with it.</p>
208 <div class="question">
209 <p>The <tt>configure</tt> script finds the right C compiler, but it uses the
210 LLVM linker from a previous build. What do I do?</p>
214 <p>The <tt>configure</tt> script uses the <tt>PATH</tt> to find executables, so
215 if it's grabbing the wrong linker/assembler/etc, there are two ways to fix
220 <li><p>Adjust your <tt>PATH</tt> environment variable so that the correct
221 program appears first in the <tt>PATH</tt>. This may work, but may not be
222 convenient when you want them <i>first</i> in your path for other
225 <li><p>Run <tt>configure</tt> with an alternative <tt>PATH</tt> that is
226 correct. In a Borne compatible shell, the syntax would be:</p>
228 <p><tt>PATH=<the path without the bad program> ./configure ...</tt></p>
230 <p>This is still somewhat inconvenient, but it allows <tt>configure</tt>
231 to do its work without having to adjust your <tt>PATH</tt>
232 permanently.</p></li>
238 <div class="question">
239 <p>When creating a dynamic library, I get a strange GLIBC error.</p>
243 <p>Under some operating systems (i.e. Linux), libtool does not work correctly if
244 GCC was compiled with the --disable-shared option. To work around this, install
245 your own version of GCC that has shared libraries enabled by default.</p>
248 <div class="question">
249 <p>I've updated my source tree from CVS, and now my build is trying to use a
250 file/directory that doesn't exist.</p>
254 <p>You need to re-run configure in your object directory. When new Makefiles
255 are added to the source tree, they have to be copied over to the object tree in
256 order to be used by the build.</p>
259 <div class="question">
260 <p>I've modified a Makefile in my source tree, but my build tree keeps using the
261 old version. What do I do?</p>
266 <p>If the Makefile already exists in your object tree, you
267 can just run the following command in the top level directory of your object
270 <p><tt>./config.status <relative path to Makefile></tt><p>
272 <p>If the Makefile is new, you will have to modify the configure script to copy
277 <div class="question">
278 <p>I've upgraded to a new version of LLVM, and I get strange build errors.</p>
283 <p>Sometimes, changes to the LLVM source code alters how the build system works.
284 Changes in libtool, autoconf, or header file dependencies are especially prone
285 to this sort of problem.</p>
287 <p>The best thing to try is to remove the old files and re-build. In most
288 cases, this takes care of the problem. To do this, just type <tt>make
289 clean</tt> and then <tt>make</tt> in the directory that fails to build.</p>
293 <div class="question">
294 <p>I've built LLVM and am testing it, but the tests freeze.</p>
299 <p>This is most likely occurring because you built a profile or release
300 (optimized) build of LLVM and have not specified the same information on the
301 <tt>gmake</tt> command line.</p>
303 <p>For example, if you built LLVM with the command:</p>
305 <p><tt>gmake ENABLE_PROFILING=1</tt>
307 <p>...then you must run the tests with the following commands:</p>
309 <p><tt>cd llvm/test<br>gmake ENABLE_PROFILING=1</tt></p>
313 <div class="question">
314 <p>Why do test results differ when I perform different types of builds?</p>
319 <p>The LLVM test suite is dependent upon several features of the LLVM tools and
322 <p>First, the debugging assertions in code are not enabled in optimized or
323 profiling builds. Hence, tests that used to fail may pass.</p>
325 <p>Second, some tests may rely upon debugging options or behavior that is only
326 available in the debug build. These tests will fail in an optimized or profile
331 <div class="question">
332 <p>Compiling LLVM with GCC 3.3 on SuSE 9 fails, what should I do?</p>
336 <p>This is a bug in the customized version of GCC shipped with SuSE, and effects
337 projects other than LLVM. Complain loudly to SuSE. :)</p>
340 <!-- *********************************************************************** -->
341 <div class="doc_section">
342 <a name="cfe">Using the GCC Front End</a>
345 <div class="question">
347 When I compile software that uses a configure script, the configure script
348 thinks my system has all of the header files and libraries it is testing for.
349 How do I get configure to work correctly?
355 The configure script is getting things wrong because the LLVM linker allows
356 symbols to be undefined at link time (so that they can be resolved during JIT
357 or translation to the C back end). That is why configure thinks your system
361 To work around this, perform the following steps:
366 Make sure the CC and CXX environment variables contains the full path to the
371 Make sure that the regular C compiler is first in your PATH.
375 Add the string "-Wl,-native" to your CFLAGS environment variable.
380 This will allow the gccld linker to create a native code executable instead of
381 a shell script that runs the JIT. Creating native code requires standard
382 linkage, which in turn will allow the configure script to find out if code is
383 not linking on your system because the feature isn't available on your system.
387 <div class="question">
389 When I compile code using the LLVM GCC front end, it complains that it cannot
396 In order to find crtend.o, you must have the directory in which it lives in
397 your LLVM_LIB_SEARCH_PATH environment variable. For the binary distribution of
398 the LLVM GCC front end, this will be the full path of the bytecode-libs
399 directory inside of the LLVM GCC distribution.
404 <!-- *********************************************************************** -->
405 <div class="doc_section">
406 <a name="cfe_code">Questions about code generated by the GCC front-end</a>
409 <div class="question">
411 What is this <tt>__main()</tt> call that gets inserted into <tt>main()</tt>?
417 The <tt>__main</tt> call is inserted by the C/C++ compiler in order to guarantee
418 that static constructors and destructors are called when the program starts up
419 and shuts down. In C, you can create static constructors and destructors by
420 using GCC extensions, and in C++ you can do so by creating a global variable
421 whose class has a ctor or dtor.
425 The actual implementation of <tt>__main</tt> lives in the
426 <tt>llvm/runtime/GCCLibraries/crtend/</tt> directory in the source-base, and is
427 linked in automatically when you link the program.
434 <!-- *********************************************************************** -->
435 <!-- *********************************************************************** -->
438 <div class="doc_footer">
439 <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a>
441 Last modified: $Date$