如果您同时指定多个优化标志,gcc(和clang)会做什么? [英] What does gcc (and clang) do if you specify more than one optimization flag together?

查看:87
本文介绍了如果您同时指定多个优化标志,gcc(和clang)会做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管可以配置一个附加标志,但无法弄清楚构建系统:在尝试进行一些快速和肮脏的测试时,我可以注入一个附加的-O3标志来查看程序的运行方式.性能是在-O3优化下进行的.

The build system is impossible to figure out, although it IS possible to configure an additional flag: In trying to do some quick-and-dirty tests, I'm able to inject an additional -O3 flag to see how the program's performance is under -O3 optimization.

但是,还指定了-O2,并且之后指定了-O2.

However, -O2 is also specified, and is specified afterwards.

问题是,对于编译器而言,只有最后一个优化标志会保留吗?还是(希望)采用最高指定的优化级别?还是未定义?毫无疑问,这绝对不是在抱怨或犯错.

The question is, is it well-defined that for the compiler only the last optimization flag will stick? Or will it (I hope) go with the highest-specified optimization level? Or is it undefined? It is definitely not complaining or erroring out, that's for sure.

推荐答案

全部在文档中.来自 gcc优化选项:

如果使用多个-O选项(带有或不带有级别编号),则最后一个这样的选项才是有效的.

If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.


如果同时指定多个优化标志,gcc(和clang)会做什么?

What does gcc (and clang) do if you specify more than one optimization flag together?

您使用的编译器使用在命令行上最后指定的优化 -O 选项.

The compilers you are using use the optimization -O option that was specified last on the command line.

对于编译器,只有最后一个优化标志会保留吗?

is it well-defined that for the compiler only the last optimization flag will stick?

它已记录在您的编译器文档中.

It's documented in your compilers documentation.

还是将其指定为最高的优化级别?

Or will it go with the highest-specified optimization level?

否.

还是未定义?

否.

这篇关于如果您同时指定多个优化标志,gcc(和clang)会做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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