//                      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)):


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/ version `GCC_4.2.0' not found (required by 

you are probably hitting  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

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:

If building for Darwin/PPC:
If building for Darwin/X86 (32- and 64-bit support):
    TARGETOPTIONS='--with-arch=nocona --with-tune=generic'
If building for Darwin/X86 (32-bit support only):
   TARGETOPTIONS='--with-arch=pentium-m --with-tune=prescott --disable-multilib'

In addition, you *must* specify the following options to configure:

  --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.

                        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 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.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.