1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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
|