1 -----------------------------------------------------------------------------
2 -- $Id: DriverState.hs,v 1.12 2000/11/09 12:54:09 simonmar Exp $
4 -- Settings for the driver
6 -- (c) The University of Glasgow 2000
8 -----------------------------------------------------------------------------
10 module DriverState where
12 #include "HsVersions.h"
21 #ifdef mingw32_TARGET_OS
22 import TmpFiles ( newTempName )
23 import Directory ( removeFile )
32 -----------------------------------------------------------------------------
35 -- certain flags can be specified on a per-file basis, in an OPTIONS
36 -- pragma at the beginning of the source file. This means that when
37 -- compiling mulitple files, we have to restore the global option
38 -- settings before compiling a new file.
40 -- The DriverState record contains the per-file-mutable state.
42 data DriverState = DriverState {
44 -- are we runing cpp on this file?
48 stolen_x86_regs :: Int,
49 cmdline_hc_includes :: [String],
51 -- options for a particular phase
59 initDriverState = DriverState {
62 cmdline_hc_includes = [],
70 GLOBAL_VAR(v_Driver_state, initDriverState, DriverState)
72 readState :: (DriverState -> a) -> IO a
73 readState f = readIORef v_Driver_state >>= return . f
75 updateState :: (DriverState -> DriverState) -> IO ()
76 updateState f = readIORef v_Driver_state >>= writeIORef v_Driver_state . f
78 addOpt_L a = updateState (\s -> s{opt_L = a : opt_L s})
79 addOpt_P a = updateState (\s -> s{opt_P = a : opt_P s})
80 addOpt_c a = updateState (\s -> s{opt_c = a : opt_c s})
81 addOpt_a a = updateState (\s -> s{opt_a = a : opt_a s})
82 addOpt_m a = updateState (\s -> s{opt_m = a : opt_m s})
84 addCmdlineHCInclude a =
85 updateState (\s -> s{cmdline_hc_includes = a : cmdline_hc_includes s})
87 -- we add to the options from the front, so we need to reverse the list
88 getOpts :: (DriverState -> [a]) -> IO [a]
89 getOpts opts = readState opts >>= return . reverse
91 -----------------------------------------------------------------------------
92 -- non-configured things
94 cHaskell1Version = "5" -- i.e., Haskell 98
96 -----------------------------------------------------------------------------
97 -- Global compilation flags
99 -- location of compiler-related files
100 GLOBAL_VAR(v_TopDir, clibdir, String)
101 GLOBAL_VAR(v_Inplace, False, Bool)
104 v_Hs_source_cpp_opts = global
105 [ "-D__HASKELL1__="++cHaskell1Version
106 , "-D__GLASGOW_HASKELL__="++cProjectVersionInt
108 , "-D__CONCURRENT_HASKELL__"
110 {-# NOINLINE v_Hs_source_cpp_opts #-}
113 GLOBAL_VAR(v_Verbose, False, Bool)
114 is_verbose = do v <- readIORef v_Verbose; if v then return "-v" else return ""
116 -- Keep output from intermediate phases
117 GLOBAL_VAR(v_Keep_hi_diffs, False, Bool)
118 GLOBAL_VAR(v_Keep_hc_files, False, Bool)
119 GLOBAL_VAR(v_Keep_s_files, False, Bool)
120 GLOBAL_VAR(v_Keep_raw_s_files, False, Bool)
121 GLOBAL_VAR(v_Keep_tmp_files, False, Bool)
124 GLOBAL_VAR(v_Scale_sizes_by, 1.0, Double)
125 GLOBAL_VAR(v_Dry_run, False, Bool)
126 #if !defined(HAVE_WIN32_DLL_SUPPORT) || defined(DONT_WANT_WIN32_DLL_SUPPORT)
127 GLOBAL_VAR(v_Static, True, Bool)
129 GLOBAL_VAR(v_Static, False, Bool)
131 GLOBAL_VAR(v_NoHsMain, False, Bool)
132 GLOBAL_VAR(v_Recomp, True, Bool)
133 GLOBAL_VAR(v_Collect_ghc_timing, False, Bool)
134 GLOBAL_VAR(v_Do_asm_mangling, True, Bool)
135 GLOBAL_VAR(v_Excess_precision, False, Bool)
137 -----------------------------------------------------------------------------
138 -- Splitting object files (for libraries)
140 GLOBAL_VAR(v_Split_object_files, False, Bool)
141 GLOBAL_VAR(v_Split_prefix, "", String)
142 GLOBAL_VAR(v_N_split_files, 0, Int)
145 can_split = prefixMatch "i386" cTARGETPLATFORM
146 || prefixMatch "alpha" cTARGETPLATFORM
147 || prefixMatch "hppa" cTARGETPLATFORM
148 || prefixMatch "m68k" cTARGETPLATFORM
149 || prefixMatch "mips" cTARGETPLATFORM
150 || prefixMatch "powerpc" cTARGETPLATFORM
151 || prefixMatch "rs6000" cTARGETPLATFORM
152 || prefixMatch "sparc" cTARGETPLATFORM
154 -----------------------------------------------------------------------------
155 -- Compiler output options
157 GLOBAL_VAR(v_Hsc_Lang, if cGhcWithNativeCodeGen == "YES" &&
158 (prefixMatch "i386" cTARGETPLATFORM ||
159 prefixMatch "sparc" cTARGETPLATFORM)
164 GLOBAL_VAR(v_Output_dir, Nothing, Maybe String)
165 GLOBAL_VAR(v_Object_suf, Nothing, Maybe String)
166 GLOBAL_VAR(v_Output_file, Nothing, Maybe String)
167 GLOBAL_VAR(v_Output_hi, Nothing, Maybe String)
169 GLOBAL_VAR(v_Ld_inputs, [], [String])
171 odir_ify :: String -> IO String
173 odir_opt <- readIORef v_Output_dir
176 Just d -> return (newdir d f)
178 osuf_ify :: String -> IO String
180 osuf_opt <- readIORef v_Object_suf
183 Just s -> return (newsuf s f)
185 -----------------------------------------------------------------------------
188 GLOBAL_VAR(v_ProduceHi, True, Bool)
189 GLOBAL_VAR(v_Hi_on_stdout, False, Bool)
190 GLOBAL_VAR(v_Hi_suf, "hi", String)
192 -----------------------------------------------------------------------------
193 -- Warnings & sanity checking
195 -- Warning packages that are controlled by -W and -Wall. The 'standard'
196 -- warnings that you get all the time are
198 -- -fwarn-overlapping-patterns
199 -- -fwarn-missing-methods
200 -- -fwarn-missing-fields
201 -- -fwarn-deprecations
202 -- -fwarn-duplicate-exports
204 -- these are turned off by -Wnot.
207 standardWarnings = [ "-fwarn-overlapping-patterns"
208 , "-fwarn-missing-methods"
209 , "-fwarn-missing-fields"
210 , "-fwarn-deprecations"
211 , "-fwarn-duplicate-exports"
213 minusWOpts = standardWarnings ++
214 [ "-fwarn-unused-binds"
215 , "-fwarn-unused-matches"
216 , "-fwarn-incomplete-patterns"
217 , "-fwarn-unused-imports"
219 minusWallOpts = minusWOpts ++
220 [ "-fwarn-type-defaults"
221 , "-fwarn-name-shadowing"
222 , "-fwarn-missing-signatures"
223 , "-fwarn-hi-shadowing"
226 data WarningState = W_default | W_ | W_all | W_not
227 GLOBAL_VAR(v_Warning_opt, W_default, WarningState)
229 -----------------------------------------------------------------------------
230 -- Compiler optimisation options
232 GLOBAL_VAR(v_OptLevel, 0, Int)
234 setOptLevel :: String -> IO ()
235 setOptLevel "" = do { writeIORef v_OptLevel 1; go_via_C }
236 setOptLevel "not" = writeIORef v_OptLevel 0
237 setOptLevel [c] | isDigit c = do
238 let level = ord c - ord '0'
239 writeIORef v_OptLevel level
240 when (level >= 1) go_via_C
241 setOptLevel s = unknownFlagErr ("-O"++s)
244 l <- readIORef v_Hsc_Lang
245 case l of { HscAsm -> writeIORef v_Hsc_Lang HscC;
246 _other -> return () }
248 GLOBAL_VAR(v_minus_o2_for_C, False, Bool)
250 GLOBAL_VAR(v_MaxSimplifierIterations, 4, Int)
251 GLOBAL_VAR(v_StgStats, False, Bool)
252 GLOBAL_VAR(v_UsageSPInf, False, Bool) -- Off by default
253 GLOBAL_VAR(v_Strictness, True, Bool)
254 GLOBAL_VAR(v_CPR, True, Bool)
255 GLOBAL_VAR(v_CSE, True, Bool)
257 hsc_minusO2_flags = hsc_minusO_flags -- for now
261 "-fignore-interface-pragmas",
262 "-fomit-interface-pragmas"
268 "-fdo-eta-reduction",
269 "-fdo-lambda-eta-expansion",
275 buildCoreToDo :: IO [CoreToDo]
277 opt_level <- readIORef v_OptLevel
278 max_iter <- readIORef v_MaxSimplifierIterations
279 usageSP <- readIORef v_UsageSPInf
280 strictness <- readIORef v_Strictness
281 cpr <- readIORef v_CPR
282 cse <- readIORef v_CSE
284 if opt_level == 0 then return
286 CoreDoSimplify (isAmongSimpl [
287 MaxSimplifierIterations max_iter
291 else {- level >= 1 -} return [
293 -- initial simplify: mk specialiser happy: minimum effort please
294 CoreDoSimplify (isAmongSimpl [
296 -- Don't inline anything till full laziness has bitten
297 -- In particular, inlining wrappers inhibits floating
298 -- e.g. ...(case f x of ...)...
299 -- ==> ...(case (case x of I# x# -> fw x#) of ...)...
300 -- ==> ...(case x of I# x# -> case fw x# of ...)...
301 -- and now the redex (f x) isn't floatable any more
303 -- Similarly, don't apply any rules until after full
304 -- laziness. Notably, list fusion can prevent floating.
306 -- Don't do case-of-case transformations.
307 -- This makes full laziness work better
308 MaxSimplifierIterations max_iter
311 -- Specialisation is best done before full laziness
312 -- so that overloaded functions have all their dictionary lambdas manifest
315 CoreDoFloatOutwards False{-not full-},
318 CoreDoSimplify (isAmongSimpl [
320 -- Want to run with inline phase 1 after the specialiser to give
321 -- maximum chance for fusion to work before we inline build/augment
322 -- in phase 2. This made a difference in 'ansi' where an
323 -- overloaded function wasn't inlined till too late.
324 MaxSimplifierIterations max_iter
327 -- infer usage information here in case we need it later.
328 -- (add more of these where you need them --KSW 1999-04)
329 if usageSP then CoreDoUSPInf else CoreDoNothing,
331 CoreDoSimplify (isAmongSimpl [
332 -- Need inline-phase2 here so that build/augment get
333 -- inlined. I found that spectral/hartel/genfft lost some useful
334 -- strictness in the function sumcode' if augment is not inlined
335 -- before strictness analysis runs
337 MaxSimplifierIterations max_iter
340 CoreDoSimplify (isAmongSimpl [
341 MaxSimplifierIterations 2
342 -- No -finline-phase: allow all Ids to be inlined now
343 -- This gets foldr inlined before strictness analysis
346 if strictness then CoreDoStrictness else CoreDoNothing,
347 if cpr then CoreDoCPResult else CoreDoNothing,
351 CoreDoSimplify (isAmongSimpl [
352 MaxSimplifierIterations max_iter
353 -- No -finline-phase: allow all Ids to be inlined now
356 CoreDoFloatOutwards False{-not full-},
357 -- nofib/spectral/hartel/wang doubles in speed if you
358 -- do full laziness late in the day. It only happens
359 -- after fusion and other stuff, so the early pass doesn't
360 -- catch it. For the record, the redex is
361 -- f_el22 (f_el21 r_midblock)
363 -- Leave out lambda lifting for now
364 -- "-fsimplify", -- Tidy up results of full laziness
366 -- "-fmax-simplifier-iterations2",
368 -- "-ffloat-outwards-full",
370 -- We want CSE to follow the final full-laziness pass, because it may
371 -- succeed in commoning up things floated out by full laziness.
373 -- CSE must immediately follow a simplification pass, because it relies
374 -- on the no-shadowing invariant. See comments at the top of CSE.lhs
375 -- So it must NOT follow float-inwards, which can give rise to shadowing,
376 -- even if its input doesn't have shadows. Hence putting it between
378 if cse then CoreCSE else CoreDoNothing,
382 -- Case-liberation for -O2. This should be after
383 -- strictness analysis and the simplification which follows it.
385 -- ( ($OptLevel != 2)
387 -- : "-fliberate-case -fsimplify [ $Oopt_FB_Support -ffloat-lets-exposing-whnf -ffloat-primops-ok -fcase-of-case -fdo-case-elim -fcase-merge -fdo-lambda-eta-expansion -freuse-con -flet-to-case $Oopt_PedanticBottoms $Oopt_MaxSimplifierIterations $Oopt_ShowSimplifierProgress ]" ),
389 -- "-fliberate-case",
391 -- Final clean-up simplification:
392 CoreDoSimplify (isAmongSimpl [
393 MaxSimplifierIterations max_iter
394 -- No -finline-phase: allow all Ids to be inlined now
398 buildStgToDo :: IO [ StgToDo ]
400 stg_stats <- readIORef v_StgStats
401 let flags1 | stg_stats = [ D_stg_stats ]
405 ways_ <- readIORef v_Ways
406 let flags2 | WayProf `elem` ways_ = StgDoMassageForProfiling : flags1
411 -----------------------------------------------------------------------------
414 split_marker = ':' -- not configurable (ToDo)
416 v_Import_paths, v_Include_paths, v_Library_paths :: IORef [String]
417 GLOBAL_VAR(v_Import_paths, ["."], [String])
418 GLOBAL_VAR(v_Include_paths, ["."], [String])
419 GLOBAL_VAR(v_Library_paths, [], [String])
421 GLOBAL_VAR(v_Cmdline_libraries, [], [String])
423 addToDirList :: IORef [String] -> String -> IO ()
424 addToDirList ref path
425 = do paths <- readIORef ref
426 writeIORef ref (paths ++ split split_marker path)
428 -----------------------------------------------------------------------------
431 GLOBAL_VAR(v_Path_package_config, error "path_package_config", String)
433 -- package list is maintained in dependency order
434 GLOBAL_VAR(v_Packages, ("std":"rts":"gmp":[]), [String])
436 addPackage :: String -> IO ()
438 = do pkg_details <- readIORef v_Package_details
439 case lookupPkg package pkg_details of
440 Nothing -> throwDyn (OtherError ("unknown package name: " ++ package))
442 ps <- readIORef v_Packages
443 unless (package `elem` ps) $ do
444 mapM_ addPackage (package_deps details)
445 ps <- readIORef v_Packages
446 writeIORef v_Packages (package:ps)
448 getPackageImportPath :: IO [String]
449 getPackageImportPath = do
450 ps <- readIORef v_Packages
451 ps' <- getPackageDetails ps
452 return (nub (concat (map import_dirs ps')))
454 getPackageIncludePath :: IO [String]
455 getPackageIncludePath = do
456 ps <- readIORef v_Packages
457 ps' <- getPackageDetails ps
458 return (nub (filter (not.null) (concatMap include_dirs ps')))
460 -- includes are in reverse dependency order (i.e. rts first)
461 getPackageCIncludes :: IO [String]
462 getPackageCIncludes = do
463 ps <- readIORef v_Packages
464 ps' <- getPackageDetails ps
465 return (reverse (nub (filter (not.null) (concatMap c_includes ps'))))
467 getPackageLibraryPath :: IO [String]
468 getPackageLibraryPath = do
469 ps <- readIORef v_Packages
470 ps' <- getPackageDetails ps
471 return (nub (concat (map library_dirs ps')))
473 getPackageLibraries :: IO [String]
474 getPackageLibraries = do
475 ps <- readIORef v_Packages
476 ps' <- getPackageDetails ps
477 tag <- readIORef v_Build_tag
478 let suffix = if null tag then "" else '_':tag
480 map (\p -> map (++suffix) (hs_libraries p) ++ extra_libraries p) ps'
483 getPackageExtraGhcOpts :: IO [String]
484 getPackageExtraGhcOpts = do
485 ps <- readIORef v_Packages
486 ps' <- getPackageDetails ps
487 return (concatMap extra_ghc_opts ps')
489 getPackageExtraCcOpts :: IO [String]
490 getPackageExtraCcOpts = do
491 ps <- readIORef v_Packages
492 ps' <- getPackageDetails ps
493 return (concatMap extra_cc_opts ps')
495 getPackageExtraLdOpts :: IO [String]
496 getPackageExtraLdOpts = do
497 ps <- readIORef v_Packages
498 ps' <- getPackageDetails ps
499 return (concatMap extra_ld_opts ps')
501 getPackageDetails :: [String] -> IO [Package]
502 getPackageDetails ps = do
503 pkg_details <- readIORef v_Package_details
504 return [ pkg | p <- ps, Just pkg <- [ lookupPkg p pkg_details ] ]
506 GLOBAL_VAR(v_Package_details, (error "package_details"), [Package])
508 lookupPkg :: String -> [Package] -> Maybe Package
510 = case [p | p <- ps, name p == nm] of
513 -----------------------------------------------------------------------------
516 -- The central concept of a "way" is that all objects in a given
517 -- program must be compiled in the same "way". Certain options change
518 -- parameters of the virtual machine, eg. profiling adds an extra word
519 -- to the object header, so profiling objects cannot be linked with
520 -- non-profiling objects.
522 -- After parsing the command-line options, we determine which "way" we
523 -- are building - this might be a combination way, eg. profiling+ticky-ticky.
525 -- We then find the "build-tag" associated with this way, and this
526 -- becomes the suffix used to find .hi files and libraries used in
529 GLOBAL_VAR(v_Build_tag, "", String)
559 GLOBAL_VAR(v_Ways, [] ,[WayName])
561 -- ToDo: allow WayDll with any other allowed combination
563 allowed_combinations =
564 [ [WayProf,WayUnreg],
565 [WayProf,WaySMP] -- works???
568 findBuildTag :: IO [String] -- new options
570 way_names <- readIORef v_Ways
571 case sort way_names of
572 [] -> do writeIORef v_Build_tag ""
575 [w] -> do let details = lkupWay w
576 writeIORef v_Build_tag (wayTag details)
577 return (wayOpts details)
579 ws -> if ws `notElem` allowed_combinations
580 then throwDyn (OtherError $
581 "combination not supported: " ++
582 foldr1 (\a b -> a ++ '/':b)
583 (map (wayName . lkupWay) ws))
584 else let stuff = map lkupWay ws
585 tag = concat (map wayTag stuff)
586 flags = map wayOpts stuff
588 writeIORef v_Build_tag tag
589 return (concat flags)
592 case lookup w way_details of
593 Nothing -> error "findBuildTag"
594 Just details -> details
602 way_details :: [ (WayName, Way) ]
604 [ (WayProf, Way "p" "Profiling"
610 (WayTicky, Way "t" "Ticky-ticky Profiling"
613 , "-optc-DTICKY_TICKY"
616 (WayUnreg, Way "u" "Unregisterised"
618 , "-optc-DUSE_MINIINTERPRETER"
619 , "-fno-asm-mangling"
623 (WayDll, Way "dll" "DLLized"
626 (WayPar, Way "mp" "Parallel"
628 , "-D__PARALLEL_HASKELL__"
630 , "-package concurrent"
633 (WayGran, Way "mg" "Gransim"
637 , "-package concurrent"
640 (WaySMP, Way "s" "SMP"
647 (WayUser_a, Way "a" "User way 'a'" ["$WAY_a_REAL_OPTS"]),
648 (WayUser_b, Way "b" "User way 'b'" ["$WAY_b_REAL_OPTS"]),
649 (WayUser_c, Way "c" "User way 'c'" ["$WAY_c_REAL_OPTS"]),
650 (WayUser_d, Way "d" "User way 'd'" ["$WAY_d_REAL_OPTS"]),
651 (WayUser_e, Way "e" "User way 'e'" ["$WAY_e_REAL_OPTS"]),
652 (WayUser_f, Way "f" "User way 'f'" ["$WAY_f_REAL_OPTS"]),
653 (WayUser_g, Way "g" "User way 'g'" ["$WAY_g_REAL_OPTS"]),
654 (WayUser_h, Way "h" "User way 'h'" ["$WAY_h_REAL_OPTS"]),
655 (WayUser_i, Way "i" "User way 'i'" ["$WAY_i_REAL_OPTS"]),
656 (WayUser_j, Way "j" "User way 'j'" ["$WAY_j_REAL_OPTS"]),
657 (WayUser_k, Way "k" "User way 'k'" ["$WAY_k_REAL_OPTS"]),
658 (WayUser_l, Way "l" "User way 'l'" ["$WAY_l_REAL_OPTS"]),
659 (WayUser_m, Way "m" "User way 'm'" ["$WAY_m_REAL_OPTS"]),
660 (WayUser_n, Way "n" "User way 'n'" ["$WAY_n_REAL_OPTS"]),
661 (WayUser_o, Way "o" "User way 'o'" ["$WAY_o_REAL_OPTS"]),
662 (WayUser_A, Way "A" "User way 'A'" ["$WAY_A_REAL_OPTS"]),
663 (WayUser_B, Way "B" "User way 'B'" ["$WAY_B_REAL_OPTS"])
666 -----------------------------------------------------------------------------
667 -- Programs for particular phases
669 GLOBAL_VAR(v_Pgm_L, error "pgm_L", String)
670 GLOBAL_VAR(v_Pgm_P, cRAWCPP, String)
671 GLOBAL_VAR(v_Pgm_c, cGCC, String)
672 GLOBAL_VAR(v_Pgm_m, error "pgm_m", String)
673 GLOBAL_VAR(v_Pgm_s, error "pgm_s", String)
674 GLOBAL_VAR(v_Pgm_a, cGCC, String)
675 GLOBAL_VAR(v_Pgm_l, cGCC, String)
677 GLOBAL_VAR(v_Opt_dep, [], [String])
678 GLOBAL_VAR(v_Anti_opt_C, [], [String])
679 GLOBAL_VAR(v_Opt_C, [], [String])
680 GLOBAL_VAR(v_Opt_l, [], [String])
681 GLOBAL_VAR(v_Opt_dll, [], [String])
683 getStaticOpts :: IORef [String] -> IO [String]
684 getStaticOpts ref = readIORef ref >>= return . reverse
686 -----------------------------------------------------------------------------
687 -- Via-C compilation stuff
689 -- flags returned are: ( all C compilations
690 -- , registerised HC compilations
694 | prefixMatch "alpha" cTARGETPLATFORM
695 = return ( ["-static"], [] )
697 | prefixMatch "hppa" cTARGETPLATFORM
698 -- ___HPUX_SOURCE, not _HPUX_SOURCE, is #defined if -ansi!
699 -- (very nice, but too bad the HP /usr/include files don't agree.)
700 = return ( ["-static", "-D_HPUX_SOURCE"], [] )
702 | prefixMatch "m68k" cTARGETPLATFORM
703 -- -fno-defer-pop : for the .hc files, we want all the pushing/
704 -- popping of args to routines to be explicit; if we let things
705 -- be deferred 'til after an STGJUMP, imminent death is certain!
707 -- -fomit-frame-pointer : *don't*
708 -- It's better to have a6 completely tied up being a frame pointer
709 -- rather than let GCC pick random things to do with it.
710 -- (If we want to steal a6, then we would try to do things
711 -- as on iX86, where we *do* steal the frame pointer [%ebp].)
712 = return ( [], ["-fno-defer-pop", "-fno-omit-frame-pointer"] )
714 | prefixMatch "i386" cTARGETPLATFORM
715 -- -fno-defer-pop : basically the same game as for m68k
717 -- -fomit-frame-pointer : *must* in .hc files; because we're stealing
718 -- the fp (%ebp) for our register maps.
719 = do n_regs <- readState stolen_x86_regs
720 sta <- readIORef v_Static
721 return ( [ if sta then "-DDONT_WANT_WIN32_DLL_SUPPORT" else "" ],
722 [ "-fno-defer-pop", "-fomit-frame-pointer",
723 "-DSTOLEN_X86_REGS="++show n_regs ]
726 | prefixMatch "mips" cTARGETPLATFORM
727 = return ( ["static"], [] )
729 | prefixMatch "powerpc" cTARGETPLATFORM || prefixMatch "rs6000" cTARGETPLATFORM
730 = return ( ["static"], ["-finhibit-size-directive"] )
736 -----------------------------------------------------------------------------
737 -- Running an external program
739 run_something phase_name cmd
741 verb <- readIORef v_Verbose
749 n <- readIORef v_Dry_run
753 #ifndef mingw32_TARGET_OS
754 exit_code <- system cmd `catchAllIO`
755 (\_ -> throwDyn (PhaseFailed phase_name (ExitFailure 1)))
757 tmp <- newTempName "sh"
758 h <- openFile tmp WriteMode
761 exit_code <- system ("sh - " ++ tmp) `catchAllIO`
762 (\e -> throwDyn (PhaseFailed phase_name (ExitFailure 1)))
766 if exit_code /= ExitSuccess
767 then throwDyn (PhaseFailed phase_name exit_code)
768 else do when verb (putStr "\n")