Clang Installation

GCC compiler doesn't support well on c++11 templated [lambda expression][http://en.cppreference.com/w/cpp/language/lambda]. On GCC 4.x, internal compiler error is always prompted. The solution is either upgrading to [GCC 5.x][https://gcc.gnu.org/gcc-5/] or installing [clang++][http://llvm.org/].

All the following steps are on servers, on which no root permission can be granted and thus all installation are into my own directories.

1.1 Upgrade Python
 
AخA
#-- python
$wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
$tar xf Python-3.5.2.tar.xz
$./configure --prefix=/afs/cs.pitt.edu/usr0/xianeizhang/private/bench/install/Python3.5_install
$make
$make install
1.2 Install llvm
 
xxxxxxxxxx
#-- llvm
$wget http://llvm.org/releases/3.6.0/llvm-3.6.0.src.tar.xz
$tar xf llvm-3.6.0.src.tar.xz
#-- clang
$cd llvm-3.6.0.src
$wget http://llvm.org/releases/3.6.0/cfe-3.6.0.src.tar.xz
$tar xf cfe-3.6.0.src.tar.xz
$mv cfe-3.6.0.src clang
$cd ../..
#-- clang-tools-extra
$cd llvm-3.6.0.src/tools/clang/tools
$wget http://llvm.org/releases/3.6.0/clang-tools-extra-3.6.0.src.tar.xz
$tar xf clang-tools-extra-3.6.0.src.tar.xz
$mv clang-tools-extra-3.6.0.src extra
$cd ../../../..
#-- compiler-rt
$cd llvm-3.6.0.src/projects/
$wget http://llvm.org/releases/3.6.0/compiler-rt-3.6.0.src.tar.xz
$tar xf compiler-rt-3.6.0.src.tar.xz
$mv compiler-rt-3.6.0.src compiler-rt
#-- install
$./configure --enable-optimized --enable-targets=host-only --prefix=/afs/cs.pitt.edu/usr0/xianeizhang/private/bench/install/llvm_install --with-python=/afs/cs.pitt.edu/usr0/xianeizhang/private/bench/install/Python3.5_install/bin/python3.5
$make -j4
$make install
$clang -version
1.3 Set environmental variables
 
xxxxxxxxxx
set CLANG_PATH = "/afs/cs.pitt.edu/usr0/xianeizhang/private/bench/install/llvm_install/bin"
setenv PATH {$CLANG_PATH}:$PATH
1.4 Makefile

change include and link path for clang.

 
x
#-- XW: change the gcc search path
GCC_PATH=/usr/local/gcc-4.8.2
#-- XW: include path should be added (-cxx-isystem, -I)
CXX := clang++ -cxx-isystem ${GCC_PATH}/include/c++/4.8.2 -I${GCC_PATH}/include/c++/4.8.2/x86_64-unknown-linux-gnu
#-- XW: link path should also be added in linking stage
-L${GCC_PATH}/lib64

[1]. [stackoverflow][http://stackoverflow.com/questions/21363494/need-to-change-include-path-for-clang]

1.5 GDB

Mismatch between the compiler and debugger may cause the failure of printing variable value. GCC 4.8+ produces debugging info in DWARF4 format, whereas GDB only understand DWARF3; solution is to request GCC to produce debugging info in the older format by specifying -gdwarf-3:

 
x
#-- before specifing format
CXXFLAGS := -O1 -std=c++11 -g -Wall
(gdb) print argc
No symbol "argc" in current text
#-- specifing format
CXXFLAGS := -O1 -std=c++11 -g -gdwarf-3 -Wall

[1]. [GDB symbol][https://codeyarns.com/2014/02/18/the-strange-case-of-gdb-not-finding-any-symbol/]

[2]. [gcc 4.8 release notes][https://gcc.gnu.org/gcc-4.8/changes.html]