llvm - sinherle/Recipes GitHub Wiki
Building LLVM
LLVM 3.7.1 has been successfully built and tested for Linux on z Systems. The following instructions can be used for RHEL 7.1/6.6 and SLES 12/11 .
General Notes: i)When following the steps below please use a standard permission user unless otherwise specified.
ii)A directory /<source_root>/
will be referred to in these instructions, this is a temporary writeable directory anywhere you'd like to place it.
Version
3.7.1
Section 1: Installing Build Dependencies:
RHEL6:
sudo yum install -y gcc gcc-c++ make subversion wget tar xz binutils-devel bzip2 flex
RHEL7:
sudo yum install -y wget tar gcc-c++ make
SLES11:
sudo zypper install -y gcc gcc-c++ make subversion wget tar xz binutils-devel bzip2 flex
SLES12:
sudo zypper install -y wget tar gcc-c++ make
Section 2: Installing GCC 4.8.4 (FOR RHEL6 and SLES11 ONLY)
-
Download Source files
mkdir /<source_root>/gcc cd /<source_root>/gcc svn co svn://gcc.gnu.org/svn/gcc/branches/gcc-4_8-branch@212064 gcc_srcDir cd gcc_srcDir/ ./contrib/download_prerequisites
-
Build and Install
mkdir -p /<source_root>/gcc/gcc_buildDir/build cd /<source_root>/gcc/gcc_buildDir/build ../../gcc_srcDir/configure --prefix="/opt/gcc" --enable-shared --with-system-zlib --enable-threads=posix --disable-multilib --enable-__cxa_atexit --enable-checking --enable-gnu-indirect-function --enable-languages="c,c++" --disable-bootstrap make sudo make install
-
Creating Symbolic link of GLIBCXX_3.4.18
cd /usr/lib64/ sudo cp /opt/gcc/lib64/libstdc++.so.6.0.19 . sudo rm /usr/lib64/libstdc++.so.6 sudo ln -s libstdc++.so.6.0.19 libstdc++.so.6
-
Update user PATH and shared library cache
sudo rm -f /usr/bin/gcc sudo ln -s /opt/gcc/bin/gcc /usr/bin/gcc export PATH=/opt/gcc/bin:$PATH sudo sh -c "echo '/opt/gcc/lib64' >> /etc/ld.so.conf.d/gcc.conf" sudo /sbin/ldconfig
Section 3: Installing Python 2.7.9 (FOR RHEL6, SLES11 and SLES12 ONLY)
-
Download Source files
cd /<source_root>/ wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tar.xz tar -xvf Python-2.7.9.tar.xz cd Python-2.7.9
-
Build and Install
./configure --prefix=/usr/local make sudo make install
-
Update link to new python
sudo rm -f /usr/bin/python sudo ln -s /usr/local/bin/python /usr/bin/python
Section 4: Download Sources
-
Download Source files
- LLVM Source Code
- Clang Source Code
- Compiler-rt Source Code
cd /<source_root>/ wget http://llvm.org/releases/3.7.1/llvm-3.7.1.src.tar.xz tar xvf llvm-3.7.1.src.tar.xz wget http://llvm.org/releases/3.7.1/cfe-3.7.1.src.tar.xz tar xvf cfe-3.7.1.src.tar.xz wget http://llvm.org/releases/3.7.1/compiler-rt-3.7.1.src.tar.xz tar xvf compiler-rt-3.7.1.src.tar.xz
-
Move the clang and compiler-rt to tools and projects folders of llvm respectively.
mv llvm-3.7.1.src/ llvm-3.7.1 mv cfe-3.7.1.src/ clang mv clang/ llvm-3.7.1/tools/ mv compiler-rt-3.7.1.src/ compiler-rt mv compiler-rt/ llvm-3.7.1/projects/
Section 4: Build and Install LLVM
-
Configure the build
mkdir build cd build ../llvm-3.7.1/configure --enable-optimized --enable-targets=systemz
-
Build the llvm source
make
-
Run test cases to check the functionality
sed -i '2d' /<source_root>/llvm-3.7.1/tools/clang/test/CodeGen/libcalls-fno-builtin.c make check-all
-
Set Environment Path
export PATH=$PATH:/build/Release+Asserts/bin
-
Add LLVM to library directory
sudo touch /etc/ld.so.conf.d/llvm.conf sudo chmod 777 /etc/ld.so.conf.d/llvm.conf echo "/<source_root>/build/Release+Asserts/lib" > /etc/ld.so.conf.d/llvm.conf sudo /sbin/ldconfig