diff --git a/BUILD/build_mccge.sh b/BUILD/build_mccge.sh index cb70a8cef67..f29a2f1db34 100755 --- a/BUILD/build_mccge.sh +++ b/BUILD/build_mccge.sh @@ -71,9 +71,10 @@ cat < ./build_mccge.sh + shell> BUILD/build_mccge.sh This performs the following operations: 1) Detects the operating system. Currently, Linux, FreeBSD, Solaris @@ -128,7 +129,7 @@ cat < temp_test.c + if test "x$m64" = "xyes" ; then + cmd="$CC $compile_flags -m64 temp_test.c" + if ! $cmd 2>1 ; then + m64="no" + echo "Changing to 32-bits since 64-bits didn't work" + else + echo "Will use 64-bits" + fi + else + cmd="$CC $compile_flags -m32 temp_test.c" + if ! $cmd 2>1 ; then + m64="yes" + echo "Changing to 64-bits since 32-bits didn't work" + else + echo "Will use 32-bits" + fi + fi + rm temp_test.c +} + +# +# Get GCC version +# +get_gcc_version() +{ + # 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 + gcc_version=`expr $cc_major '*' 100 '+' $cc_minor` + fi +} + +# +# Link Time Optimizer in GCC (LTO) uses a parameter -flto +# which was added to GCC 4.5, if --with-link-time-optimizer +# is set then use this feature +# +check_for_link_time_optimizer() +{ + get_gcc_version + if test "$gcc_version" -ge 405 && \ + test "x$with_link_time_optimizer" = "xyes" ; then + compiler_flags="$compiler_flags -flto" + LDFLAGS="$LDFLAGS -flto" + fi +} # # Linux Section # @@ -1284,20 +1389,22 @@ set_linux_configs() fi if test "x$compiler" = "xgcc" ; then set_cc_and_cxx_for_gcc - if test "x$m64" = "xyes" ; then - compiler_flags="$compiler_flags -m64" - else - compiler_flags="$compiler_flags -m32" - fi if test "x$fast_flag" != "xno" ; then if test "x$fast_flag" = "xyes" ; then compiler_flags="$compiler_flags -O3" + check_for_link_time_optimizer else compiler_flags="$compiler_flags -O2" fi else compiler_flags="$compiler_flags -O0" fi + check_64_bits + if test "x$m64" = "xyes" ; then + compiler_flags="$compiler_flags -m64" + else + compiler_flags="$compiler_flags -m32" + fi # configure will set proper compiler flags for gcc on Linux elif test "x$compiler" = "xicc" ; then compiler_flags="$compiler_flags -mp -restrict" @@ -1307,8 +1414,10 @@ set_linux_configs() fi if test "x$fast_flag" != "xno" ; then compiler_flags="$compiler_flags -O3 -unroll2 -ip" - if test "x$fast_flag" = "xyes" ; then + if test "x$fast_flag" = "xyes" && \ + test "x$with_link_time_optimizer" = "xyes" ; then compiler_flags="$compiler_flags -ipo" + LDFLAGS="$LDFLAGS -ipo" fi fi else @@ -1323,11 +1432,16 @@ set_linux_configs() set_solaris_configs() { # Use mtmalloc as malloc, see Tim Cook blog - base_configs="$base_configs --with-mysqld-libs=-lmtmalloc" +# For information on optimal compiler settings, see article at +# http://developers.sun.com/solaris/articles/mysql_perf_tune.html +# by Luojia Chen at Sun. base_configs="$base_configs --with-named-curses=-lcurses" case "`uname -a`" in - *5.8* | *5.9* | *5.10* | *5.11*) + *5.8* | *5.9* ) + ;; + *5.10* | *5.11*) + base_configs="$base_configs --with-mysqld-libs=-lmtmalloc" ;; *) usage "Only versions 8,9, 10 and 11 supported for Solaris" @@ -1361,6 +1475,7 @@ set_solaris_configs() if test "x$fast_flag" = "xyes" ; then LDFLAGS="$LDFLAGS -O3" compiler_flags="$compiler_flags -O3" + check_for_link_time_optimizer else if test "x$fast_flag" = "xgeneric" ; then LDFLAGS="$LDFLAGS -O2" @@ -1373,44 +1488,50 @@ set_solaris_configs() else #Using Forte compiler (SunStudio) set_cc_and_cxx_for_forte - base_cflags="$base_cflags -xstrconst" compiler_flags="$compiler_flags -mt" - LD_FLAGS="$LD_FLAGS -mt" + LDFLAGS="$LDFLAGS -mt" compiler_flags="$compiler_flags -fsimple=1" compiler_flags="$compiler_flags -ftrap=%none" compiler_flags="$compiler_flags -xbuiltin=%all" compiler_flags="$compiler_flags -xlibmil" compiler_flags="$compiler_flags -xlibmopt" - base_cxxflags="$base_cxxflags -noex" if test "x$fast_flag" = "xyes" ; then compiler_flags="$compiler_flags -xtarget=native" - compiler_flags="$compiler_flags -xipo" compiler_flags="$compiler_flags -xunroll=3" - LD_FLAGS="$LD_FLAGS -xipo" + if test "x$with_link_time_optimizer" = "xyes" ; then + compiler_flags="$compiler_flags -xipo" + LDFLAGS="$LDFLAGS -xipo" + fi else compiler_flags="$compiler_flags -xtarget=generic" fi if test "x$cpu_base_type" = "xx86" ; then compiler_flags="$compiler_flags -nofstore" + base_cxx_flags="$base_cxx_flags -features=no%except" if test "x$fast_flag" = "xyes" ; then compiler_flags="$compiler_flags -xregs=frameptr" compiler_flags="$compiler_flags -xO4" - elif test "x$fast_flag" = "xgeneric" ; then - compiler_flags="$compiler_flags -xO2" else - compiler_flags="$compiler_flags -xO0" + compiler_flags="$compiler_flags -xregs=no%frameptr" + if test "x$fast_flag" = "xgeneric" ; then + compiler_flags="$compiler_flags -xO2" + else + compiler_flags="$compiler_flags -xO0" + fi fi else #Using SPARC cpu with SunStudio (Forte) compiler ASFLAGS="$ASFLAGS -xarch=sparc" LDFLAGS="$LDFLAGS -xarch=sparc" + base_cxxflags="$base_cxxflags -noex" + base_cflags="$base_cflags -xstrconst" compiler_flags="$compiler_flags -xarch=sparc" if test "x$fast_flag" = "xyes" ; then compiler_flags="$compiler_flags -xbinopt=prepare" LDFLAGS="$LDFLAGS -xbinopt=prepare" compiler_flags="$compiler_flags -xO4" elif test "x$fast_flag" = "xgeneric" ; then - compiler_flags="$compiler_flags -xO2" + compiler_flags="$compiler_flags -xO3" else compiler_flags="$compiler_flags -xO0" fi @@ -1432,7 +1553,7 @@ set_macosx_configs() # optimisations also when not in fast mode. # base_cxxflags="$base_cxxflags -felide-constructors" - base_cxxflags="$base_cxxflags -fno-common" + compiler_flags="$compiler_flags -fno-common" if test "x$m64" = "xyes" ; then compiler_flags="$compiler_flags -m64" compiler_flags="$compiler_flags -arch x86_64" @@ -1526,7 +1647,7 @@ fi cpu_type= package= prefix="/usr/local/mysql" -parallelism="4" +parallelism="8" fast_flag="generic" compiler="gcc" gpl="yes" @@ -1562,6 +1683,10 @@ engine_configs= ASFLAGS= LDFLAGS= use_tcmalloc= +without_comment="yes" +with_fast_mutexes= +with_link_time_optimizer= +gcc_version="0" set_defaults_based_on_environment @@ -1656,7 +1781,7 @@ elif test "x$os" = "xbsd" ; then else die "Operating system not supported by this script" fi - +set_ssl # # Final step before setting up commands is to set up proper make and # proper libtoolize versions, and to determine whether to use ccache. diff --git a/BUILD/check-cpu b/BUILD/check-cpu index 585043de67c..070e7de0125 100755 --- a/BUILD/check-cpu +++ b/BUILD/check-cpu @@ -4,6 +4,7 @@ # best compiler optimization flags for gcc # Will return result in: # cpu_arg : Type of CPU +# low_cpu_arg : Type of CPU used up until GCC v3.3 # check_cpu_args : Arguments for GCC compiler settings # @@ -33,7 +34,7 @@ check_compiler_cpu_flags () { case `gcc -dumpmachine` in i?86-* | x86_64-*) if test "$cc_comp" -lt 304 ; then - check_cpu_cflags="-mcpu=${cpu_arg}" + check_cpu_cflags="-mcpu=${low_cpu_arg}" elif test "$cc_comp" -ge 402 ; then check_cpu_cflags="-mtune=native" else @@ -141,9 +142,10 @@ check_cpu () { # detect CPU shortname as used by gcc options # this list is not complete, feel free to add further entries cpu_arg="" - case "$cpu_family--$model_name--$spu_arch" in + low_cpu_arg="" + case "$cpu_vendor--$cpu_family--$model_name--$spu_arch" in # DEC Alpha - Alpha*EV6*) + *Alpha*EV6*) cpu_arg="ev6"; ;; #Core 2 Duo @@ -172,6 +174,13 @@ check_cpu () { *Pentium*4*Mobile*) cpu_arg="pentium4m" ;; + *Pentium\(R\)*\ M*) + cpu_arg="pentium-m" + low_cpu_arg="pentium3" + ;; + *Pentium\(R\)*\ D*) + cpu_arg="prescott" + ;; *Pentium*4*) cpu_arg="pentium4" ;; @@ -196,6 +205,12 @@ check_cpu () { *Celeron*) cpu_arg="pentium2" ;; + *Atom*) + cpu_arg="prescott" + ;; + *GenuineIntel*) + cpu_arg="pentium" + ;; *Turion*) cpu_arg="athlon64" ;; @@ -205,9 +220,30 @@ check_cpu () { *Athlon*) cpu_arg="athlon" ;; + *AMD-K7*) + cpu_arg="athlon" + ;; + *Athlon*XP\ *) + cpu_arg="athlon-xp" + ;; + *AMD*Sempron\(tm\)*) + cpu_arg="athlon-mp" + ;; + *AMD*Athlon\(tm\)\ 64*) + cpu_arg="k8" + ;; *Opteron*) cpu_arg="opteron" ;; + *Phenom*) + cpu_arg="k8" + ;; + *AuthenticAMD*) + cpu_arg="k6" + ;; + *VIA\ *) + cpu_arg="i686" + ;; # MacOSX / Intel *i386*i486*) cpu_arg="pentium-m" @@ -239,6 +275,10 @@ check_cpu () { ;; esac + if test "x$low_cpu_arg" = "x" ; then + low_cpu_arg="$cpu_arg" + fi + if test -z "$cpu_arg" ; then if test "$CPUINFO" != " " ; then # fallback to uname if necessary