summaryrefslogtreecommitdiff
path: root/aclocal.m4
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-03-09 11:37:18 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-03-17 19:05:50 -0400
commit84927818ee68c6826327abc26d4647fb56053fb7 (patch)
tree108ab49003f77c80a1b2eeb755df44ecad416f22 /aclocal.m4
parent540fa6b2cff3802877ff56a47ab3611e33a9ac86 (diff)
downloadhaskell-84927818ee68c6826327abc26d4647fb56053fb7.tar.gz
llvmGen: Accept range of LLVM versions
Previously we would support only one LLVM major version. Here we generalize this to accept a range, taking this range to be LLVM 10 to 11, as 11 is necessary for Apple M1 support. We also accept 12, as that is what apple ships with BigSur on the M1.
Diffstat (limited to 'aclocal.m4')
-rw-r--r--aclocal.m435
1 files changed, 22 insertions, 13 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index be132387f2..d7b6c58f44 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -3,6 +3,8 @@
# To be a good autoconf citizen, names of local macros have prefixed with FP_ to
# ensure we don't clash with any pre-supplied autoconf ones.
+m4_include([m4/ax_compare_version.m4])
+
# FPTOOLS_WRITE_FILE
# ------------------
# Write $2 to the file named $1.
@@ -2249,22 +2251,29 @@ AC_DEFUN([XCODE_VERSION],[
#
# $1 = the variable to set
# $2 = the command to look for
-# $3 = the version of the command to look for
+# $3 = the lower bound version of the command to look for
+# $4 = the upper bound version of the command to look for.
#
AC_DEFUN([FIND_LLVM_PROG],[
# Test for program with and without version name.
- AC_CHECK_TOOLS([$1], [$2-$3 $2-$3.0 $2], [:])
- if test "$$1" != ":"; then
- AC_MSG_CHECKING([$$1 is version $3])
- if test `$$1 --version | grep -c "version $3"` -gt 0 ; then
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- $1=""
- fi
- else
- $1=""
- fi
+ PROG_VERSION_CANDIDATES=$(for llvmVersion in `seq $4 -1 $3`; do echo "$2-$llvmVersion $2-$llvmVersion.0"; done)
+ AC_CHECK_TOOLS([$1], [$PROG_VERSION_CANDIDATES $2], [])
+ AS_IF([test x"$$1" != x],[
+ PROG_VERSION=`$$1 --version | awk '/.*version [[0-9\.]]+/{for(i=1;i<=NF;i++){ if(\$i ~ /^[[0-9\.]]+$/){print \$i}}}'`
+ AS_IF([test x"$PROG_VERSION" == x],
+ [AC_MSG_RESULT(no)
+ $1=""
+ AC_MSG_NOTICE([We only support llvm $3 to $4 (no version found).])],
+ [AC_MSG_CHECKING([$$1 version ($PROG_VERSION) is between $3 and $4])
+ AX_COMPARE_VERSION([$PROG_VERSION], [lt], [$3],
+ [AC_MSG_RESULT(no)
+ $1=""
+ AC_MSG_NOTICE([We only support llvm $3 to $4 (found $PROG_VERSION).])],
+ [AX_COMPARE_VERSION([$PROG_VERSION], [gt], [$4],
+ [AC_MSG_RESULT(no)
+ $1=""
+ AC_MSG_NOTICE([We only support llvm $3 to $4 (found $PROG_VERSION).])],
+ [AC_MSG_RESULT(yes)])])])])
])
# CHECK_LD_COPY_BUG()