build llvm on CentOS

Hi there,

I was trying to build llvm on CentOS. The problem is that library on CentOS is always so old (Gcc, python). I managed to install local gcc and let cmake know. But I couldn’t do so with python. I end up comment out the check in CMakeList.txt which is not good.
I was wondering if anyone has experience building llvm (using cmake) using a local python?


Did you specify PYTHON_EXECUTABLE?

See also,
It’s centos6.

2015年7月22日(水) 14:29 Xiaochu Liu <>:

For various reasons I have to use an old 5.5 version of CentOS that is fairly locked down. Not only are newer versions of ‘gcc’ available, but for operational reasons we have chosen to keep the set of installed tools frozen until some more suitable date as there are other teams dependent on the current configuration.

Python is a particular problem because ‘yum’ is written in Python and is very version sensitive, so ironically you can update Python and find that ‘yum’ no longer works preventing future updates.

My solution was to download the sources for ‘cmake’ [v3.0.2], ‘python’ [v2.7.6] and ‘gcc’ [v4.8.2], build them locally, and set my PATH, LD_LIBRARY_PATH and LD_RUN_PATH variables to reference this local version. Then to configure I have:

CC=which gcc CXX=which g++ $(CMAKE) -G “Unix Makefiles” \

…/…/llvm \


“-DCMAKE_EXE_LINKER_FLAGS:STRING=-<extra link flags>” \

“-DCMAKE_CXX_FLAGS:STRING=<extra C++ flags>” \

-DLLVM_TARGETS_TO_BUILD=“<list of targets>” \



Having the locally built version of Python on PATH seems to be fine, but I did have to force ‘CC’ and ‘CXX’ to the intended versions.

If you want the version of ‘clang’ you build to run on other Linux distros (Ubuntu for example), I found that the GCC shared library dependencies could be a problem, so you might want to include ‘-static-libgcc -static-libstdc++ -static’ in your extra link flags which will use the static libraries and remove this dependency, although at the expense of large executables.

All the best,


I tried -DPYTHON_EXECUTABLE but it still says the version is 2.6 (centos one).

I set my PATH in .bash_profile and the cmake does recognize them.

But when I compile using ‘make’, it shows me this:

…/…/…/bin/llvm-tblgen: /usr/lib64/ version `GLIBCXX_3.4.15’ not found (required by …/…/…/bin/llvm-tblgen)