1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5 <link rel="stylesheet" href="llvm.css" type="text/css" media="screen" />
6 <title>Bootstrapping the C/C++ Front-End</title>
10 <div class="doc_title">
11 Bootstrapping the C/C++ Front-End
14 <p>This document is intended to explain the process of building the LLVM
15 C/C++ front-end, based on GCC 3.4, from source.</p>
17 <p><b>NOTE:</b> This is currently a somewhat fragile, error-prone
18 process, and you should only try to do it if (A) you really, really,
19 really can't use the binaries we distribute, and (B) you are a wicked
22 <p>We welcome patches to help make this process simpler.</p>
24 <!-- *********************************************************************** -->
25 <div class="doc_section">
26 <a name="instructions">Instructions</a>
28 <!-- *********************************************************************** -->
30 <div class="doc_text">
33 <li><p>Configure and build the LLVM libraries and tools using:</p>
36 % ./configure [options...]
39 <p>The use of the non-default target "tools-only" means that the
40 LLVM tools and libraries will build, and the binaries will be
41 deposited in llvm/tools/Debug, but the runtime (bytecode)
42 libraries will not build.</p></li>
44 <li><p>Add the directory containing the tools to your PATH.</p>
46 % set path = ( `cd llvm/tools/Debug && pwd` $path )
49 <li><p>Unpack the C/C++ front-end source into cfrontend/src.</p></li>
51 <li><p>Edit src/configure. Change the first line (starting w/ #!) to
52 contain the correct full pathname of sh.</p></li>
54 <li><p>Make "build" and "install" directories as siblings of the "src"
58 /usr/local/example/cfrontend/src
61 % set CFEINSTALL = `pwd`/install
64 <li><p>Configure, build and install the C front-end:</p>
67 % ../src/configure --prefix=$CFEINSTALL --disable-nls --disable-shared \
68 --enable-languages=c,c++
70 % setenv LLVM_LIB_SEARCH_PATH `pwd`/gcc
71 % gmake all; gmake install
74 <p><b>Common Problem:</b> You may get error messages regarding the fact
75 that LLVM does not support inline assembly. Here are two common
79 <li><p><b>Fix 1:</b> If you have system header files that include
80 inline assembly, you may have to modify them to remove the inline
81 assembly, and install the modified versions in
82 <code>$CFEINSTALL/<i>target-triplet</i>/sys-include</code>.</p></li>
84 <li><b>Fix 2:</b> If you are building the C++ front-end on a CPU we
85 haven't tried yet, you will probably have to edit the appropriate
86 version of atomicity.h under
87 <code>src/libstdc++-v3/config/cpu/<i>name-of-cpu</i>/atomicity.h</code>
88 and apply a patch so that it does not use inline assembly.</p></li>
91 <p><b>Porting to a new architecture:</b> If you are porting the new front-end
92 to a new architecture, or compiling in a different configuration that we have
93 previously, there are probably several changes you will have to make to the GCC
94 target to get it to work correctly. These include:<p>
97 <li>Often targets include special or assembler linker flags which
98 <tt>gccas</tt>/<tt>gccld</tt> does not understand. In general, these can
100 <li>LLVM currently does not support any floating point values other than
101 32-bit and 64-bit IEEE floating point. The primary effect of this is
102 that you may have to map "long double" onto "double".</li>
103 <li>The profiling hooks in GCC do not apply at all to the LLVM front-end.
104 These may need to be disabled.</li>
105 <li>No inline assembly for position independent code. At the LLVM level,
106 everything is position independent.</li>
107 <li>We handle <tt>.init</tt> and <tt>.fini</tt> differently.</li>
108 <li>Did we mention that we don't support inline assembly? You'll probably
109 have to add some fixinclude hacks to disable it in the system
114 <li><p>Go back into the LLVM source tree proper. Edit Makefile.config
115 to redefine <code>LLVMGCCDIR</code> to the full pathname of the
116 <code>$CFEINSTALL</code> directory, which is the directory you just
117 installed the C front-end into. (The ./configure script is likely to
118 have set this to a directory which does not exist on your system.)</p></li>
120 <li><p>If you edited header files during the C/C++ front-end build as
121 described in "Fix 1" above, you must now copy those header files from
122 <code>$CFEINSTALL/<i>target-triplet</i>/sys-include</code> to
123 <code>$CFEINSTALL/lib/gcc/<i>target-triplet</i>/3.4-llvm/include</code>.
124 (This should be the "include" directory in the same directory as the
125 libgcc.a library, which you can find by running
126 <code>$CFEINSTALL/bin/gcc --print-libgcc-file-name</code>.)</p></li>
128 <li><p>Build and install the runtime (bytecode) libraries by running:</p>
131 % mkdir $CFEINSTALL/bytecode-libs
132 % gmake -C runtime install
133 % setenv LLVM_LIB_SEARCH_PATH $CFEINSTALL/bytecode-libs
136 <li><p>Test the newly-installed C frontend by one or more of the
139 <li> compiling and running a "hello, LLVM" program in C and C++.</li>
140 <li> running the tests under <tt>test/Programs</tt> using <code>gmake -C
141 test/Programs</code></li>
148 <!-- *********************************************************************** -->
151 <address><a href="mailto:gaeke -at- uiuc.edu">Brian Gaeke</a></address>
152 Last modified: $Date$