@@ -80,7 +80,7 @@ data MafiaCommand =
80
80
| MafiaHash
81
81
| MafiaDepends DependsUI (Maybe PackageName ) [Flag ]
82
82
| MafiaClean
83
- | MafiaBuild Profiling Warnings CoreDump [Flag ] [Argument ]
83
+ | MafiaBuild Profiling Warnings CoreDump AsmDump [Flag ] [Argument ]
84
84
| MafiaTest [Flag ] [Argument ]
85
85
| MafiaTestCI [Flag ] [Argument ]
86
86
| MafiaRepl [Flag ] [Argument ]
@@ -108,6 +108,11 @@ data CoreDump =
108
108
| EnableCoreDump
109
109
deriving (Eq , Show )
110
110
111
+ data AsmDump =
112
+ DisableAsmDump
113
+ | EnableAsmDump
114
+ deriving (Eq , Show )
115
+
111
116
data GhciInclude =
112
117
Directory Directory
113
118
| ProjectLibraries
@@ -129,8 +134,8 @@ run = \case
129
134
mafiaDepends tree pkg flags
130
135
MafiaClean ->
131
136
mafiaClean
132
- MafiaBuild p w dump flags args ->
133
- mafiaBuild p w dump flags args
137
+ MafiaBuild p w dumpc dumpa flags args ->
138
+ mafiaBuild p w dumpc dumpa flags args
134
139
MafiaTest flags args ->
135
140
mafiaTest flags args
136
141
MafiaTestCI flags args ->
@@ -192,7 +197,7 @@ commands =
192
197
(pure MafiaClean )
193
198
194
199
, command' " build" " Build this package, including all executables and test suites."
195
- (MafiaBuild <$> pProfiling <*> pWarnings <*> pCoreDump <*> many pFlag <*> many pCabalArgs)
200
+ (MafiaBuild <$> pProfiling <*> pWarnings <*> pCoreDump <*> pAsmDump <*> many pFlag <*> many pCabalArgs)
196
201
197
202
, command' " test" " Test this package, by default this runs all test suites."
198
203
(MafiaTest <$> many pFlag <*> many pCabalArgs)
@@ -283,6 +288,12 @@ pCoreDump =
283
288
long " dump-core"
284
289
<> help " Dump the optimised Core output to dist/build/*. This is simply a shorthand for other GHC options."
285
290
291
+ pAsmDump :: Parser AsmDump
292
+ pAsmDump =
293
+ flag DisableAsmDump EnableAsmDump $
294
+ long " dump-asm"
295
+ <> help " Dump the assembly-language output to dist/build/*. This is simply a shorthand for other GHC options."
296
+
286
297
pDependsUI :: Parser DependsUI
287
298
pDependsUI =
288
299
flag List Tree $
@@ -462,8 +473,8 @@ mafiaClean = do
462
473
Out (_ :: ByteString ) <- liftCabal $ cabal " clean" []
463
474
liftCabal removeSandbox
464
475
465
- mafiaBuild :: Profiling -> Warnings -> CoreDump -> [Flag ] -> [Argument ] -> EitherT MafiaError IO ()
466
- mafiaBuild p w dump flags args = do
476
+ mafiaBuild :: Profiling -> Warnings -> CoreDump -> AsmDump -> [Flag ] -> [Argument ] -> EitherT MafiaError IO ()
477
+ mafiaBuild p w dumpc dumpa flags args = do
467
478
initMafia LatestSources p flags
468
479
469
480
let
@@ -475,7 +486,10 @@ mafiaBuild p w dump flags args = do
475
486
[" --ghc-options=-Werror" ]
476
487
477
488
dumpargs =
478
- case dump of
489
+ ordNub $ coredump <> asmdump
490
+
491
+ coredump =
492
+ case dumpc of
479
493
DisableCoreDump ->
480
494
[]
481
495
EnableCoreDump -> fmap (" --ghc-options=" <> )
@@ -489,6 +503,14 @@ mafiaBuild p w dump flags args = do
489
503
," -dsuppress-module-prefixes"
490
504
]
491
505
506
+ asmdump =
507
+ case dumpa of
508
+ DisableAsmDump ->
509
+ []
510
+ EnableAsmDump -> fmap (" --ghc-options=" <> )
511
+ [" -ddump-asm"
512
+ ," -ddump-to-file"
513
+ ]
492
514
493
515
liftCabal . cabal_ " build" $ [" -j" ] <> wargs <> dumpargs <> args
494
516
0 commit comments