summaryrefslogtreecommitdiff
path: root/skip/ghc/0005-Set-min-LLVM-version-to-9-and-make-version-checking-.patch
diff options
context:
space:
mode:
Diffstat (limited to 'skip/ghc/0005-Set-min-LLVM-version-to-9-and-make-version-checking-.patch')
-rw-r--r--skip/ghc/0005-Set-min-LLVM-version-to-9-and-make-version-checking-.patch143
1 files changed, 143 insertions, 0 deletions
diff --git a/skip/ghc/0005-Set-min-LLVM-version-to-9-and-make-version-checking-.patch b/skip/ghc/0005-Set-min-LLVM-version-to-9-and-make-version-checking-.patch
new file mode 100644
index 0000000..f2a00c3
--- /dev/null
+++ b/skip/ghc/0005-Set-min-LLVM-version-to-9-and-make-version-checking-.patch
@@ -0,0 +1,143 @@
+From 5279eac5ce1a82d661dfaa911e892a591c7f95c0 Mon Sep 17 00:00:00 2001
+From: Zubin Duggal <zubin.duggal@gmail.com>
+Date: Thu, 17 Jun 2021 16:25:46 +0530
+Subject: [PATCH 5/9] Set min LLVM version to 9 and make version checking use a
+ non-inclusive upper bound.
+
+We use a non-inclusive upper bound so that setting the upper bound to 13 for
+example means that all 12.x versions are accepted.
+---
+ aclocal.m4 | 2 +-
+ compiler/GHC/CmmToLlvm.hs | 6 +++---
+ compiler/GHC/CmmToLlvm/Base.hs | 16 +++++++++-------
+ compiler/GHC/SysTools/Tasks.hs | 9 +++++----
+ configure.ac | 4 ++--
+ 5 files changed, 20 insertions(+), 17 deletions(-)
+
+diff --git a/aclocal.m4 b/aclocal.m4
+index a296dbc243..0219ea3a61 100644
+--- a/aclocal.m4
++++ b/aclocal.m4
+@@ -2251,7 +2251,7 @@ AC_DEFUN([FIND_LLVM_PROG],[
+ [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],
++ [AX_COMPARE_VERSION([$PROG_VERSION], [ge], [$4],
+ [AC_MSG_RESULT(no)
+ $1=""
+ AC_MSG_NOTICE([We only support llvm $3 to $4 (found $PROG_VERSION).])],
+diff --git a/compiler/GHC/CmmToLlvm.hs b/compiler/GHC/CmmToLlvm.hs
+index 0d2ecb16be..8bc7dc65b4 100644
+--- a/compiler/GHC/CmmToLlvm.hs
++++ b/compiler/GHC/CmmToLlvm.hs
+@@ -64,8 +64,8 @@ llvmCodeGen dflags h cmm_stream
+ let doWarn = wopt Opt_WarnUnsupportedLlvmVersion dflags
+ when (not (llvmVersionSupported ver) && doWarn) $ putMsg dflags $
+ "You are using an unsupported version of LLVM!" $$
+- "Currently only" <+> text (llvmVersionStr supportedLlvmVersionMin) <+>
+- "to" <+> text (llvmVersionStr supportedLlvmVersionMax) <+> "is supported." <+>
++ "Currently only" <+> text (llvmVersionStr supportedLlvmVersionLowerBound) <+>
++ "to" <+> text (llvmVersionStr supportedLlvmVersionUpperBound) <+> "is supported." <+>
+ "System LLVM version: " <> text (llvmVersionStr ver) $$
+ "We will try though..."
+ let isS390X = platformArch (targetPlatform dflags) == ArchS390X
+@@ -78,7 +78,7 @@ llvmCodeGen dflags h cmm_stream
+ -- currently don't use the LLVM version to guide code generation
+ -- so this is okay.
+ let llvm_ver :: LlvmVersion
+- llvm_ver = fromMaybe supportedLlvmVersionMin mb_ver
++ llvm_ver = fromMaybe supportedLlvmVersionLowerBound mb_ver
+
+ -- run code generation
+ a <- runLlvm dflags llvm_ver bufh $
+diff --git a/compiler/GHC/CmmToLlvm/Base.hs b/compiler/GHC/CmmToLlvm/Base.hs
+index a47bfd3baa..86f9944f59 100644
+--- a/compiler/GHC/CmmToLlvm/Base.hs
++++ b/compiler/GHC/CmmToLlvm/Base.hs
+@@ -15,7 +15,7 @@ module GHC.CmmToLlvm.Base (
+ LiveGlobalRegs,
+ LlvmUnresData, LlvmData, UnresLabel, UnresStatic,
+
+- LlvmVersion, supportedLlvmVersionMin, supportedLlvmVersionMax,
++ LlvmVersion, supportedLlvmVersionLowerBound, supportedLlvmVersionUpperBound,
+ llvmVersionSupported, parseLlvmVersion,
+ llvmVersionStr, llvmVersionList,
+
+@@ -265,7 +265,6 @@ llvmPtrBits platform = widthInBits $ typeWidth $ gcWord platform
+ -- * Llvm Version
+ --
+
+--- Newtype to avoid using the Eq instance!
+ newtype LlvmVersion = LlvmVersion { llvmVersionNE :: NE.NonEmpty Int }
+ deriving (Eq, Ord)
+
+@@ -283,14 +282,17 @@ parseLlvmVersion =
+ where
+ (ver_str, rest) = span isDigit s
+
+--- | The LLVM Version that is currently supported.
+-supportedLlvmVersionMin, supportedLlvmVersionMax :: LlvmVersion
+-supportedLlvmVersionMin = LlvmVersion (sUPPORTED_LLVM_VERSION_MIN NE.:| [])
+-supportedLlvmVersionMax = LlvmVersion (sUPPORTED_LLVM_VERSION_MAX NE.:| [])
++-- | The (inclusive) lower bound on the LLVM Version that is currently supported.
++supportedLlvmVersionLowerBound :: LlvmVersion
++supportedLlvmVersionLowerBound = LlvmVersion (sUPPORTED_LLVM_VERSION_MIN NE.:| [])
++
++-- | The (not-inclusive) upper bound bound on the LLVM Version that is currently supported.
++supportedLlvmVersionUpperBound :: LlvmVersion
++supportedLlvmVersionUpperBound = LlvmVersion (sUPPORTED_LLVM_VERSION_MAX NE.:| [])
+
+ llvmVersionSupported :: LlvmVersion -> Bool
+ llvmVersionSupported v =
+- v > supportedLlvmVersionMin && v <= supportedLlvmVersionMax
++ v >= supportedLlvmVersionLowerBound && v < supportedLlvmVersionUpperBound
+
+ llvmVersionStr :: LlvmVersion -> String
+ llvmVersionStr = intercalate "." . map show . llvmVersionList
+diff --git a/compiler/GHC/SysTools/Tasks.hs b/compiler/GHC/SysTools/Tasks.hs
+index 1ab3a0a425..4d5158e940 100644
+--- a/compiler/GHC/SysTools/Tasks.hs
++++ b/compiler/GHC/SysTools/Tasks.hs
+@@ -11,7 +11,7 @@ module GHC.SysTools.Tasks where
+
+ import GHC.Utils.Exception as Exception
+ import GHC.Utils.Error
+-import GHC.CmmToLlvm.Base (LlvmVersion, llvmVersionStr, supportedLlvmVersionMin, supportedLlvmVersionMax, llvmVersionStr, parseLlvmVersion)
++import GHC.CmmToLlvm.Base (LlvmVersion, llvmVersionStr, supportedLlvmVersionLowerBound, supportedLlvmVersionUpperBound, llvmVersionStr, parseLlvmVersion)
+ import GHC.Driver.Types
+ import GHC.Driver.Session
+ import GHC.Utils.Outputable
+@@ -235,10 +235,11 @@ figureLlvmVersion dflags = traceToolCommand dflags "llc" $ do
+ errorMsg dflags $ vcat
+ [ text "Warning:", nest 9 $
+ text "Couldn't figure out LLVM version!" $$
+- text ("Make sure you have installed LLVM between "
+- ++ llvmVersionStr supportedLlvmVersionMin
++ text ("Make sure you have installed LLVM between ["
++ ++ llvmVersionStr supportedLlvmVersionLowerBound
+ ++ " and "
+- ++ llvmVersionStr supportedLlvmVersionMax) ]
++ ++ llvmVersionStr supportedLlvmVersionUpperBound
++ ++ ")") ]
+ return Nothing)
+
+
+diff --git a/configure.ac b/configure.ac
+index cf93f10938..e0423add87 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -716,8 +716,8 @@ AC_SUBST(InstallNameToolCmd)
+ # 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.
+-LlvmMinVersion=10
+-LlvmMaxVersion=12 # inclusive
++LlvmMinVersion=9 # inclusive
++LlvmMaxVersion=13 # not inclusive
+ AC_SUBST([LlvmMinVersion])
+ AC_SUBST([LlvmMaxVersion])
+ sUPPORTED_LLVM_VERSION_MIN=$(echo \($LlvmMinVersion\) | sed 's/\./,/')
+--
+2.33.0
+