Untar LLVM source tarball first, which will create a directory, say
/tmp/llvm-2.x/Then untar the LLVM-GCC Front End source tarball, which will create a directory, say
/tmp/llvm-gcc-4.y-2.x.source/It's better to use the GNU tar to avoid issues.
cd /scratch /tmp/llvm-gcc-4.y-2.x.source/configure --prefix=/usr/local/ <other options>where <other options> are:
See here for other options.
gmake -j 5 gmake install
llvm-gcc llvm-g++ llvm-gcov llvm-gfortranTo test:
llvm-gcc hello.cshould create an executable binary a.out just as you would expect.
llvm-gcc -c -emit-llvm hello.cshould instead create an LLVM bitcode object hello.o. To run it (if you have LLVM compiled):
lli hello.bc
Another reason why GCC 4.3 or 4.4 are needed is because when compiling C++ code, Clang will seek C++-specific headers (e.g. iostream) in hard-coded paths such as /usr/include/c++/4.4 or /usr/include/c++/4.3. In addition, Clang will invoke g++ to generate code (from assembly) and do the linking to libstd++.
Untar LLVM source tarball first, which will create a directory, say
/tmp/llvm-2.x/Then enter LLVM's tool directory, untar the Clang source package here, and create a symbolic link:
cd /tmp/llvm-2.x/tool tar zxvf /tmp/clang-2.x.tgz ln -s clang-2.x clang
vi /tmp/llvm-2.x/tool/Makefile
cd /tmp/llvm-2.x/ gmake -j 5
/tmp/llvm-2.7/lib/clang/1.1/include
clang/clang++ are the gcc/g++ equivalent in LLVM.
lli is the LLVM bitcode interpreter.
To test:
clang hello.c clang++ hello.cxxshould create executable binary a.out just as you would expect.
If clang++ complains about unable to find C++-specific header files, use
clang++ -v hello.cxxto see its search paths, and copy GCC 4.3 or 4.4 C++-specific header files to the appropriate paths, or add -I... command-line options.
clang -c -emit-llvm hello.cshould instead create an LLVM bitcode object hello.o. To run it:
lli hello.oTo disassemble it (into LLVM assembly):
llvm-dis < hello.oTo convert the bitcode to native assembly code
llc hello.o -o hello.s