1 //===----------------------------------------------------------------------===//
2 // Building llvm-gcc4 from Source
3 //===----------------------------------------------------------------------===//
5 These instructions describe how to build llvm-gcc-4.2.
7 Note that this should work on all the supported LLVM targets. If you run into
8 problems, please ask for help or file a bug.
10 Please follow these instructions carefully. In particular, the target-specific
11 configure instructions should be followed to ensure correct builds.
13 Please also note, that this branch is still in early development phase and can
16 //===----------------------------------------------------------------------===//
17 First Step: Build LLVM
18 //===----------------------------------------------------------------------===//
20 First, check out LLVM from Subversion, then build it in optimized mode (a
21 Release build, as opposed to a Debug one)):
23 make ENABLE_OPTIMIZED=1
25 If you use a Debug instead of a Release build of LLVM, make sure you add
26 --enable-checking to the configure flags below or llvm-gcc-4.2 will not build!
28 Below we assume the LLVM OBJ_ROOT is $LLVMOBJDIR.
31 //===----------------------------------------------------------------------===//
32 Unpack Front-end Source
33 //===----------------------------------------------------------------------===//
37 $ tar zxvf llvm-gcc4-x.y.source.tar.gz
40 //===----------------------------------------------------------------------===//
41 Target-Specific configure Instructions
42 //===----------------------------------------------------------------------===//
44 //===-----------------------
45 Linux-specific Instructions:
47 To build a compiler that targets 32-bit x86, the following options should be
48 added to the configure line:
49 --target=i686-pc-linux-gnu --with-tune=generic --with-arch=pentium4
50 You can select a different arch string if you prefer, but it's important to
51 use this option to prevent llvm-gcc from defaulting to generic i386, which
52 can lead to problems as llvm itself doesn't support x86 targets lower
55 If llvm-gcc doesn't build right, try building LLVM with OPTIMIZE_OPTION=-O2.
56 This may be host compiler version specific.
58 If you get an error message building llvm-gcc like this:
59 ...gcc/libgcc_s.so.1: version `GCC_4.2.0' not found (required by
60 /usr/lib/libstdc++.so.6)
62 you are probably hitting http://llvm.org/PR896. Please reconfigure with the
63 --disable-shared option to work around this.
65 If you want Fortran support:
68 //===-----------------------
69 X86-64/AMD-64/EM64-T for any OS other than Darwin/Mac OS X:
71 If you want just pure 64 bit compiler, configure with --disable-multilib.
73 //===-----------------------
74 Darwin/Mac OS X Instructions:
76 First step: Upgrade your Xcode installation: you need at least Xcode 2.4.
78 Next, decide if you want Objective-C support. If so:
79 EXTRALANGS=,objc,obj-c++
81 If building for Darwin/PPC:
82 TRIPLE=powerpc-apple-darwin8 (Tiger)
83 TRIPLE=powerpc-apple-darwin9 (Leopard)
85 If building for Darwin/X86 (32- and 64-bit support):
86 TARGETOPTIONS='--with-arch=nocona --with-tune=generic'
87 TRIPLE=i686-apple-darwin8 (Tiger)
88 TRIPLE=i686-apple-darwin9 (Leopard)
89 TRIPLE=x86_64-apple-darwin10 (Snow Leopard on a 64-bit machine)
90 TRIPLE=i686-apple-darwin10 (Snow Leopard on a 32-bit machine)
92 If building for Darwin/X86 (32-bit support only):
93 TARGETOPTIONS='--with-arch=pentium-m --with-tune=prescott --disable-multilib'
94 TRIPLE=i686-apple-darwin8 (Tiger)
95 TRIPLE=i686-apple-darwin9 (Leopard)
96 TRIPLE=x86_64-apple-darwin10 (Snow Leopard on a 64-bit machine)
97 TRIPLE=i686-apple-darwin10 (Snow Leopard on a 32-bit machine)
99 The Triples are very important, otherwise your llvm-gcc/g++ may not be able
100 to find the header files below.
102 In addition, you *must* specify the following options to configure:
104 --with-gxx-include-dir=/usr/include/c++/4.0.0 (Leopard)
105 --with-gxx-include-dir=/usr/include/c++/4.2.1 (Snow Leopard)
106 --build=$TRIPLE --host=$TRIPLE --target=$TRIPLE
108 With these options, llvm-gcc will build the same way as Apple's system GCC.
110 If you want Fortran support, you need to do the following:
111 Get the GMP, MPFR, and libiconv via MacPorts.
112 You need to add fortran to the list of EXTRALANGS.
113 Then specify these additional options to configure:
114 --with-gmp=/opt/local
115 --with-mpfr=/opt/local
116 --with-libiconv-prefix=/opt/local
118 //===----------------------------------------------------------------------===//
120 //===----------------------------------------------------------------------===//
124 If you want LLVM to include an identifying marker in the --version output,
125 build llvm-gcc with LLVM_VERSION_INFO=XXX. For example, to build the LLVM
126 2.5 Release front-end, use 'make LLVM_VERSION_INFO=2.5'. This will cause the
127 front-end to print: "gcc version 4.2.1 (Based on Apple Inc. build 5555)
128 (LLVM build 2.5)" as the version number.
130 BUILDOPTIONS=LLVM_VERSION_INFO=whatever
133 //===----------------------------------------------------------------------===//
134 Configure, Build, Install, Test
135 //===----------------------------------------------------------------------===//
137 Next, make an object directory and install directory as siblings to the
138 llvm-gcc source directory, and build and install llvm-gcc:
143 $ ../llvm-gcc4.2-x.y.source/configure --prefix=`pwd`/../install --program-prefix=llvm- \
144 --enable-llvm=$LLVMOBJDIR --enable-languages=c,c++$EXTRALANGS $TARGETOPTIONS
148 Note that it is currently necessary to use a separate object directory for
149 building llvm-gcc. Running configure and make from within the llvm-gcc
150 source directory does not work.
152 //===-----------------------
153 Darwin/Mac OS X Specific part:
155 $ ln -sf /usr/lib/libstdc++.6.dylib `pwd`/../install/lib
156 $ ln -sf /usr/lib/libstdc++.6.dylib `pwd`/../install/lib/libstdc++.dylib
158 That last step, "ln -sf ..." is required so that the linker (collect2) can find
159 libstdc++ ('-lstdc++') and subsequently link C++ executables correctly.
161 //===-----------------------
163 Note that if you prefer to bootstrap llvm-gcc (so that the final llvm-gcc
164 executables have been compiled with llvm-gcc itself), replace "make" with
167 You should now have something like:
171 gcc version 4.2.1 (Based on Apple Inc. build 5555) (LLVM build)
173 ** NOTE: If the -v line above doesn't include "LLVM", you probably mistyped the
174 --enable-llvm=xxx line and have a normal gcc, not an llvm-gcc.