diff options
author | Davi Arnaut <davi.arnaut@oracle.com> | 2010-08-05 09:32:23 -0300 |
---|---|---|
committer | Davi Arnaut <davi.arnaut@oracle.com> | 2010-08-05 09:32:23 -0300 |
commit | 9d503b77e40436e1e90c8f383fddf210026b9623 (patch) | |
tree | a7ac50cefa300aa483ba9c97fc054d37ea364334 /BUILD/check-cpu | |
parent | b94d86215d3f785962cfe2398a2b4ad9b68c028e (diff) | |
download | mariadb-git-9d503b77e40436e1e90c8f383fddf210026b9623.tar.gz |
Bug#55601: BUILD/check-cpu in mysql-trunk is broken on Mac OS X 10.5
Restore the original behavior of check-cpu with respect to core2.
It isn't used as a actual target processor type, but as a mean to
perform other kinds of architecture checks.
Diffstat (limited to 'BUILD/check-cpu')
-rwxr-xr-x | BUILD/check-cpu | 146 |
1 files changed, 75 insertions, 71 deletions
diff --git a/BUILD/check-cpu b/BUILD/check-cpu index f9f5d423f4f..585043de67c 100755 --- a/BUILD/check-cpu +++ b/BUILD/check-cpu @@ -7,6 +7,79 @@ # check_cpu_args : Arguments for GCC compiler settings # +check_compiler_cpu_flags () { + # different compiler versions have different option names + # for CPU specific command line options + if test -z "$CC" ; then + cc="gcc"; + else + cc=$CC + fi + + # check if compiler is gcc and dump its version + cc_verno=`$cc -dumpversion 2>/dev/null` + if test "x$?" = "x0" ; then + set -- `echo $cc_verno | tr '.' ' '` + cc_ver="GCC" + cc_major=$1 + cc_minor=$2 + cc_patch=$3 + cc_comp=`expr $cc_major '*' 100 '+' $cc_minor` + fi + + case "$cc_ver--$cc_verno" in + *GCC*) + # different gcc backends (and versions) have different CPU flags + case `gcc -dumpmachine` in + i?86-* | x86_64-*) + if test "$cc_comp" -lt 304 ; then + check_cpu_cflags="-mcpu=${cpu_arg}" + elif test "$cc_comp" -ge 402 ; then + check_cpu_cflags="-mtune=native" + else + check_cpu_cflags="-mtune=${cpu_arg}" + fi + ;; + ppc-*) + check_cpu_cflags="-mcpu=${cpu_arg} -mtune=${cpu_arg}" + ;; + *) + check_cpu_cflags="" + return + ;; + esac + ;; + 2.95.*) + # GCC 2.95 doesn't expose its name in --version output + check_cpu_cflags="-m${cpu_arg}" + ;; + *) + check_cpu_cflags="" + return + ;; + esac + + # now we check whether the compiler really understands the cpu type + touch __test.c + + while [ "$cpu_arg" ] ; do + printf "testing $cpu_arg ... " >&2 + + # compile check + eval "$cc -c $check_cpu_cflags __test.c" 2>/dev/null + if test "x$?" = "x0" ; then + echo ok >&2 + break; + fi + + echo failed >&2 + check_cpu_cflags="" + break; + done + rm __test.* + return 0 +} + check_cpu () { CPUINFO=/proc/cpuinfo if test -n "$TEST_CPUINFO" ; then @@ -179,83 +252,14 @@ check_cpu () { return fi - # different compiler versions have different option names - # for CPU specific command line options - if test -z "$CC" ; then - cc="gcc"; - else - cc=$CC + if test "x$compiler" = "x" ; then + check_compiler_cpu_flags fi if test "x$core2" = "xyes" ; then cpu_arg="core2" fi - if test "x$compiler" != "x" ; then - return 0 - fi - - # check if compiler is gcc and dump its version - cc_verno=`$cc -dumpversion 2>/dev/null` - if test "x$?" = "x0" ; then - set -- `echo $cc_verno | tr '.' ' '` - cc_ver="GCC" - cc_major=$1 - cc_minor=$2 - cc_patch=$3 - cc_comp=`expr $cc_major '*' 100 '+' $cc_minor` - fi - - case "$cc_ver--$cc_verno" in - *GCC*) - # different gcc backends (and versions) have different CPU flags - case `gcc -dumpmachine` in - i?86-* | x86_64-*) - if test "$cc_comp" -lt 304 ; then - check_cpu_cflags="-mcpu=${cpu_arg}" - elif test "$cc_comp" -ge 402 ; then - check_cpu_cflags="-mtune=native" - else - check_cpu_cflags="-mtune=${cpu_arg}" - fi - ;; - ppc-*) - check_cpu_cflags="-mcpu=${cpu_arg} -mtune=${cpu_arg}" - ;; - *) - check_cpu_cflags="" - return - ;; - esac - ;; - 2.95.*) - # GCC 2.95 doesn't expose its name in --version output - check_cpu_cflags="-m${cpu_arg}" - ;; - *) - check_cpu_cflags="" - return - ;; - esac - - # now we check whether the compiler really understands the cpu type - touch __test.c - - while [ "$cpu_arg" ] ; do - printf "testing $cpu_arg ... " >&2 - - # compile check - eval "$cc -c $check_cpu_cflags __test.c" 2>/dev/null - if test "x$?" = "x0" ; then - echo ok >&2 - break; - fi - - echo failed >&2 - check_cpu_cflags="" - break; - done - rm __test.* return 0 } |