Which is the best compiler to build LLVM 5.0.0 rc2?

Recently I have been building LLVM and Clang from the distribution using gcc 4.9.2. With the new 5.0.0 rc2 that is giving warning messages during the compilation. I have been trying out some other compilers.

gcc 5.2 with -std=c++11 This works, although there are still some warnings.

gcc 6.4 and gcc 7.1 fail with errors such as this in building libcxxabi as follows:

Command: /opt/cmake/bin/cmake -G “Unix Makefiles” -DCMAKE_INSTALL_PREFIX=/home/fletcher/LLVM/llvm-5.0.rc2/local_71 -DCMAKE_C_COMPILER=/opt/gcc-7.1/bin/gcc CMAKE_CXX_COMPILER=/opt/gcc-7.1/bin/g++ -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_TARGETS_TO_BUILD=“host” -DCMAKE_CXX_FLAGS=“-std=c++11 -I/opt/gcc-7.1/include/c++/7.1.0” -DCMAKE_EXE_LINKER_FLAGS=“-Xlinker -R/opt/gcc-7.1/lib64 -L/opt/gcc-7.1/lib64” …/llvm

First Error:

Building CXX object projects/libcxxabi/src/CMakeFiles/cxxabi_objects.dir/cxa_aux_runtime.cpp.o
In file included from /home/fletcher/LLVM/llvm-5.0.rc2/llvm/projects/libcxx/include/stdlib.h:94:0,
from /home/fletcher/LLVM/llvm-5.0.rc2/llvm/projects/libcxx/include/cstdlib:86,
from /home/fletcher/LLVM/llvm-5.0.rc2/llvm/projects/libcxx/include/exception:82,
from /home/fletcher/LLVM/llvm-5.0.rc2/llvm/projects/libcxx/include/new:89,
from /home/fletcher/LLVM/llvm-5.0.rc2/llvm/projects/libcxxabi/src/cxa_aux_runtime.cpp:14:
/opt/gcc-7.1/include/c++/7.1.0/stdlib.h:38:12: error: std::abort has not been declared
using std::abort;

clang 4.0.0 fails with a different problem with libcxxabi -

Command:

/opt/cmake/bin/cmake -G “Unix Makefiles” -DCMAKE_INSTALL_PREFIX=/home/fletcher/LLVM/llvm-5.0.rc2/local_40 -DCMAKE_C_COMPILER=/home/fletcher/LLVM/llvm-4.0.distrib/local/bin/clang CMAKE_CXX_COMPILER=/home/fletcher/LLVM/llvm-4.0.distrib/local/bin/clang++ -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_TARGETS_TO_BUILD=“host” -DCMAKE_CXX_FLAGS=“-I/home/fletcher/LLVM/llvm-4.0.distrib/local/include/c++/v1 -stdlib=libc++” -DCMAKE_EXE_LINKER_FLAGS="-Xlinker -R/home/fletcher/LLVM/llvm-4.0.distrib/local/lib -L/home/fletcher/LLVM/llvm-4.0.distrib/local/lib -lc++abi -lclangBasic -lLLVMSupport -lpthread -ldl " …/llvm

Error:

Building CXX object projects/libcxxabi/src/CMakeFiles/cxxabi_objects.dir/cxa_aux_runtime.cpp.o
In file included from /home/fletcher/LLVM/llvm-5.0.rc2/llvm/projects/libcxxabi/src/cxa_aux_runtime.cpp:13:
/home/fletcher/LLVM/llvm-5.0.rc2/llvm/projects/libcxxabi/include/cxxabi.h:42:26: error: unknown type name
‘size_t’

It seems to me that there are some configuration problems here in getting the correct header arrangement.

The rest of the build works, and looking around clang is recommended for building libcxxabi.

Is this a known problem?

Thanks

John Fletcher

Why are you passing this?

-DCMAKE_CXX_FLAGS=“-std=c++11 -I/opt/gcc-7.1/include/c++/7.1.0”

CMakeLists.txt should take care of setting -std=c++11, and by passing -I/opt/gcc-7.1/include/c++/7.1.0, are you short circuiting the compiler’s own include paths?