c++ - 用于 LLVM 的 GCC 工具链

标签 c++ llvm configure rhel

我在 RHEL 6.x 机器上运行,当然安装了 GCC 4.4。我希望在这台机器上运行 LLVM。为此,我必须从源代码编译它。为了做到这一点,我需要一个更现代的 GCC 版本。

所以,关注 the instructions ,我已经构建了 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

满足 LLVM 的先决条件后,我就可以配置和构建 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。

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?


1:我已经尝试了我在 --with-gcc-toolchain 中指定的路径的多种变体,包括 /root/toolchain/bin /root/toolchain/bin/g++

最佳答案

正如您所发现的,解决此问题的正确方法是将您的自定义工具链添加到 PATH。这不是系统范围的更改,并且仅限于您的 shell session 。或者,您可以配置:

../llvm/configure CXX=$HOME/toolchains/bin/g++

以及configure--help 输出中记录的类似选项。

选项 --with-gcc-toolchain 只告诉构建的 Clang 在哪里寻找 C++ 标准库和头文件,它与 LLVM/Clang 构建过程无关。我强烈建议同时构建和安装 libc++ 和 libc++abi,并将它们与新的 Clang 一起使用。

关于c++ - 用于 LLVM 的 GCC 工具链,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23665181/

相关文章:

c++ - 我无法在数字后扫描字符

c++ - make_shared、make_pair 等叫什么?

llvm - TableGen 语言中的模式支持是什么

llvm - 使用 CostModel 获取 LLVM IR 的 CPU 周期

configuration - clojure 中的惯用配置管理?

c++ - 如何在 C++ 中读/写 excel 复选框状态

windows - 如何在 Windows 中运行 llvm pass?

xcode - ./configure 在 OS X Lion 安装后找不到 C 编译器

c++ - "configure"脚本如何检测我的系统是否支持某些头文件或 cpp 功能?

python - 为 vim 编译 YouCompleteMe 时出错