GCC的pass和调用的程序是什么?
它出现在另一个问题中:程序和部件叫什么通过gcc
(特别是在编译C
或C++
时),以便有人可以设计某种拦截和改变流程以用于各种自定义编码目的的方案?
It came up in another question: What are the programs and parts called by gcc
(particularly when compiling C
or C++
) so that someone might engineer some scheme of intercepting and altering the flow for various custom coding purposes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编译器二进制文件是“编译器驱动程序”(即
gcc
),编译器本身也兼作预处理器(cc1
或cc1plus
) 。它还调用汇编器 (as
) 和链接器 (ld
)。此外,还有一个名为collect2
的工具,可以在某些情况下在链接过程中提供帮助。如果您想查看中间状态和调用是什么,请执行以下操作:
如果您想查看编译器的优化过程,请使用以下选项:
这会生成(模糊地)人类可读的内部状态转储,以用于调试目的。这是肯定的,您无法保存并稍后重新加载到编译器中,但如果您打算修改编译器的源代码或编写 GCC 插件,那么它会很有帮助。
The compiler binaries are the "compiler driver" (i.e.
gcc
), and the compiler itself which also doubles as a preprocessor (cc1
orcc1plus
). It also invokes the assembler (as
), and the linker (ld
). Additionally there's a tool calledcollect2
that assists during the link process in some cases.If you want to see what the intermediate states and invocations are then do this:
If you want to see the compiler's optimization passes, then use these options:
This produces (vaguely) human readable dumps of the internal state for debugging purposes. It's nothing you could save and reload into the compiler later, that's for sure, but it's helpful if you plan to modify the compiler's source, or write a GCC plugin.
准确观察程序的名称:
具体步骤由规范文件确定,格式为: https://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/Spec-Files.html
查看默认值(在 GCC 中硬编码):
运行您自己的规范默认文件之后的文件:
Observe exactly what programs are called:
The exact steps are determined by a spec file with format: https://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/Spec-Files.html
View the default (hard-coded in GCC):
Run your own spec file after the default one: