What are GCC's passes and invoked programs?

大城市里の小女人 提交于 2019-12-05 12:26:48

The compiler binaries are the "compiler driver" (i.e. gcc), and the compiler itself which also doubles as a preprocessor (cc1 or cc1plus). It also invokes the assembler (as), and the linker (ld). Additionally there's a tool called collect2 that assists during the link process in some cases.

If you want to see what the intermediate states and invocations are then do this:

gcc -save-temps -v .....

If you want to see the compiler's optimization passes, then use these options:

gcc -fdump-tree-all -fdump-rtl-all ....

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.

Observe exactly what programs are called:

gcc -v main.c

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):

gcc -dumpspecs

Run your own spec file after the default one:

gcc -specs=file
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!