15

GCC have -march= and -mtune option as described here. But it is not obvious which of the options to choose for x64 platform as generic one. Say, -mtune= have the generic value, but -march= for x64 have no.

I suspect that -march=nocona (as frequently seen everywhere) or even -march=i686 -m64 is the solution, but I'm not sure.

Tomilov Anatoliy
  • 15,657
  • 10
  • 64
  • 169

1 Answers1

19

The generic x86-64 -march is -march=x86-64.

It is usually the default for GCC targeting x86-64, but that default can be changed at configure time by passing appropriate value to --with-arch.

  • 1
    But `echo "" | gcc -v -E - 2>&1 | grep cc1` produce the following: `c:/mingw/bin/../libexec/gcc/x86_64-w64-mingw32/4.8.0/cc1.exe -E -quiet -v -iprefix c:\mingw\bin\../lib/gcc/x86_64-w64-mingw32/4.8.0/ -D_REENTRANT - -mtune=core2 -march=nocona` – Tomilov Anatoliy Apr 29 '13 at 08:23
  • 1
    @Dukales: on my machine it produces `/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/cc1 -E -quiet -v - -mtune=generic -march=x86-64`. See the point about `--with-arch`. –  Apr 29 '13 at 08:27
  • Thank you. So, it depends on the build of GCC/MinGW. – Tomilov Anatoliy Apr 29 '13 at 08:29
  • @Dukales that output shows only the optimizations used to build the GCC executables, in your case tuned to an Intel Core2 CPU and using everything up to SSE3. – rubenvb Apr 29 '13 at 09:18
  • @rubenvb: actually, no. It shows the arguments the driver passes to `cc1`. –  Apr 29 '13 at 09:21
  • Oh, then you've got a dangerous GCC build on your hands. – rubenvb Apr 29 '13 at 09:24
  • @rubenvb Ok, it is your rival - mingw-builds project =) – Tomilov Anatoliy Apr 29 '13 at 13:42
  • 1
    @Dukales lol yes. It's only dangerous because one would expect an executable compiled default options (no `-march`) to work on all CPUs. In this case it wouldn't. Be careful `:P` – rubenvb Apr 29 '13 at 14:04
  • Why it's not documented in `man gcc`, `-mtune=cpu-type` in the `cpu-type` list also used by `-march`? I took me some time to get this to work. If not for this answer here, I would still be reading why I got problems using the `i686` instead. – DrBeco Oct 06 '14 at 04:45
  • Is there a reason that GCC doesn't support the more common name `x86_64` instead of `x86-64`? – Aaron Franke Feb 25 '22 at 05:02