它经常使用主机 binutils(用于链接器和汇编器)、用于 crt 文件和内部编译器头文件的主机编译器和用于 C++ 程序/库中 ABI 兼容性的 c++ 库。
工具链
gcc 驱动程序对工具链没有直接的了解。每个 gcc 二进制文件大致对应于嵌入在单个 ToolChain 中的信息。
clang 驱动程序旨在可移植并支持复杂的编译环境。所有平台和工具链特定的代码都应该在抽象或明确定义的接口后面进行保护(例如平台是否支持用作驱动程序驱动程序)。
绑定:工具和文件名选择。
从概念上讲,驱动程序执行自上而下的匹配以将操作分配给工具。 ToolChain 负责选择执行特定操作的工具;选择后,驱动程序会与工具进行交互,以查看它是否可以匹配其他操作(例如,通过集成预处理器)。
驱动程序与 ToolChain 交互以执行工具绑定。每个 ToolChain 都包含有关编译特定架构、平台和操作系统所需的所有工具的信息。单个驱动程序调用可能会在一次编译期间查询多个 ToolChain,以便与不同架构的工具进行交互。
此阶段的结果不是直接计算的,但驱动程序可以通过 -ccc-print-bindings 选项打印结果。例如:
$ 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 版本的工具。