Clear Linux's make-fmv-patch Eases The Creation Of GCC FMV-Enabled Code Paths
Written by Michael Larabel in GNU on 18 January 2019 at 05:16 AM EST. 11 Comments
GNU --
One of the GCC compiler features unfortunately not taken advantage of by most Linux distributions is FMV - Function Multi-Versioning. FMV is what allows for the compilation of different tuned code paths depending upon the processor and for the particular code-path to be chosen at run-time, i.e. optimizing to your heart's content with AVX, SSE4, and other instruction set extensions and compiling all of that into a single binary and for the preferred code path to be taken depending upon the CPU running the binary so it will still run on older CPUs as well as today's most powerful processors.

FMV isn't widely taken advantage of since most Linux distributions don't take performance serious enough to invest that level of detail into optimizations but also because it's another code path / option that can trouble the debugging process when user problems arise. But for those wanting to ship optimized binaries while retaining compatibility with other generations of CPUs, GCC FMV is there.

Clear Linux is the only Linux distribution I am aware of employing FMV as part of their packaging process. As part of that they have a make-fmv-patch utility for helping to spin their function-multi-versioned patches. Their primary motivation with FMV is for allowing AVX-optimized code paths in programs where there is performance benefits to be exploited. Make-fmv-patch has always been open-source while now some documentation has been added that sheds some light on the process.

For generating FMV patches, first they compile the given code with the GCC vectorization flag while using -fopt-info-dev to dump the details on where the compiler could successfully vectorize a given chunk of code. The make-fmv-patch, which is a fairly small Perl script, then parses that GCC output in order to produce a patch that adds the necessary attributes for GCC FMV in the areas where the compiler could successfully vectorize the code. After patching the original source code, the code can then be compiled a final time.

Those interested in exploring it more can find make-fmv-patch on GitHub with the newly-added documentation. It's too bad though that the process isn't more streamlined by GCC itself and/or built into other toolchain processes for aiding the adoption.

If you are only hearing about FMV for the first time, you can learn more about this compiler capability via the GCC Wiki. There is also this LPC 2016 presentation on the topic.
Related News
About The Author
Author picture

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 or contacted via

Popular News This Week