I am running on an RHEL 6.x box, which of course has GCC 4.4 installed. I wish to have LLVM running on this machine. In order to do so, I must compile it from source. In order to do that, I need a more modern version of GCC.
So, following the instructions, I have built GCC 4.8.2:
[snip]
% $PWD/../gcc-4.8.2/configure --prefix=$HOME/toolchains --enable-languages=c,c++
% make -j$(nproc)
% make install
I'm logged in as root, so $HOME/toolchains
resolves to /root/toolchains
.
After satisfying prerequisites for LLVM, I'm ready to configure and build LLVM.
root@dev06 /root/llvm-build # ~/llvm/configure --enable-optimized --prefix=$HOME/toolchains/ --with-gcc-toolchain=/root/toolchains/
checking for clang... no
[snip]
checking target architecture... x86_64
checking whether GCC is new enough... no
configure: error:
The selected GCC C++ compiler is not new enough to build LLVM. Please upgrade
to GCC 4.7. You may pass --disable-compiler-version-checks to configure to
bypass these sanity checks.
root@dev06 /root/llvm-build #
configure
thinks I'm using GCC 4.4 still, even though I passed --with-gcc-toolchain=/root/toolchains/
to configure1. Let's make sure that I installed 4.8.2 properly.
root@dev06 /root/llvm-build # $HOME/toolchains/bin/g++ --version
g++ (GCC) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
How do I convince configure
to use the GCC I have at /root/toolchains
?
1: I have tried a number of variations of the path I specify in --with-gcc-toolchain
, inclding /root/toolchain/bin
, /root/toolchain/bin/g++
, etc.
Yes, for C code Clang and GCC are compatible (they both use the GNU Toolchain for linking, in fact.)
LLVM is a set of compiler and toolchain technologies that can be used to develop a front end for any programming language and a back end for any instruction set architecture.
Introduction. Clang is only one component in a complete tool chain for C family programming languages. In order to assemble a complete toolchain, additional tools and runtime libraries are required.
A full build of LLVM and Clang will need around 15-20 GB of disk space. The exact space requirements will vary by system. (It is so large because of all the debugging information and the fact that the libraries are statically linked into multiple tools).
As you have discovered, the proper way to resolve this is by adding your custom toolchain to PATH
. This is not a systemwide change, and is limited to your shell session. Alternatively, you can configure with:
../llvm/configure CXX=$HOME/toolchains/bin/g++
and similar options documented in configure
's --help
output.
The option --with-gcc-toolchain
only tells the built Clang where to look for a C++ standard library and headers, it has nothing to do with the LLVM/Clang build process. I strongly suggest to also build and install libc++ and libc++abi and use those with your new Clang instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With