[commit: ghc] ghc-7.10: configure: LLVM and LD detection improvements (#10329) (99e4e26)

git at git.haskell.org git at git.haskell.org
Sat Apr 25 06:16:41 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-7.10
Link       : http://ghc.haskell.org/trac/ghc/changeset/99e4e26a2672f7697cf1f76306c3dfb63125e035/ghc

>---------------------------------------------------------------

commit 99e4e26a2672f7697cf1f76306c3dfb63125e035
Author: Erik de Castro Lopo <erikd at mega-nerd.com>
Date:   Sat Apr 25 08:14:48 2015 +0200

    configure: LLVM and LD detection improvements (#10329)
    
    The ghc-7.10 branch *only* works with llvm-3.5.
    
    This commit is basically the ghc-7.10 branch version of
    485dba86d2 in the master branch.
    
    Signed-off-by: Erik de Castro Lopo <erikd at mega-nerd.com>
    
    Differential Revision: https://phabricator.haskell.org/D856


>---------------------------------------------------------------

99e4e26a2672f7697cf1f76306c3dfb63125e035
 aclocal.m4              | 50 +++++++++++++++++++++++++++++++++++--------------
 configure.ac            | 21 +++++----------------
 distrib/configure.ac.in | 23 +++++++++++++++++++++--
 3 files changed, 62 insertions(+), 32 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index 671f545..63e21e5 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -2099,21 +2099,43 @@ AC_DEFUN([XCODE_VERSION],[
 # $4 = the version of the command to look for
 #
 AC_DEFUN([FIND_LLVM_PROG],[
-	# Test for program with version name.
+    # Test for program with version name.
     FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL_NOTARGET([$1], [$2], [$3-$4])
     if test "$$1" = ""; then
-		# 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
+        # 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
-			AC_MSG_RESULT(no)
-			$1=""
-		fi
+            AC_MSG_RESULT(no)
+            $1=""
+        fi
     fi
 ])
 
+# FIND_LD
+# Find the version of `ld` to use. This is used in both in the top level
+# configure.ac and in distrib/configure.ac.in.
+#
+# $1 = the variable to set
+#
+AC_DEFUN([FIND_LD],[
+    FP_ARG_WITH_PATH_GNU_PROG([LD], [ld], [ld])
+    case $target in
+        arm*linux*)
+            # Arm requires use of the binutils ld.gold linker.
+            # This case should catch at least arm-unknown-linux-gnueabihf and
+            # arm-linux-androideabi.
+            FP_ARG_WITH_PATH_GNU_PROG([LD_GOLD], [ld.gold], [ld.gold])
+            $1="$LD_GOLD"
+            ;;
+        *)
+            $1="$LD"
+            ;;
+    esac
+])
+
 # FIND_GHC_BOOTSTRAP_PROG()
 # --------------------------------
 # Parse the bootstrap GHC's compier settings file for the location of things
@@ -2124,12 +2146,12 @@ AC_DEFUN([FIND_LLVM_PROG],[
 # $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
+    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
 ])
 
 
diff --git a/configure.ac b/configure.ac
index c231434..d99d1d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -432,19 +432,7 @@ FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs)
 
 dnl ** Which ld to use?
 dnl --------------------------------------------------------------
-FP_ARG_WITH_PATH_GNU_PROG([LD], [ld], [ld])
-case $target in
-arm*linux*)
-	# Arm requires use of the binutils ld.gold linker.
-	# This case should catch at least arm-unknown-linux-gnueabihf and
-	# arm-linux-androideabi.
-	FP_ARG_WITH_PATH_GNU_PROG([LD_GOLD], [ld.gold], [ld.gold])
-	LdCmd="$LD_GOLD"
-	;;
-*)
-	LdCmd="$LD"
-	;;
-esac
+FIND_LD([LdCmd])
 AC_SUBST([LdCmd])
 
 dnl ** Which nm to use?
@@ -482,17 +470,18 @@ esac
 # 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
+LlvmVersion=3.5
+AC_SUBST([LlvmVersion])
 
 dnl ** Which LLVM llc to use?
 dnl --------------------------------------------------------------
-FIND_LLVM_PROG([LLC], [llc], [llc], [$llvm_version])
+FIND_LLVM_PROG([LLC], [llc], [llc], [$LlvmVersion])
 LlcCmd="$LLC"
 AC_SUBST([LlcCmd])
 
 dnl ** Which LLVM opt to use?
 dnl --------------------------------------------------------------
-FIND_LLVM_PROG([OPT], [opt], [opt], [$llvm_version])
+FIND_LLVM_PROG([OPT], [opt], [opt], [$LlvmVersion])
 OptCmd="$OPT"
 AC_SUBST([OptCmd])
 
diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index 2ae0072..0fcd869 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -65,11 +65,30 @@ export CC
 
 # --with-hs-cpp/--with-hs-cpp-flags
 FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs)
+AC_SUBST([HaskellCPPCmd])
+AC_SUBST([HaskellCPPArgs])
+
+# 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.
+LlvmVersion=@LlvmVersion@
+
+dnl ** Which LLVM llc to use?
+dnl --------------------------------------------------------------
+FIND_LLVM_PROG([LLC], [llc], [llc], [$LlvmVersion])
+LlcCmd="$LLC"
+AC_SUBST([LlcCmd])
+
+dnl ** Which LLVM opt to use?
+dnl --------------------------------------------------------------
+FIND_LLVM_PROG([OPT], [opt], [opt], [$LlvmVersion])
+OptCmd="$OPT"
+AC_SUBST([OptCmd])
 
 dnl ** Which ld to use?
 dnl --------------------------------------------------------------
-FP_ARG_WITH_PATH_GNU_PROG([LD], [ld], [ld])
-LdCmd="$LD"
+FIND_LD([LdCmd])
 AC_SUBST([LdCmd])
 
 FP_GCC_VERSION



More information about the ghc-commits mailing list