summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-09-24 22:42:57 (GMT)
committerBen Gamari <ben@smart-cactus.org>2020-01-06 16:14:00 (GMT)
commitadb04fa0a9f1824600b026487951db4d325f242e (patch)
tree5d7d6db76200b9637dc763336b32bfbbb38ca711
parentb84c09d533faf576c406ce9f7163efecf3037787 (diff)
downloadghc-wip/T15742.zip
ghc-wip/T15742.tar.gz
ghc-wip/T15742.tar.bz2
configure: Only check GCC version if CC is GCCwip/T15742
Also refactor FP_GCC_EXTRA_FLAGS in a few ways: * We no longer support compilers which lack support for -fno-builtin and -fwrapv so remove the condition on GccVersion * These flags are only necessary when using the via-C backend so make them conditional on Unregisterised. Fixes #15742.
-rw-r--r--aclocal.m443
1 files changed, 24 insertions, 19 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index fd096b2..ed6e8a7 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1318,19 +1318,25 @@ AC_DEFUN([FP_PROG_AR_NEEDS_RANLIB],[
# (unsubstituted) output variable GccVersion.
AC_DEFUN([FP_GCC_VERSION], [
AC_REQUIRE([AC_PROG_CC])
- if test -z "$CC"
- then
- AC_MSG_ERROR([gcc is required])
+ if test -z "$CC"; then
+ AC_MSG_ERROR([C compiler is required])
+ fi
+
+ if $CC --version | grep --quiet gcc; then
+ AC_CACHE_CHECK([version of gcc], [fp_cv_gcc_version],
+ [
+ # Be sure only to look at the first occurrence of the "version " string;
+ # Some Apple compilers emit multiple messages containing this string.
+ AC_MSG_CHECKING([version of gcc])
+ fp_cv_gcc_version="`$CC -v 2>&1 | sed -n -e '1,/version /s/.*version [[^0-9]]*\([[0-9.]]*\).*/\1/p'`"
+ AC_MSG_RESULT([$fp_cv_gcc_version])
+ FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [4.6],
+ [AC_MSG_ERROR([Need at least gcc version 4.6 (4.7+ recommended)])])
+ ])
+ AC_SUBST([GccVersion], [$fp_cv_gcc_version])
+ else
+ AC_MSG_NOTICE([\$CC is not gcc; assuming it's a reasonably new C compiler])
fi
- AC_CACHE_CHECK([version of gcc], [fp_cv_gcc_version],
- [
- # Be sure only to look at the first occurrence of the "version " string;
- # Some Apple compilers emit multiple messages containing this string.
- fp_cv_gcc_version="`$CC -v 2>&1 | sed -n -e '1,/version /s/.*version [[^0-9]]*\([[0-9.]]*\).*/\1/p'`"
- FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [4.6],
- [AC_MSG_ERROR([Need at least gcc version 4.6 (4.7+ recommended)])])
- ])
- GccVersion="$fp_cv_gcc_version"
])# FP_GCC_VERSION
dnl Check to see if the C compiler is clang or llvm-gcc
@@ -1555,13 +1561,12 @@ AC_SUBST([GhcPkgCmd])
AC_DEFUN([FP_GCC_EXTRA_FLAGS],
[AC_REQUIRE([FP_GCC_VERSION])
AC_CACHE_CHECK([for extra options to pass gcc when compiling via C], [fp_cv_gcc_extra_opts],
-[fp_cv_gcc_extra_opts=
- FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-ge], [3.4],
- [fp_cv_gcc_extra_opts="$fp_cv_gcc_extra_opts -fwrapv"],
- [])
- FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-ge], [4.0],
- [fp_cv_gcc_extra_opts="$fp_cv_gcc_extra_opts -fno-builtin"],
- [])
+[
+ if test "$Unregisterised" = "YES"; then
+ # These used to be conditioned on gcc version but we no longer support
+ # GCC versions which lack support for these flags
+ fp_cv_gcc_extra_opts="-fwrapv -fno-builtin"
+ fi
])
AC_SUBST([GccExtraViaCOpts],$fp_cv_gcc_extra_opts)
])