summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Wilson <douglas.wilson@gmail.com>2021-12-19 11:56:39 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-28 18:54:44 -0400
commit4ad559c8142e52f4a97076c813471a2848ed4e0f (patch)
tree96ea38a0f1796325a6af95b84bc1dcd156938882
parent654bafea5bd4a1ce82af440c90f5fa38ac532503 (diff)
downloadhaskell-4ad559c8142e52f4a97076c813471a2848ed4e0f.tar.gz
hadrian: add debug_ghc and debug_stage1_ghc flavour transformers
-rw-r--r--hadrian/doc/flavours.md8
-rw-r--r--hadrian/src/Flavour.hs11
-rw-r--r--hadrian/src/Rules/Test.hs2
-rw-r--r--hadrian/src/Settings/Builders/Ghc.hs1
4 files changed, 20 insertions, 2 deletions
diff --git a/hadrian/doc/flavours.md b/hadrian/doc/flavours.md
index 3ef7ac5a3a..d8a4efe7af 100644
--- a/hadrian/doc/flavours.md
+++ b/hadrian/doc/flavours.md
@@ -243,6 +243,14 @@ The supported transformers are listed below:
<td>Build the stage2 libraries with IPE debugging information for use with -hi profiling.</td>
</tr>
<tr>
+ <td><code>debug_ghc</code></td>
+ <td>Build the stage2 compiler linked against the debug rts</td>
+ </tr>
+ <tr>
+ <td><code>debug_stage1_ghc</code></td>
+ <td>Build the stage1 compiler linked against the debug rts</td>
+ </tr>
+ <tr>
<td><code>assertions</code></td>
<td>Build the stage2 compiler with assertions enabled. </td>
</tr>
diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs
index 178eda3a8b..7a42e6df3d 100644
--- a/hadrian/src/Flavour.hs
+++ b/hadrian/src/Flavour.hs
@@ -49,6 +49,8 @@ flavourTransformers = M.fromList
, "fully_static" =: fullyStatic
, "collect_timings" =: collectTimings
, "assertions" =: enableAssertions
+ , "debug_ghc" =: debugGhc Stage1
+ , "debug_stage1_ghc" =: debugGhc Stage0
]
where (=:) = (,)
@@ -270,6 +272,15 @@ collectTimings =
addArgs $ notStage0 ? builder (Ghc CompileHs) ?
pure ["-ddump-to-file", "-ddump-timings", "-v"]
+-- | Build ghc with debug rts (i.e. -debug) in and after this stage
+debugGhc :: Stage -> Flavour -> Flavour
+debugGhc stage f = f
+ { ghcDebugged = (>= stage)
+ , rtsWays = do
+ ws <- rtsWays f
+ pure $ (Set.map (\w -> w <> debug) ws) <> ws
+ }
+
-- * CLI and <root>/hadrian.settings options
{-
diff --git a/hadrian/src/Rules/Test.hs b/hadrian/src/Rules/Test.hs
index 27ef2336f1..e389506f3e 100644
--- a/hadrian/src/Rules/Test.hs
+++ b/hadrian/src/Rules/Test.hs
@@ -146,7 +146,7 @@ testRules = do
top <- topDirectory
depsPkgs <- mod_pkgs . packageDependencies <$> readPackageData progPkg
bindir <- getBinaryDirectory testGhc
- debugged <- ghcDebugged <$> flavour <*> pure Stage3
+ debugged <- ghcDebugged <$> flavour <*> pure (stageOf testGhc)
dynPrograms <- dynamicGhcPrograms =<< flavour
cmd [bindir </> "ghc" <.> exe] $
concatMap (\p -> ["-package", pkgName p]) depsPkgs ++
diff --git a/hadrian/src/Settings/Builders/Ghc.hs b/hadrian/src/Settings/Builders/Ghc.hs
index 47ac5f0ed9..ec19de44d5 100644
--- a/hadrian/src/Settings/Builders/Ghc.hs
+++ b/hadrian/src/Settings/Builders/Ghc.hs
@@ -177,7 +177,6 @@ ghcLinkArgs = builder (Ghc LinkHs) ? do
, osxTarget ? pure (concat [ ["-framework", fmwk] | fmwk <- fmwks ])
, debugged ? packageOneOf [ghc, iservProxy, iserv, remoteIserv] ?
arg "-debug"
-
]
findHsDependencies :: Args