diff options
author | msvensson@neptunus.(none) <> | 2005-04-27 12:50:37 +0200 |
---|---|---|
committer | msvensson@neptunus.(none) <> | 2005-04-27 12:50:37 +0200 |
commit | 6b84489a018fc01fcdba002669b209101e987101 (patch) | |
tree | 666dbd45ebcb68e18dedf88cf17571c835bae608 /BUILD/check-cpu | |
parent | 30caa4a32d4160ca06d56b191d1172791ea95acb (diff) | |
download | mariadb-git-6b84489a018fc01fcdba002669b209101e987101.tar.gz |
Bug#9263 GCC4: -mcpu is depricated, use -mtune or -march instead
- Made a script that selects the best compiler optimizations for the current cpu.
- Use the script from BUILD/SETUP.sh
Diffstat (limited to 'BUILD/check-cpu')
-rwxr-xr-x | BUILD/check-cpu | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/BUILD/check-cpu b/BUILD/check-cpu new file mode 100755 index 00000000000..633aa9e8a00 --- /dev/null +++ b/BUILD/check-cpu @@ -0,0 +1,77 @@ +#!/bin/sh +# +# Check cpu of current machine and find the +# best compiler optimization flags for gcc +# +# + +if test -r /proc/cpuinfo ; then + cpuinfo="cat /proc/cpuinfo" + cpu_family=`$cpuinfo | grep 'family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` + if test -z "$cpu_family" ; then + cpu_family=`$cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` + fi + cpu_vendor=`$cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` + model_name=`$cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1` + if test -z "$model_name" ; then + model_name=`$cpuinfo | grep 'cpu model' | cut -d ':' -f 2 | head -1` + fi + if test -z "$model_name" ; then + model_name=`uname -m` + fi +else + exit 0 +fi + +case "$cpu_family--$model_name" in + Alpha*EV6*) + cpu_flag="ev6"; + ;; + *Xeon*) + cpu_flag="nocona"; + ;; + *Pentium*4*CPU*) + cpu_flag="pentium4"; + ;; + *Athlon*64*) + cpu_flag="athlon64"; + ;; + *Athlon*) + cpu_flag="athlon"; + ;; + *Itanium*) + # Don't need to set any flags for itanium(at the moment) + cpu_flag=""; + ;; + *ppc) + cpu_flag="powerpc"; + ;; + *) + cpu_flag="i386"; + ;; +esac + +echo "cpu_flag: $cpu_flag" + +if test -z "$CC" ; then + cc="gcc"; +else + cc=$CC + +fi + +cc_ver=`$cc --version | sed 1q` +cc_verno=`echo $cc_ver | sed -e 's/[^0-9. ]//g; s/^ *//g; s/ .*//g'` + +case "$cc_ver--$cc_verno" in + *GCC*--3.4*|*GCC*--3.5*|*GCC*--4.*) + check_cpu_cflags="-mtune=$cpu_flag -march=$cpu_flag" + ;; + *GCC*) + check_cpu_cflags="-mcpu=$cpu_flag -march=$cpu_flag" + ;; + *) + check_cpu_cflags="" + ;; +esac +echo $check_cpu_cflags |