//===----------------------------------------------------------------------===// // Building llvm-gcc4 from Source //===----------------------------------------------------------------------===// These instructions describe how to build llvm-gcc-4.0. Note that this should work on all the supported LLVM targets. If you run into problems, please ask for help or file a bug. Please follow these instructions carefully. In particular, the target-specific configure instructions should be followed to ensure correct builds. //===----------------------------------------------------------------------===// First Step: Build LLVM //===----------------------------------------------------------------------===// First, check out LLVM from Subversion, then build it in optimized mode (a Release build, as opposed to a Debug one)): make ENABLE_OPTIMIZED=1 If you use a Debug instead of a Release build of LLVM, make sure you add --enable-checking to the configure flags below or llvm-gcc-4.0 will not build! Below we assume the LLVM OBJ_ROOT is $LLVMOBJDIR. //===----------------------------------------------------------------------===// Unpack Front-end Source //===----------------------------------------------------------------------===// $ mkdir llvm-gcc $ cd llvm-gcc $ tar zxvf llvm-gcc4-x.y.source.tar.gz //===----------------------------------------------------------------------===// Target-Specific configure Instructions //===----------------------------------------------------------------------===// //===----------------------- Linux-specific Instructions: If llvm-gcc doesn't build right, try building LLVM with OPTIMIZE_OPTION=-O2. This may be host compiler version specific. If you get an error message building llvm-gcc like this: ...gcc/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/libstdc++.so.6) you are probably hitting http://llvm.org/PR896. Please reconfigure with the --disable-shared option to work around this. //===----------------------- X86-64/AMD-64/EM64-T for any OS other than Darwin/Mac OS X: When targeting non-darwin X86-64/AMD-64/EM64-T, configure with --disable-shared. The LLVM X86-64 backend doesn't support PIC codegen on non-darwin systems yet. If you get a build error, try configuring with --disable-multilib. //===----------------------- Darwin/Mac OS X Instructions: First step: Upgrade your Xcode installation: you need at least Xcode 2.4. Next, decide if you want Objective-C support. If so: EXTRALANGS=,objc,obj-c++ If building for Darwin/PPC: TRIPLE=powerpc-apple-darwin8 If building for Darwin/X86 (32- and 64-bit support): TARGETOPTIONS=--with-arch=nocona --with-tune=generic TRIPLE=i686-apple-darwin8 If building for Darwin/X86 (32-bit support only): TARGETOPTIONS=--with-arch=pentium-m --with-tune=prescott --disable-multilib TRIPLE=i686-apple-darwin8 Building for Darwin/Mac OS X is significantly different than building for other targets. Darwin considers libstdc++ to be part of the operating system, not as part of the compiler. As such, you should *remove* the libstdc++-v3 directory from the llvm-gcc4 source directory before configuring it: rm -rf llvm-gcc4-x.y.source/libstdc++-v3 In addition, you *must* specify the following options to configure: --with-gxx-include-dir=/usr/include/c++/4.0.0 --build=$TRIPLE --host=$TRIPLE --target=$TRIPLE With these options, llvm-gcc will build the same way as Apple's system GCC. //===----------------------------------------------------------------------===// Build Options //===----------------------------------------------------------------------===// Version Identifier: If you want LLVM to include an identifying marker in the --version output, build llvm-gcc with LLVM_VERSION_INFO=XXX. For example, to build the LLVM 1.9 Release front-end, use 'make LLVM_VERSION_INFO=1.9'. This will cause the front-end to print: "gcc (GCC) 4.0.1 LLVM (Apple Computer, Inc. build 1.9)" as the version number. BUILDOPTIONS=LLVM_VERSION_INFO=whatever //===----------------------------------------------------------------------===// Configure, Build, Install, Test //===----------------------------------------------------------------------===// Next, make an object directory and install directory as siblings to the llvm-gcc source directory, and build and install llvm-gcc: $ mkdir obj $ mkdir install $ cd obj $ ../llvm-gcc4-x.y.source/configure --prefix=`pwd`/../install --program-prefix=llvm- \ --enable-llvm=$LLVMOBJDIR --enable-languages=c,c++$EXTRALANGS $TARGETOPTIONS $ make $BUILDOPTIONS $ make install Note that if you prefer to bootstrap llvm-gcc (so that the final llvm-gcc executables have been compiled with llvm-gcc itself), replace "make" with "make bootstrap". Finally, add symlinks for llvm-gcc and llvm-g++ to your path: $ su $ cd /usr/local/bin $ ln -s /install/bin/gcc llvm-gcc $ ln -s /install/bin/g++ llvm-g++ $ exit You should now have something like: $ llvm-gcc -v ... gcc version 4.0.1 LLVM (Apple Computer, Inc. build 5400) ** NOTE: If the -v line above doesn't include "LLVM", you probably mistyped the --enable-llvm=xxx line and have a normal gcc, not an llvm-gcc.