关于您的最后一个问题: gcc 4.6.1 来源(gcc/gcc.c
)包含以下评论%>
:
%>S Similar to "%<S", but keep it in the GCC command line.
为了完整起见,请遵循%<
形成同一文件的评论:
%<S remove all occurrences of -S from the command line.
Note - this command is position dependent. % commands in the
spec string before this one will see -S, % commands in the
spec string after this one will not.
简短地回答第一个问题:是的,但是....
...我发现的唯一通用解决方案有一个重大缺点,即该-march
选项将被忽略,因此每次构建都像-march=native
指定的那样完成。无论如何,有一个解决方法。
1 解决方案(没有解决方法)
创建一个名为让我们说specs.nativealways
包含:
*cc1_cpu:
%<march=* -march=native %>march=native %:local_cpu_detect(arch) %{!mtune=*:%>mtune=native %:local_cpu_detect(tune)} %{mtune=native:%>mtune=native %:local_cpu_detect(tune)}
使用 specs 文件时(例如通过gcc
使用 option调用-specs=specs.nativealways
),构建将按照-march=native
指定的方式完成(具有提到的缺点,即任何出现的 option-march=<arch>
都将被简单地忽略)。
2 解决方法
为了仍然能够覆盖新配置的默认行为,可以使用上述规范文件的修改版本,引入一个新选项,使用与(except for )-myarch
相同的语法调用,它不起作用,不符合现在是默认值)。-march
-myarch=native
native
修改后的规格文件如下所示:
*cc1_cpu:
%<march=* %{myarch=*:%<myarch* -march=%* ; :-march=native %>march=native %:local_cpu_detect(arch) %{!mtune=*:%>mtune=native %:local_cpu_detect(tune)}} %{mtune=native:%>mtune=native %:local_cpu_detect(tune)}
PS:这已经在 Linux 上使用 gcc 4.6.2 进行了测试,但应该适用于 MinGW。