命令"clang -v"打印:
$ clang -v
clang version 3.4 (tags/RELEASE_34/final)
Target: i386-redhat-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/i686-redhat-linux/4.8.2
Selected GCC installation: /usr/bin/../lib/gcc/i686-redhat-linux/4.8.2
Run Code Online (Sandbox Code Playgroud)
"clang选择gcc installatiom"是什么意思?为什么?Clang是否独立于gcc?
谢谢您帮忙.
编辑:
我在页面https://bbs.archlinux.org/viewtopic.php?id=129760找到了一个可能的一般答案(我使用Fedora 20)
如果此主机有其他默认编译器(clang 在 Apple 的 OSX/macOS 和FreeBSD 的变体上是默认的),Clang 会使用主机编译器的多个设置。获得与其他二进制文件和操作系统库的更多兼容性很有用。
它通常使用主机 binutils(用于链接器和汇编器)、用于 crt 文件的主机编译器和内部编译器头文件以及用于 C++ 程序/库中的 ABI 兼容性的 C++ 库。
工具链选择是 clang 驱动程序(clang
命令)的一部分,在https://github.com/llvm-mirror/clang/blob/master/lib/Driver/ToolChains.cpp文件中实现。
Clang 的“Driver Design & Internals”中有一些文档 http://clang.llvm.org/docs/DriverInternals.html
工具链
gcc 驱动程序对工具链没有直接的理解。每个 gcc 二进制文件大致对应于嵌入在单个 ToolChain 中的信息。
clang 驱动程序旨在可移植并支持复杂的编译环境。所有平台和工具链特定代码都应受抽象或定义良好的接口(例如平台是否支持用作驱动程序驱动程序)的保护。
绑定:工具和文件名选择。从概念上讲,驱动程序执行自上而下的匹配以将操作分配给工具。ToolChain 负责选择执行特定操作的工具;选择后,驱动程序与工具交互以查看它是否可以匹配其他操作(例如,通过集成预处理器)。
驱动程序与 ToolChain 交互以执行 Tool 绑定。每个 ToolChain 都包含有关为特定架构、平台和操作系统编译所需的所有工具的信息。在一次编译期间,单个驱动程序调用可能会查询多个 ToolChain,以便与不同架构的工具进行交互。
此阶段的结果不是直接计算的,但驱动程序可以通过 -ccc-print-bindings 选项打印结果。例如:
Run Code Online (Sandbox Code Playgroud)$ clang -ccc-print-bindings -arch i386 -arch ppc t0.c # "i386-apple-darwin9" - "clang", inputs: ["t0.c"], output: "/tmp/cc-Sn4RKF.s" # "i386-apple-darwin9" - "darwin::Assemble", inputs: ["/tmp/cc-Sn4RKF.s"], output: "/tmp/cc-gvSnbS.o" # "i386-apple-darwin9" - "darwin::Link", inputs: ["/tmp/cc-gvSnbS.o"], output: "/tmp/cc-jgHQxi.out" # "ppc-apple-darwin9" - "gcc::Compile", inputs: ["t0.c"], output: "/tmp/cc-Q0bTox.s" # "ppc-apple-darwin9" - "gcc::Assemble", inputs: ["/tmp/cc-Q0bTox.s"], output: "/tmp/cc-WCdicw.o" # "ppc-apple-darwin9" - "gcc::Link", inputs: ["/tmp/cc-WCdicw.o"], output: "/tmp/cc-HHBEBh.out" # "i386-apple-darwin9" - "darwin::Lipo", inputs: ["/tmp/cc-jgHQxi.out", "/tmp/cc-HHBEBh.out"], output: "a.out"
这显示了为此编译序列绑定的工具链、工具、输入和输出。这里使用 clang 在 i386 架构上编译 t0.c,使用 darwin 特定版本的工具来组装和链接结果,但在 PowerPC 上使用通用 gcc 版本的工具。
归档时间: |
|
查看次数: |
3064 次 |
最近记录: |