简体   繁体   English

如何告诉gcc告诉我你使用的优化标志列表

[英]How to tell gcc show me the list of optimization flags you used

I have read the gcc documentation for optimization options. 我已经阅读了gcc 文档以了解优化选项。 They do not have examples. 他们没有例子。

One tedious method is to use godbolt and try so many options and see which option works for a specific optimization flag. 一个繁琐的方法是使用godbolt并尝试这么多选项,看看哪个选项适用于特定的优化标志。

I have written the following trivial code: 我写了以下琐碎的代码:

#include <cmath>

double calculate(double x)
{
    int y=x+sin(x);
    return exp(x)+exp(-x);
}

int main(int argc,char *argv[])
{
    return ceil(calculate(argc));
}

and I compiled it with 我编译了它

g++ -Q -v -O3 main.cpp

which prints all enabled optimization flag for me and not the used option flags. 它为我打印所有启用的优化标志,而不是使用的选项标志。 I also need to know the optimization flags for a specific function excluding the optimizations used for the libraries. 我还需要知道特定函数的优化标志,不包括用于库的优化。

How is it possible for me to get the list of optimization flags used for compilation of calculate function? 我怎么可能得到用于编译calculate函数的优化标志列表?

现代版本的GCC具有-fverbose-asm选项,可以转储在汇编文件中的注释中启用的优化选项,您可以通过使用-S-save-temps进行编译

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM