This is the mail archive of the
mailing list for the GCC project.
Re: Default value for -march option
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Anthony S <ast_dev at ymail dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Mon, 17 Dec 2012 15:06:23 +0000
- Subject: Re: Default value for -march option
- References: <1355746334.4441.YahooMailNeo@web120105.mail.ne1.yahoo.com>
On 17 December 2012 12:12, Anthony S wrote:
> What is the default value for -march option on all platforms generally and on x86_64 particularly?
There is no default in general, because it's platform-specific.
> I've compiled some code with gcc using these options:
> -g -O3 -fstrength-reduce -Werror -Wall -Wpointer-arith
> See that -march is not set explicitly. Code was compiled on i3 and I've found that generated executable contains AVX instructions (it failed with SIGILL in VirtualBox, VirtualBox does not support AVX yet)
> There is no information about default -march value in GCC docs,
There is in newer copies of the docs:
"While picking a specific cpu-type schedules things appropriately for
that particular chip, the compiler does not generate any code that
cannot run on the default machine type unless you use a
-march=cpu-type option. For example, if GCC is configured for
i686-pc-linux-gnu then -mtune=pentium4 generates code that is tuned
for Pentium 4 but still runs on i686 machines."
I didn't make that change to the GCC 4.6 docs.
> and I think that sane default value should not be -march=native or core-avx-i. Compiler should include modern instructionsonly if it is explicitly told to do so
That's what it does.
> GCC version where this problem was found is 4.6.3
Since GCC 4.5 the default value for -march is set from the configure
target (see http://gcc.gnu.org/gcc-4.5/changes.html#x86 for the
release notes documenting the change) so I assume either your GCC was
configured for something like core-avx-i-*-* or you've found a bug.
Running 'gcc -v' will tell you what target it was configured for.