GCC options: (-m64) vs (-march=native) vs (-march=core2) -- Which one(s) to use?
Reference of compiler flags: http://gcc.gnu.org/onlinedocs/gcc/i3...4-Options.html
So, what that page doesn't quite tell me, is which if any of the compiler flags I'm using, are absolutely mutually inclusive/exclusive, except for one thing it does say:
-march=XXX implies -mtune=XXX
My CPU is an Intel E2160 CORE2 with EM64T, and I'm running and building stuff for Slack64.
So, I'd like to know, if possible, ragarding my CPU:
1) Is -march=native identical to -march=core2? Will they produce identical code for me?
2) Does -march=[native|core2] imply -m64 or is -m64 just a generic sort of thing, for non-specific CPU's when no -march is specified?
Do I need to specify -m64 at all? Maybe my GCC + CPU will = CPU-optimized 64 bit code by default, just by specifying the -march flag??
To make selection of the best method simple, consider the following possible combinations, noting the order of the flags. Is Any particular one of these methods going to be "the best" for me?:
t) gcc -march=core2
u) gcc -march=native
v) gcc -m64
w) gcc -march=native -m64
x) gcc -march=core2 -m64
y) gcc -m64 -march=native
z) gcc -m64 -march=core2
Please help clarify/distinguish these options for me :)
First let me refer you to the safe cflags listing:
2) You really never need to specify -m64, unless you are compiling a 64-bit executable on a 32-bit system. And you only need to specify -m32 when you are compiling a 32-bit executable on a 64-bit system.
So no, you don't need to specify -m64, in fact even without the -march flag you still don't need it.
Probably the best thing to use is either -march=native or the safe cflags above.
Thank you so much for pointing me towards those Gentoo Wiki pages. Ever since the Gentoo team had their crash a while back and/or a lot of their most helpful pages got lost, it's been more difficult to find them using Google OR by using their Wiki index pages.
It looks like based on those pages, exactly what I want is "-march=native" and that should do the most, with the least. According to my /proc/cpuinfo, I don't appear to have a use for -msse4_1 though.
Thanks for the perfect answer!
Actually the old gentoo wiki is still available here:
It still contains some things not available in the new wiki.
AFAIK, -march=core2 is only supported from gcc4.3.2 up right? I use -march=native -mtune=native and I have the same processor as you. If you are planning to install the compiled packages to another system then try -mtune=generic
H_TeXMeX_H, thanks again for the link to the Gentoo ARCHIVE -- I had no idea, and had never encountered that via Google. Phooey :|
Shylock -- Yes, according to the GCC changelog: http://gcc.gnu.org/gcc-4.3/changes.html the way I read it, gcc4.3.x introduced the -march=core2 flag, and gcc4.2.x introduced the -march=native flag according to this Gentoo Wiki page: http://en.gentoo-wiki.com/wiki/Safe_...march.3Dnative
I'm just building for my own system, so I'll be using "native".
|All times are GMT -5. The time now is 02:51 AM.|