blob: 19724999bfeef3929b07a2dda0d525ae1afcfaf4 [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:
If you want to build multilib-enabled llvm-gcc (so, it will be able to generate
32 and 64 bit executables) you need to consider your system default lib directory
layout.
Usually, your system uses one of these layouts:
I. /usr/lib => 32 bit libraries (also in /usr/lib32)
/usr/lib64 => 64 bit libraries
You're lucky and don't need to do anything, just proceed to usual configure
steps.
II. /usr/lib => 64 bit libraries (also in /usr/lib64)
/usr/lib32 => 32 bit libraries
You need to apply the following patch:
<==cut==>
--- gcc/config/i386/t-linux64
+++ gcc/config/i386/t-linux64
@@ -6,7 +6,7 @@ SHLIB_MAPFILES = $(srcdir)/libgcc-std.ver \
MULTILIB_OPTIONS = m64/m32
MULTILIB_DIRNAMES = 64 32
-MULTILIB_OSDIRNAMES = ../lib64 ../lib
+MULTILIB_OSDIRNAMES = ../lib64 ../lib32
LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib
<==cut==>
Note, that usually you don't notice such patching with your native gcc, since
it's done automatically by your favourite system package manager. Maybe we'll
add some layout detection routine in the future.
If you want just pure 64 bit compiler, configure 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.4 Release front-end, use 'make LLVM_VERSION_INFO=2.4'. This will cause the
front-end to print: "gcc version 4.2.1 (Based on Apple Inc. build 5555)
(LLVM build 2.4)" 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.2-2.4.source/configure --prefix=`pwd`/../install --program-prefix=llvm- \
--enable-llvm=$LLVMOBJDIR --enable-languages=c,c++$EXTRALANGS $TARGETOPTIONS
$ make $BUILDOPTIONS
$ make install
//===-----------------------
Darwin/Mac OS X Specific part:
$ 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.