@@ -62,6 +62,29 @@ if test "$GCC" = yes; then
6262 fi
6363fi
6464
65+ dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
66+ dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
67+ dnl the version number of the clang in use.
68+ dnl Note that this does not work to get the version of clang 3.1 or 3.2.
69+ AC_MSG_CHECKING(for recent clang version)
70+ CLANG_VERSION_STRING=`"$CC" --version 2>/dev/null | sed -n -e 's/^.*clang.*\([[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\).*$/\1/p'`
71+ if test x"$CLANG_VERSION_STRING" != x"" ; then
72+ CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
73+ CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
74+ CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
75+ CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
76+ AC_MSG_RESULT($CLANG_VERSION)
77+ dnl If you find the same issue with versions earlier than 500.2.75,
78+ dnl change the constant 500002075 below appropriately. To get the
79+ dnl integer corresponding to a version number, refer to the
80+ dnl definition of CLANG_VERSION above.
81+ if test "$CLANG_VERSION" -ge 500002075 ; then
82+ CFLAGS=`echo "$CFLAGS" | sed -n -e 's/-fno-strength-reduce/ /p'`
83+ fi
84+ else
85+ AC_MSG_RESULT(no)
86+ fi
87+
6588dnl If configure thinks we are cross compiling, there might be something
6689dnl wrong with the CC or CFLAGS settings, give a useful warning message
6790if test "$cross_compiling" = yes; then
0 commit comments