summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-09-24 18:42:57 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-01-07 13:11:48 -0500
commit7aa4a0615629f36e520c11c7e40db7b1475b6402 (patch)
tree3c2e14dd1349d62081d6c4569f8c10d4dee0ff64
parent99a9f51bf8207c79241fc0b685fadeb222a61292 (diff)
downloadhaskell-7aa4a0615629f36e520c11c7e40db7b1475b6402.tar.gz
configure: Only check GCC version if CC is GCC
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 fd096b2bd9..ed6e8a7c0d 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)
])