This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Default value for -march option


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:
http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html

"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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]