annotate src/fftw-3.3.5/m4/ax_cc_maxopt.m4 @ 158:fa7c54aeb697

Rebuild with --disable-stack-protector for mingw32
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 25 Jan 2019 14:31:07 +0000
parents 7867fa7e1b6b
children
rev   line source
cannam@127 1 dnl @synopsis AX_CC_MAXOPT
cannam@127 2 dnl @summary turn on optimization flags for the C compiler
cannam@127 3 dnl @category C
cannam@127 4 dnl
cannam@127 5 dnl Try to turn on "good" C optimization flags for various compilers
cannam@127 6 dnl and architectures, for some definition of "good". (In our case,
cannam@127 7 dnl good for FFTW and hopefully for other scientific codes. Modify
cannam@127 8 dnl as needed.)
cannam@127 9 dnl
cannam@127 10 dnl The user can override the flags by setting the CFLAGS environment
cannam@127 11 dnl variable.
cannam@127 12 dnl
cannam@127 13 dnl Note also that the flags assume that ANSI C aliasing rules are
cannam@127 14 dnl followed by the code (e.g. for gcc's -fstrict-aliasing), and that
cannam@127 15 dnl floating-point computations can be re-ordered as needed.
cannam@127 16 dnl
cannam@127 17 dnl Requires macros: AX_CHECK_COMPILER_FLAGS, AX_COMPILER_VENDOR,
cannam@127 18 dnl
cannam@127 19 dnl @version 2011-06-22
cannam@127 20 dnl @license GPLWithACException
cannam@127 21 dnl @author Steven G. Johnson <stevenj@alum.mit.edu> and Matteo Frigo.
cannam@127 22 AC_DEFUN([AX_CC_MAXOPT],
cannam@127 23 [
cannam@127 24 AC_REQUIRE([AC_PROG_CC])
cannam@127 25 AC_REQUIRE([AX_COMPILER_VENDOR])
cannam@127 26 AC_REQUIRE([AC_CANONICAL_HOST])
cannam@127 27
cannam@127 28 # Try to determine "good" native compiler flags if none specified via CFLAGS
cannam@127 29 if test "$ac_test_CFLAGS" != "set"; then
cannam@127 30 CFLAGS=""
cannam@127 31 case $ax_cv_c_compiler_vendor in
cannam@127 32 dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host"
cannam@127 33 ;;
cannam@127 34
cannam@127 35 sun) CFLAGS="-native -fast -xO5 -dalign"
cannam@127 36 ;;
cannam@127 37
cannam@127 38 hp) CFLAGS="+Oall +Optrs_ansi +DSnative"
cannam@127 39 ;;
cannam@127 40
cannam@127 41 ibm) xlc_opt="-qarch=auto -qtune=auto"
cannam@127 42 AX_CHECK_COMPILER_FLAGS($xlc_opt,
cannam@127 43 CFLAGS="-O3 -qalias=ansi -w $xlc_opt",
cannam@127 44 [CFLAGS="-O3 -qalias=ansi -w"])
cannam@127 45 ;;
cannam@127 46
cannam@127 47 intel) CFLAGS="-O3"
cannam@127 48 # Intel seems to have changed the spelling of this flag recently
cannam@127 49 icc_ansi_alias="unknown"
cannam@127 50 for flag in -ansi-alias -ansi_alias; do
cannam@127 51 AX_CHECK_COMPILER_FLAGS($flag, [icc_ansi_alias=$flag; break])
cannam@127 52 done
cannam@127 53 if test "x$icc_ansi_alias" != xunknown; then
cannam@127 54 CFLAGS="$CFLAGS $icc_ansi_alias"
cannam@127 55 fi
cannam@127 56 AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double")
cannam@127 57 # We used to check for architecture flags here, e.g. -xHost etc.,
cannam@127 58 # but these flags are problematic. On icc-12.0.0, "-mavx -xHost"
cannam@127 59 # overrides -mavx with -xHost, generating SSE2 code instead of AVX
cannam@127 60 # code. ICC does not seem to support -mtune=host or equivalent
cannam@127 61 # non-ABI changing flag.
cannam@127 62 ;;
cannam@127 63
cannam@127 64 clang)
cannam@127 65 CFLAGS="-O3 -fomit-frame-pointer"
cannam@127 66 AX_CHECK_COMPILER_FLAGS(-mtune=native, CFLAGS="$CFLAGS -mtune=native")
cannam@127 67 AX_CHECK_COMPILER_FLAGS(-fstrict-aliasing,CFLAGS="$CFLAGS -fstrict-aliasing")
cannam@127 68 AX_CHECK_COMPILER_FLAGS(-ffast-math, CFLAGS="$CFLAGS -ffast-math")
cannam@127 69 ;;
cannam@127 70
cannam@127 71 gnu)
cannam@127 72 # Default optimization flags for gcc on all systems.
cannam@127 73 # Somehow -O3 does not imply -fomit-frame-pointer on ia32
cannam@127 74 CFLAGS="-O3 -fomit-frame-pointer"
cannam@127 75
cannam@127 76 # tune for the host by default
cannam@127 77 AX_CHECK_COMPILER_FLAGS(-mtune=native, CFLAGS="$CFLAGS -mtune=native")
cannam@127 78
cannam@127 79 # -malign-double for x86 systems
cannam@127 80 AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double")
cannam@127 81
cannam@127 82 # -fstrict-aliasing for gcc-2.95+
cannam@127 83 AX_CHECK_COMPILER_FLAGS(-fstrict-aliasing,
cannam@127 84 CFLAGS="$CFLAGS -fstrict-aliasing")
cannam@127 85
cannam@127 86 # -fno-schedule-insns is pretty much required on all risc
cannam@127 87 # processors.
cannam@127 88 #
cannam@127 89 # gcc performs one pass of instruction scheduling, then a pass of
cannam@127 90 # register allocation, then another pass of instruction
cannam@127 91 # scheduling. The first pass reorders instructions in a way that
cannam@127 92 # is pretty much the worst possible for the purposes of register
cannam@127 93 # allocation. We disable the first pass.
cannam@127 94 AX_CHECK_COMPILER_FLAGS(-fno-schedule-insns, CFLAGS="$CFLAGS -fno-schedule-insns")
cannam@127 95
cannam@127 96 # note that we enable "unsafe" fp optimization with other compilers, too
cannam@127 97 AX_CHECK_COMPILER_FLAGS(-ffast-math, CFLAGS="$CFLAGS -ffast-math")
cannam@127 98
cannam@127 99 # flags to enable power ISA 2.07 instructions with gcc (always true with vsx)
cannam@127 100 if test "$have_vsx" = "yes"; then
cannam@127 101 AX_CHECK_COMPILER_FLAGS(-mcpu=power8, CFLAGS="$CFLAGS -mcpu=power8")
cannam@127 102 AX_CHECK_COMPILER_FLAGS(-mpower8-fusion, CFLAGS="$CFLAGS -mpower8-fusion")
cannam@127 103 AX_CHECK_COMPILER_FLAGS(-mpower8-vector, CFLAGS="$CFLAGS -mpower8-vector")
cannam@127 104 AX_CHECK_COMPILER_FLAGS(-mdirect-move, CFLAGS="$CFLAGS -mdirect-move")
cannam@127 105 fi
cannam@127 106 ;;
cannam@127 107 esac
cannam@127 108
cannam@127 109 if test -z "$CFLAGS"; then
cannam@127 110 echo ""
cannam@127 111 echo "********************************************************"
cannam@127 112 echo "* WARNING: Don't know the best CFLAGS for this system *"
cannam@127 113 echo "* Use ./configure CFLAGS=... to specify your own flags *"
cannam@127 114 echo "* (otherwise, a default of CFLAGS=-O3 will be used) *"
cannam@127 115 echo "********************************************************"
cannam@127 116 echo ""
cannam@127 117 CFLAGS="-O3"
cannam@127 118 fi
cannam@127 119
cannam@127 120 AX_CHECK_COMPILER_FLAGS($CFLAGS, [], [
cannam@127 121 echo ""
cannam@127 122 echo "********************************************************"
cannam@127 123 echo "* WARNING: The guessed CFLAGS don't seem to work with *"
cannam@127 124 echo "* your compiler. *"
cannam@127 125 echo "* Use ./configure CFLAGS=... to specify your own flags *"
cannam@127 126 echo "********************************************************"
cannam@127 127 echo ""
cannam@127 128 CFLAGS=""
cannam@127 129 ])
cannam@127 130
cannam@127 131 fi
cannam@127 132 ])