C++ 默认启用 gcc 4.3.3 编译器选项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3138335/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 12:10:05  来源:igfitidea点击:

gcc 4.3.3 compiler options enabled by default

c++gccoptimizationcompiler-construction

提问by pv.

I have moved from gcc version 4.0.3 to 4.3.3 and realized that -mfpmath was set to sse by default in gcc 4.3.3. This actually caused errors in my application. In 4.0.3 the -mfpmath was 387.

我已经从 gcc 版本 4.0.3 移动到 4.3.3 并意识到 -mfpmath 在 gcc 4.3.3 中默认设置为 sse。这实际上在我的应用程序中导致了错误。在 4.0.3 中,-mfpmath 是 387。

I want to know how I can get all the default options enabled by gcc for a given version. How can I dump set of all options used by gcc while compiling. This enables me to compare version 4.0.3 vs 4.3.3.

我想知道如何获得 gcc 为给定版本启用的所有默认选项。编译时如何转储 gcc 使用的所有选项集。这使我能够比较版本 4.0.3 与 4.3.3。

In general it will be great if I can know a comprehensive list of things need to be checked before going for a version change in gcc .(As this has effect on performance and functionality.)

一般来说,如果我能知道在 gcc 中进行版本更改之前需要检查的完整事项列表,那就太好了。(因为这会影响性能和功能。)

回答by Ashaman

gcc -Q -v (inputfile)

gcc -Q -v(输入文件)

With just a basic tiny c or cpp file as an input file. Should give you a big list of all the options passed to gcc by default, one of those might be causing sse fp math to be enabled.

只需一个基本的微型 c 或 cpp 文件作为输入文件。应该为您提供默认情况下传递给 gcc 的所有选项的大列表,其中一个可能会导致启用 sse fp 数学。

回答by Trevor Robinson

In addition to compiling a specific file -Q -v, which outputs the list of passed and enabled options, as well as a lots of other version, configuration, and timing information, you can also use gcc -Q --help=targetto just list default target-specific compiler options:

除了编译一个特定的 file -Q -v,它输出传递和启用的选项列表,以及许多其他版本、配置和时间信息,您还可以使用gcc -Q --help=target仅列出默认的特定于目标的编译器选项:

$ gcc --version | head -1
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
$ gcc -Q --help=target
The following options are target specific:
  -m128bit-long-double                  [disabled]
  -m32                                  [disabled]
  -m3dnow                               [disabled]
  -m3dnowa                              [disabled]
  -m64                                  [enabled]
  -m80387                               [enabled]
  -m8bit-idiv                           [disabled]
  -m96bit-long-double                   [enabled]
  -mabi=
  -mabm                                 [disabled]
  -maccumulate-outgoing-args            [disabled]
  -maes                                 [disabled]
  -malign-double                        [disabled]
  -malign-functions=
  -malign-jumps=
  -malign-loops=
  -malign-stringops                     [enabled]
  -mandroid                             [disabled]
  -march=                               x86-64
...

To also include a list of target-specific assembler and linker options (but not currently their default settings), use --target-helpinstead of --help=target.

要还包括特定于目标的汇编器和链接器选项的列表(但目前不是它们的默认设置),请使用--target-help代替--help=target

回答by AProgrammer

  1. The version I've here of gcc 4.3.3 hasn't the behavior you are complaining about. I compiled it myself so I'm pretty sure that there must be another reason for the change you are seeing than just the gcc version (like compiling for 64 bit which has always used sse AFAIR).

  2. gcc has release notes which notifies of behavior changes. They are packaged with gcc source distribution and are available on the web. For gcc 4.3 see http://gcc.gnu.org/gcc-4.3/changes.html.

  1. 我在这里的 gcc 4.3.3 版本没有你抱怨的行为。我自己编译了它,所以我很确定你看到的变化肯定有另一个原因,而不仅仅是 gcc 版本(比如编译 64 位,它总是使用 sse AFAIR)。

  2. gcc 有发布说明,通知行为变化。它们与 gcc 源代码分发一起打包,可在网络上获得。对于 gcc 4.3,请参阅http://gcc.gnu.org/gcc-4.3/changes.html

回答by LThode

In addition to -Q --help=targetfor target-specific options, you can use -Q -O<n> --help=optimizeto display which optimizer passes are on or off at a given optimization level. -Qalso appears to work by itself with other --help=<blah>arguments as well.

除了-Q --help=target针对特定于目标的选项之外,您还可以使用-Q -O<n> --help=optimize来显示在给定优化级别打开或关闭哪些优化器传递。-Q似乎也可以单独使用其他--help=<blah>参数。