summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik de Castro Lopo <erikd@mega-nerd.com>2015-03-20 12:16:23 +1100
committerAustin Seipp <austin@well-typed.com>2015-04-14 07:54:07 -0500
commit07da52ce2db15da1d495baa213f3bdca158b6843 (patch)
tree5dd22eff99cd7d9c9372ec0e1cf139a0f527d705
parent335c02562af599434ff42e5f3dac160a76229999 (diff)
downloadhaskell-07da52ce2db15da1d495baa213f3bdca158b6843.tar.gz
Do version specific detection of LLVM tools (#10170).
The LLVM developers seem to make breaking changes in the LLVM IR language between major releases. As a consumer of the LLVM tools GHC now needs to be locked more tightly to a single version of the LLVM tools. GHC HEAD currently only supports LLVM version 3.6. This commit changes the configure script to look for `llc-3.6` and `opt-3.6` before looking for `llc` and `opt`. If the former are not found, but the later are, check that they actually are version 3.6. At the same time, when detecting known problems with the LLVM tools (ie #9439) test for it using the versions of the LLVM tools retrieved from the bootstrap compiler's settings file. Test Plan: Manual testing. Reviewers: thomie, rwbarton, nomeata, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D745 GHC Trac Issues: #10170 (cherry picked from commit 42448e3757f25735a0a5b5e2b7ee456b5e8b0039)
-rw-r--r--aclocal.m455
-rw-r--r--configure.ac27
2 files changed, 52 insertions, 30 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index 049a8462c4..671f5451f6 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -2096,38 +2096,43 @@ AC_DEFUN([XCODE_VERSION],[
# $1 = the variable to set
# $2 = the with option name
# $3 = the command to look for
+# $4 = the version of the command to look for
#
AC_DEFUN([FIND_LLVM_PROG],[
- FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL_NOTARGET([$1], [$2], [$3])
+ # Test for program with version name.
+ FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL_NOTARGET([$1], [$2], [$3-$4])
if test "$$1" = ""; then
- echo -n "checking for $3-x.x... "
- save_IFS=$IFS
- IFS=":;"
- if test "$windows" = YES; then
- PERM=
- MODE=
+ # Test for program without version name.
+ FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL_NOTARGET([$1], [$2], [$3])
+ AC_MSG_CHECKING([$$1 is version $4])
+ if test `$$1 --version | grep -c "version $4"` -gt 0 ; then
+ AC_MSG_RESULT(yes)
else
- # Search for executables.
- PERM="-perm"
- MODE="/+x"
- fi
- for p in ${PATH}; do
- if test -d "${p}"; then
- $1=`${FindCmd} "${p}" -maxdepth 1 \( -type f -o -type l \) ${PERM} ${MODE} -regex ".*/$3-[[0-9]]\.[[0-9]]" | ${SortCmd} -n | tail -1`
- if test -n "$$1"; then
- break
- fi
- fi
- done
- IFS=$save_IFS
- if test -n "$$1"; then
- echo "$$1"
- else
- echo "no"
- fi
+ AC_MSG_RESULT(no)
+ $1=""
+ fi
fi
])
+# FIND_GHC_BOOTSTRAP_PROG()
+# --------------------------------
+# Parse the bootstrap GHC's compier settings file for the location of things
+# like the `llc` and `opt` commands.
+#
+# $1 = the variable to set
+# $2 = The bootstrap compiler.
+# $3 = The string to grep for to find the correct line.
+#
+AC_DEFUN([FIND_GHC_BOOTSTRAP_PROG],[
+ BootstrapTmpCmd=`grep $3 $($2 --print-libdir)/settings 2>/dev/null | sed 's/.*", "//;s/".*//'`
+ if test -n "$BootstrapTmpCmd" && test `basename $BootstrapTmpCmd` = $BootstrapTmpCmd ; then
+ AC_PATH_PROG([$1], [$BootstrapTmpCmd], "")
+ else
+ $1=$BootstrapTmpCmd
+ fi
+])
+
+
# FIND_GCC()
# --------------------------------
# Finds where gcc is
diff --git a/configure.ac b/configure.ac
index b25e3ff29b..c231434401 100644
--- a/configure.ac
+++ b/configure.ac
@@ -478,15 +478,21 @@ cygwin32|mingw32)
;;
esac
+# Here is where we re-target which specific version of the LLVM
+# tools we are looking for. In the past, GHC supported a number of
+# versions of LLVM simultaneously, but that stopped working around
+# 3.5/3.6 release of LLVM.
+llvm_version=3.6
+
dnl ** Which LLVM llc to use?
dnl --------------------------------------------------------------
-FIND_LLVM_PROG([LLC], [llc], [llc])
+FIND_LLVM_PROG([LLC], [llc], [llc], [$llvm_version])
LlcCmd="$LLC"
AC_SUBST([LlcCmd])
dnl ** Which LLVM opt to use?
dnl --------------------------------------------------------------
-FIND_LLVM_PROG([OPT], [opt], [opt])
+FIND_LLVM_PROG([OPT], [opt], [opt], [$llvm_version])
OptCmd="$OPT"
AC_SUBST([OptCmd])
@@ -508,13 +514,24 @@ dnl whether -fllvm is the stage 0 compiler's default. If so we
dnl fail. If not, we check whether -fllvm is affected explicitly and
dnl if so set a flag. The build system will later check this flag
dnl after the desired build flags are known.
-if test -n "$LlcCmd" && test -n "$OptCmd"
+
+dnl This problem is further complicated by the fact that the llvm
+dnl version used by the bootstrap compiler may be different from the
+dnl version we arre trying to compile GHC against. Therefore, we need
+dnl to find the boostrap compiler's `settings` file then check to see
+dnl if the `opt` and `llc` command strings are non-empty and if these
+dnl programs exist. Only if they exist to we test for bug #9439.
+
+FIND_GHC_BOOTSTRAP_PROG([BootstrapLlcCmd], [${WithGhc}], "LLVM llc command")
+FIND_GHC_BOOTSTRAP_PROG([BootstrapOptCmd], [${WithGhc}], "LLVM opt command")
+
+if test -n "$BootstrapLlcCmd" && test -n "$BootstrapOptCmd"
then
AC_MSG_CHECKING(whether bootstrap compiler is affected by bug 9439)
echo "main = putStrLn \"%function\"" > conftestghc.hs
# Check whether LLVM backend is default for this platform
- "${WithGhc}" -pgmlc="${LlcCmd}" -pgmlo="${OptCmd}" conftestghc.hs 2>&1 >/dev/null
+ "${WithGhc}" -pgmlc="${BootstrapLlcCmd}" -pgmlo="${BootstrapOptCmd}" conftestghc.hs 2>&1 >/dev/null
res=`./conftestghc`
if test "x$res" = "x%object"
then
@@ -531,7 +548,7 @@ then
# -fllvm is not the default, but set a flag so the Makefile can check
# -for it in the build flags later on
- "${WithGhc}" -fforce-recomp -pgmlc="${LlcCmd}" -pgmlo="${OptCmd}" -fllvm conftestghc.hs 2>&1 >/dev/null
+ "${WithGhc}" -fforce-recomp -pgmlc="${BootstrapLlcCmd}" -pgmlo="${BootstrapOptCmd}" -fllvm conftestghc.hs 2>&1 >/dev/null
if test $? = 0
then
res=`./conftestghc`