如何使gcc显示调用的内部命令? [英] How to make gcc show the internal commands called?

查看:88
本文介绍了如何使gcc显示调用的内部命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以让gcc(MinGW/Windows)显示所有被调用的命令行?

Is there a possibility to let gcc (MinGW/Windows) to show all command lines called?

示例:

gcc -o test.exe test.c -desiredOption

...应该输出如下内容:

... should output something like this:

cc1 -o intermediate.s test.c
as -o intermediate.o intermediate.s
ld - o test.exe intermediate.o crt0.o -lsomelibrary -e __start

背景:

有时候,当我调用"gcc"时,一些与汇编器相关的选项会很好地工作,但是当我尝试直接调用"ld.exe"时,它们根本无法工作.因此,我想知道"gcc.exe"将哪个选项真正传递给了"ld.exe".

Sometimes some assembler-related options work well when I call "gcc" but they do not work at all when I try to call "ld.exe" directly. Therefore I want to know which option is really passed to "ld.exe" by "gcc.exe".

在Linux下,我会使用类似的东西:

Under Linux I would use something like:

strace -f gcc -o test.exe test.c

...以查看命令行(作为execve系统调用的参数).

... to see the command lines (as arguments of the execve system calls).

推荐答案

阅读 GCC文档的"noreferrer>调用GCC 一章.您需要 -v选项:

Read the Invoking GCC chapter of the GCC documentation.You want the -v option:

(在标准错误输出上)打印执行以运行编译阶段的命令.还要打印编译器驱动程序的版本号,预处理器和正确的编译器的版本号.

Print (on standard error output) the commands executed to run the stages of compilation. Also print the version number of the compiler driver program and of the preprocessor and the compiler proper.

请注意,在Linux上, strace(1)确实可以不显示 command 行,而是系统调用.

Notice that on Linux, strace(1) does not show command lines, but system calls.

这篇关于如何使gcc显示调用的内部命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆