summaryrefslogtreecommitdiff
path: root/hadrian
diff options
context:
space:
mode:
authorsternenseemann <sternenseemann@systemli.org>2022-07-24 11:41:11 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-07-26 16:26:53 -0400
commit42147534320f9ac22f16ffc226148ae553337d2e (patch)
treefcf235b7e28c24f957a79ac23ea2958dcf9ed306 /hadrian
parent25c24535ad51aa22b9cae425c6ac4ad9a8f1e1e9 (diff)
downloadhaskell-42147534320f9ac22f16ffc226148ae553337d2e.tar.gz
hadrian: add flag disabling selftest rules which require QuickCheck
The hadrian executable depends on QuickCheck for building, meaning this library (and its dependencies) will need to be built for bootstrapping GHC in the future. Building QuickCheck, however, can require TemplateHaskell. When building a statically linking GHC toolchain, TemplateHaskell can be tricky to get to work, and cross-compiling TemplateHaskell doesn't work at all without -fexternal-interpreter, so QuickCheck introduces an element of fragility to GHC's bootstrap. Since the selftest rules are the only part of hadrian that need QuickCheck, we can easily eliminate this bootstrap dependency when required by introducing a `selftest` flag guarding the rules' inclusion. Closes #8699.
Diffstat (limited to 'hadrian')
-rw-r--r--hadrian/hadrian.cabal15
-rw-r--r--hadrian/src/Main.hs6
2 files changed, 18 insertions, 3 deletions
diff --git a/hadrian/hadrian.cabal b/hadrian/hadrian.cabal
index da0aa4daab..c37974914a 100644
--- a/hadrian/hadrian.cabal
+++ b/hadrian/hadrian.cabal
@@ -24,6 +24,14 @@ flag threaded
which don't support the threaded runtime should
disable this flag.
+-- See also #21913
+flag selftest
+ manual: True
+ default: True
+ description: Enables the hadrian selftest rules which require
+ QuickCheck. Disabling it thus saves on a few dependencies
+ which can be problematic when bootstrapping.
+
executable hadrian
main-is: Main.hs
hs-source-dirs: .
@@ -82,7 +90,6 @@ executable hadrian
, Rules.Program
, Rules.Register
, Rules.Rts
- , Rules.Selftest
, Rules.SimpleTargets
, Rules.SourceDist
, Rules.Test
@@ -141,7 +148,6 @@ executable hadrian
other-extensions: MultiParamTypeClasses
, TypeFamilies
build-depends: Cabal >= 3.2 && < 3.7
- , QuickCheck >= 2.6 && < 2.15
, base >= 4.8 && < 5
, bytestring >= 0.10 && < 0.12
, containers >= 0.5 && < 0.7
@@ -169,3 +175,8 @@ executable hadrian
-- time tends to eat any benefit.
"-with-rtsopts=-I0 -qg"
-threaded
+
+ if flag(selftest)
+ other-modules: Rules.Selftest
+ cpp-options: -DHADRIAN_ENABLE_SELFTEST
+ build-depends: QuickCheck >= 2.6 && < 2.15
diff --git a/hadrian/src/Main.hs b/hadrian/src/Main.hs
index d2e0ace795..4c3dfe2bcc 100644
--- a/hadrian/src/Main.hs
+++ b/hadrian/src/Main.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
module Main (main) where
import Development.Shake
@@ -19,7 +20,9 @@ import qualified Rules.Docspec
import qualified Rules.Documentation
import qualified Rules.Lint
import qualified Rules.Nofib
+#if HADRIAN_ENABLE_SELFTEST
import qualified Rules.Selftest
+#endif
import qualified Rules.SourceDist
import qualified Rules.Test
import qualified UserSettings
@@ -99,7 +102,9 @@ main = do
Rules.Lint.lintRules
Rules.Nofib.nofibRules
Rules.oracleRules
+#if HADRIAN_ENABLE_SELFTEST
Rules.Selftest.selftestRules
+#endif
Rules.SourceDist.sourceDistRules
Rules.Test.testRules
Rules.topLevelTargets
@@ -150,4 +155,3 @@ escNormal = "\ESC[0m"
escape :: String -> String -> String
escape code x = escForeground code ++ x ++ escNormal
-