Nytro Posted November 2, 2011 Report Posted November 2, 2011 How to recompile software with hardware optimizationsOvidiu / 02/11/2011I don’t like to recompile software. I also laugh my ass off when some Gentoo “god” tells me how much faster their system became after they tweaked their compile flags. But (because there’s always a “but”) once in a while I do compile software. And in some of those cases, I really want the best optimization possible.One of these cases was when I wanted to run a CPU miner for Litecoin on my i7. I wanted to squeeze the most out the CPU, so I turned to the Gentoo wiki, where I found this page (seems down when I wrote this).You can find out the hardware flags for GCC running this simple commannd:$ echo "" | gcc -march=native -v -E - 2>&1 | grep cc1The result looks something like this:/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/cc1 -E -quiet -v - -D_FORTIFY_SOURCE=2 [COLOR="Blue"]-march=core2 -mcx16 -msahf -mpopcnt -msse4.2 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=6144 -mtune=core2[/COLOR] -fstack-protectorThe part in blue is the interesting part and it should be used as part of the CFLAGS. Adding a -O3 there can’t hurt, either:$ CFLAGS="-O3 -Wall <blue-string-from-above>" ./configureA ‘make’ will then build whatever program you’re compiling with the best optimizations for your hardware.I hope it’s useful! Enjoy!Autor: OvidiuSursa: http://blog.mybox.ro/2011/11/02/how-to-recompile-software-with-hardware-optimizations/ Quote