Linux 4.17 Kernel Patch Brings -march=native Support

Written by Michael Larabel in Linux Kernel on 4 June 2018 at 08:00 PM EDT. 16 Comments
A Gentoo user has revised his kernel patch allowing the mainline Linux kernel to be built with the GCC "-march=native" compiler optimizations for targeting the kernel build against your particular CPU.

While -march=native of modern compilers is popular with developers/enthusiasts for building optimized packages targeting your specific CPU micro-architecture, the mainline Linux kernel still does not support this functionality. But Gentoo user Alexey Dobriyan.

The 400+ line patch dubbed 4.17-ad1 allows compiling the kernel with the "-march=native" compiler flag and for it to be honored.

Those interested can find the patch here though it's only received minimal testing on Intel hardware and still has some open TODO items.

The developer hasn't supplied any benchmarks though on his original version of the patch he noted, "Random microbenchmarking indicates that a) SHLX et al enabled SHA-1 can be ~10% faster than regular one as there are no carry flags dependencies and b) REP STOSB clear_page() can be ~15% faster then REP STOSQ one where fast REP STOSB is advertised. This is actually important because clear_page()/copy_page() are regularly seen on top of kernel profiles."

When time allows I'll probably give the kernel build a whirl and see how it does in some real-world Linux benchmarks.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via

Popular News This Week