Setting the makefile variable AUTO_OPT_GCC will give GCC a list of optimization flags suited for the machine make is run on. It does this using util/auto-opt.sh. "-march=native -mtune=native" are always outputted, which causes GCC to detect the CPU type you use and generate code for that. On Linux systems it also looks at the flags line of /proc/cpuinfo to pick x86 optimization flags.
HEQAW4ICQJP6TQGYTYLWBXEWO2TJIVZREUIEVYA2LGTQYMY5IGCAC AMYZN5E6SNZWQI4BVLZIG5DYB3S6ATHUSLJIABDXXYKDAHODA3SQC RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC HCTDAXFRE6LXGHLKOMM7GX3YXGWJYM4DLZS7ITWYTXC5NWZBB2OQC 6DZUZUSYGFQGDSWQYPHIAOCN6EUURKO5TWMMQMB4427ZG55X7LCQC K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC P7MDK4LUKDI2Z24FTQYRZDAT3HJZ7CGP5NRTO4IMTGB3F776ZJYAC GL5T36G3A2LUTTYSL7ZQVUYONUCXL5DK36532FM6XRAQCLYDWW2QC SSPFGPVYFTWDK3ZMQQKOPVM5SVES62TL5KFEFC2PX4PMZDWHTIOQC #!/bin/bash --noprofile########################################################################## Called by the makefile if AUTO_OPT_GCC is true, outputs the list of CPU# specific optimization flags that should be used.##########################################################################TODO: Detect extra compiler options for:## * Non-gcc compilers.# * CYGWIN.# * Mac OS X.# * Non-x86 Linux systems.########################################################################## This line makes GCC automatically detect the CPU architecture to use. Also# might cause the use of some of the "-m" options we use down below,# but GCC doesn't complain about an "-m" option being used repeatedly.OUT="-mtune=native -march=native"if [ -f /proc/cpuinfo ]; then# On Linux system, the "flags: " line of /proc/cpuinfo indicates which# extended instruction sets are available (among other things), so we# can use that to detect what to use.# Only get info for the first CPU; assumes that all CPUs in the system# are the sameINFO=`cat /proc/cpuinfo | grep '^flags.*:' | head -n 1`# These are currently all x86 specific.for flag in cx16 mmx sse sse2 sse3 sse4.1 sse4.2 sse4 sse4a 3dnow abm; do# Put a space on either side of the flag name, so that it won't# match in the middle of a flag.if [[ $INFO == *\ $flag\ * ]] ; thenOUT="$OUT -m$flag"fidoneif [[ $INFO == *\ lahf_lm\ * ]]; thenOUT="$OUT -msahf"fi# Any available SSE lets us use -mfpmath=sseif [[ $INFO == *\ sse* ]]; thenOUT="$OUT -mfpmath=sse"fifiecho "$OUT"
CFOPTIMIZE := -O2
# Define this to automatically generate code optimized for your machine# (GCC only as of now).## NOTE: Don't use this with a release build, since the generated code# won't work for all machines.ifdef AUTO_OPT_GCCifdef CROSSHOSTerror Can not do AUTO_OPT_GCC with CROSSHOSTendififdef HURRYerror Can not do AUTO_OPT_GCC with HURRYendifAUTO_OPT_FLAGS := $(shell util/auto-opt.sh)endifCFOPTIMIZE := -O2 $(AUTO_OPT_FLAGS)