summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-11-11 14:55:40 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-11-22 12:39:38 -0500
commit179d0becd2ddfa216f7b221df9fc520a352fdbe7 (patch)
tree9d45057d4c56f3a4af233d000cbe5d4503299dd6
parentd23fef68415ce6587f77e9530cb0571bb90b31cc (diff)
downloadhaskell-179d0becd2ddfa216f7b221df9fc520a352fdbe7.tar.gz
hadrian: Add a viaLlvmBackend modifier
Note that this also slightly changes the semantics of these flavours as we only use LLVM for >= stage1 builds.
-rw-r--r--hadrian/doc/flavours.md4
-rw-r--r--hadrian/src/Flavour.hs6
-rw-r--r--hadrian/src/Settings/Flavours/Llvm.hs8
3 files changed, 12 insertions, 6 deletions
diff --git a/hadrian/doc/flavours.md b/hadrian/doc/flavours.md
index c5441f05d6..254f2e0666 100644
--- a/hadrian/doc/flavours.md
+++ b/hadrian/doc/flavours.md
@@ -216,6 +216,10 @@ The supported transformers are listed below:
<td><code>thread_sanitizer</code></td>
<td>Build the runtime system with ThreadSanitizer support</td>
</tr>
+ <tr>
+ <td><code>llvm</code></td>
+ <td>Use GHC's LLVM backend (`-fllvm`) for all stage1+ compilation.</td>
+ </tr>
</table>
## Ways
diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs
index 06f72a06eb..6c68df21ff 100644
--- a/hadrian/src/Flavour.hs
+++ b/hadrian/src/Flavour.hs
@@ -8,6 +8,7 @@ module Flavour
, splitSections, splitSectionsIf
, enableThreadSanitizer
, enableDebugInfo, enableTickyGhc
+ , viaLlvmBackend
) where
import Expression
@@ -84,6 +85,7 @@ flavourTransformers = M.fromList
, "ticky_ghc" =: enableTickyGhc
, "split_sections" =: splitSections
, "thread_sanitizer" =: enableThreadSanitizer
+ , "llvm" =: viaLlvmBackend
]
where (=:) = (,)
@@ -191,3 +193,7 @@ enableThreadSanitizer = addArgs $ mconcat
, builder (Cabal Flags) ? arg "thread-sanitizer"
, builder RunTest ? arg "--config=have_thread_sanitizer=True"
]
+
+-- | Use the LLVM backend in stages 1 and later.
+viaLlvmBackend :: Flavour -> Flavour
+viaLlvmBackend = addArgs $ notStage0 ? builder Ghc ? arg "-fllvm"
diff --git a/hadrian/src/Settings/Flavours/Llvm.hs b/hadrian/src/Settings/Flavours/Llvm.hs
index ddf07a248d..3882e73f45 100644
--- a/hadrian/src/Settings/Flavours/Llvm.hs
+++ b/hadrian/src/Settings/Flavours/Llvm.hs
@@ -5,7 +5,6 @@ module Settings.Flavours.Llvm (
quickLlvmFlavour,
) where
-import Expression
import Flavour
import Settings.Flavours.Benchmark
@@ -22,8 +21,5 @@ quickLlvmFlavour = mkLlvmFlavour quickFlavour
-- | Turn a flavour into an LLVM flavour
mkLlvmFlavour :: Flavour -> Flavour
-mkLlvmFlavour flav = flav
- { name = name flav ++ "-llvm"
- , args = mconcat [ args flav
- , builder Ghc ? arg "-fllvm" ]
- }
+mkLlvmFlavour flav = viaLlvmBackend $ flav
+ { name = name flav ++ "-llvm" }