LLVM的GCC工具链 [英] GCC toolchain for LLVM
问题描述
我在RHEL 6.x机器上运行,该机器当然已经安装了GCC 4.4.我希望在此计算机上运行LLVM.为此,我必须从源代码进行编译.为了做到这一点,我需要一个更现代的GCC版本.
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.
因此,按照说明,我构建了GCC 4.8.2:>
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
我以root用户身份登录,因此$HOME/toolchains
解析为/root/toolchains
.
I'm logged in as root, so $HOME/toolchains
resolves to /root/toolchains
.
满足LLVM的先决条件后,我就可以配置和构建LLVM.
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
认为我仍在使用GCC 4.4,即使我通过了--with-gcc-toolchain=/root/toolchains/
来配置 1 .确保我正确安装了4.8.2.
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.
如何说服configure
使用/root/toolchains
上的GCC?
How do I convince configure
to use the GCC I have at /root/toolchains
?
1 :我尝试了在--with-gcc-toolchain
中指定的路径的多种变体,包括/root/toolchain/bin
,/root/toolchain/bin/g++
等.
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.
推荐答案
您已经发现,解决此问题的正确方法是将自定义工具链添加到PATH
.这不是系统范围的更改,并且仅限于您的Shell会话.另外,您可以配置:
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++
和configure
的--help
输出中记录的类似选项.
and similar options documented in configure
's --help
output.
选项--with-gcc-toolchain
仅告诉生成的Clang在哪里寻找C ++标准库和标头,它与LLVM/Clang生成过程无关.我强烈建议您还构建并安装libc ++和libc ++ abi,并将其与新的Clang一起使用.
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.
这篇关于LLVM的GCC工具链的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!