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 If llvm-gcc doesn't build right, try building LLVM with OPTIMIZE_OPTION=-O2.
48 This may be host compiler version specific.
50 If you get an error message building llvm-gcc like this:
51 ...gcc/libgcc_s.so.1: version `GCC_4.2.0' not found (required by
52 /usr/lib/libstdc++.so.6)
54 you are probably hitting http://llvm.org/PR896. Please reconfigure with the
55 --disable-shared option to work around this.
57 //===-----------------------
58 X86-64/AMD-64/EM64-T for any OS other than Darwin/Mac OS X:
60 When targeting non-darwin X86-64/AMD-64/EM64-T, configure with
61 --disable-shared. The LLVM X86-64 backend doesn't support PIC codegen on
62 non-darwin systems yet. If you get a build error, try configuring with
66 //===-----------------------
67 Darwin/Mac OS X Instructions:
69 First step: Upgrade your Xcode installation: you need at least Xcode 2.4.
71 Next, decide if you want Objective-C support. If so:
72 EXTRALANGS=,objc,obj-c++
74 If building for Darwin/PPC:
75 TRIPLE=powerpc-apple-darwin8
77 If building for Darwin/X86 (32- and 64-bit support):
78 TARGETOPTIONS=--with-arch=nocona --with-tune=generic
79 TRIPLE=i686-apple-darwin8
81 If building for Darwin/X86 (32-bit support only):
82 TARGETOPTIONS=--with-arch=pentium-m --with-tune=prescott --disable-multilib
83 TRIPLE=i686-apple-darwin8
85 Building for Darwin/Mac OS X is significantly different than building for other
86 targets. Darwin considers libstdc++ to be part of the operating system, not as
87 part of the compiler. As such, you should *remove* the libstdc++-v3 directory
88 from the llvm-gcc4 source directory before configuring it:
90 rm -rf llvm-gcc4-x.y.source/libstdc++-v3
92 In addition, you *must* specify the following options to configure:
94 --with-gxx-include-dir=/usr/include/c++/4.0.0
95 --build=$TRIPLE --host=$TRIPLE --target=$TRIPLE
97 With these options, llvm-gcc will build the same way as Apple's system GCC.
100 //===----------------------------------------------------------------------===//
102 //===----------------------------------------------------------------------===//
106 If you want LLVM to include an identifying marker in the --version output,
107 build llvm-gcc with LLVM_VERSION_INFO=XXX. For example, to build the LLVM
108 1.9 Release front-end, use 'make LLVM_VERSION_INFO=1.9'. This will cause the
109 front-end to print: "gcc (GCC) 4.0.1 LLVM (Apple Computer, Inc. build 1.9)"
110 as the version number.
112 BUILDOPTIONS=LLVM_VERSION_INFO=whatever
115 //===----------------------------------------------------------------------===//
116 Configure, Build, Install, Test
117 //===----------------------------------------------------------------------===//
119 Next, make an object directory and install directory as siblings to the
120 llvm-gcc source directory, and build and install llvm-gcc:
125 $ ../llvm-gcc4-x.y.source/configure --prefix=`pwd`/../install \
126 --enable-llvm=$LLVMOBJDIR --enable-languages=c,c++$EXTRALANGS $TARGETOPTIONS
130 Note that if you prefer to bootstrap llvm-gcc (so that the final llvm-gcc
131 executables have been compiled with llvm-gcc itself), replace "make" with
134 Finally, add symlinks for llvm-gcc and llvm-g++ to your path:
138 $ ln -s <llvmgccdir>/install/bin/gcc llvm-gcc
139 $ ln -s <llvmgccdir>/install/bin/g++ llvm-g++
142 You should now have something like:
146 gcc version 4.0.1 LLVM (Apple Computer, Inc. build 5400)
149 ** NOTE: If the -v line above doesn't include "LLVM", you probably mistyped the
150 --enable-llvm=xxx line and have a normal gcc, not an llvm-gcc.