How to build clang++ 5.0.2 into a custom directory AND avoid that the final clang++ compiler finds include files in /usr/include

Don’t blame me – I did not decide to use this ancient system!

I need to build llvm on CENTOS 7.9.2009.

This system has a very old compiler installed (g++ 4.8.5) – which nobody is using.
I’m using a compiler found in some other directory than /usr/bin (g+±5.3).

Somebody told me to use LLVM 5.0.2 because it is the newest version, which can be built using g++ 5.3.

I’ve successfully build clang++ but it keeps finding ancient boost include files installed in /usr/include.

How to prevent this?

I tried

cmake \
-G "Unix Makefiles" \
-DCMAKE_C_COMPILER=`which gcc` \
-DCMAKE_CXX_COMPILER=`which g++` \

BTW – I also need the LLVM libraries in order for

  • creating IR code in C++
  • JIT compiler

Is the above make command correct?

There are builds for newer versions of clang available on CentOS:

Never mind!
The machine already had LLVM installed – just needed to be enabled using

scl enable llvm-toolset-7