Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC: mtune vs march vs mcpu

Tags:

gcc

I'm trying to make some optimized builds on several ARM SBCs, where each build will have compatability only on the target platform I'm building on.

I've heard that -march is more preferable here compared to -mtune as it will break break backwards compatability with other cpus in the architecture family by generating instructions that are only compatile with the host cpu. -mtune on the other hand will keep this compatabiliy.

However, I've read that -mcpu is possibly the best flag to set instead of -march or -mtune as -mcpu is specific to the very processor, not just the more common architecture specified by -marm (a difference of something like -mcpu=cortex-a8 over -march=armv7-a).

Now the tricky thing is I'm also reading that -mcpu is deprecated and its functionality is taken over by -mtune, which conflicts with my previous comments regarding the use of -mtune being undesirable when compared to -march and -marm being undesirable when compared to -mcpu.

Essentially, which flag will give me the best performance for the host machine when I don't care to maintain compatability with other cpus at all.

like image 416
Mike Dank Avatar asked Mar 10 '17 12:03

Mike Dank


1 Answers

-mcpu unfortunately has different semantics for different targets. It's deprecated for x86 (being a synonym for -mtune) but not for ARM, where it's a sum of -march and -mtune.

So to answer your question - on ARM, always use -mcpu for best performance, unless you care for backwards compatibility.

like image 77
yugr Avatar answered Oct 18 '22 01:10

yugr