blob: c101740fe627580640747259dad35de78660492e [file] [log] [blame]
//===----------------------------------------------------------------------===//
// Building llvm-gcc4 from Source
//===----------------------------------------------------------------------===//
These instructions describe how to build llvm-gcc-4.2.
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.
Please also note, that this branch is still in early development phase and can
be not usable at all.
//===----------------------------------------------------------------------===//
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.2 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
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
2.3 Release front-end, use 'make LLVM_VERSION_INFO=2.3'. This will cause the
front-end to print: "gcc version 4.2.1 (Based on Apple Inc. build 5555)
(LLVM build 2.3)" 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
$ ln -sf /usr/lib/libstdc++.6.dylib `pwd`/../install/lib
$ ln -sf /usr/lib/libstdc++.6.dylib `pwd`/../install/lib/libstdc++.dylib
That last step, "ln -sf ..." is required so that the linker (collect2) can find
libstdc++ ('-lstdc++') and subsequently link C++ executables correctly.
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".
You should now have something like:
$ llvm-gcc -v
...
gcc version 4.2.1 (Based on Apple Inc. build 5555) (LLVM build)
** 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.