ShrekMovieFreeLegit wrote:So basically, -march=native should do the same as CPU_FLAGS_X86. Thanks a lot!
No.
-march=native tells gcc to use whatever natively available instructions it wants when generating assembly from C/C++. This generally happens on a fairly granular level, like using
xmm instructions for bulk copying of small structures. It will usually not have a large scope view, such as completely changing how a function is implemented. CPU_FLAGS_X86 is used to advise particular packages to enable whole optional features. Such features are dozens or hundreds of lines long, and rely on a given CPU feature throughout. The complexity of the tool feature precludes trusting gcc to just guess that a few statements here and there ought to use the CPU feature. That is why you should use both:
-march lets gcc opportunistically use advanced CPU features when specific C statements can be done better. CPU_FLAGS_X86 lets a tool build an entirely different code path, which presumably is more efficient than the generic alternative. (In some cases, the tool's maintainers may have decided not to write the generic version at all, so you don't even get the tool's feature, even in a slow inefficient version, if you don't enable the right CPU_FLAGS_X86.)