+{-# OPTIONS -#include "hschooks.h" #-}
+
-----------------------------------------------------------------------------
--- $Id: DriverFlags.hs,v 1.28 2000/12/06 13:03:29 simonmar Exp $
+-- $Id: DriverFlags.hs,v 1.63 2001/07/24 04:47:06 ken Exp $
--
-- Driver flags
--
--
-----------------------------------------------------------------------------
-module DriverFlags where
+module DriverFlags (
+ processArgs, OptKind(..), static_flags, dynamic_flags,
+ getDynFlags, dynFlag,
+ getOpts, getVerbFlag, addCmdlineHCInclude,
+ buildStaticHscOpts,
+ machdepCCOpts
+ ) where
#include "HsVersions.h"
+#include "../includes/config.h"
-import PackageMaintenance
import DriverState
import DriverUtil
-import TmpFiles ( v_TmpDir )
+import SysTools ( setTmpDir, setPgm, setDryRun, showGhcUsage )
import CmdLineOpts
import Config
import Util
-import TmpFiles ( newTempName )
-import Directory ( removeFile )
+import Panic
+
import Exception
import IOExts
+import System ( exitWith, ExitCode(..) )
+
import IO
+import Maybe
import Monad
-import System
import Char
-----------------------------------------------------------------------------
--
-- * parse the initial list of flags and remove any flags understood
-- by the driver only. Determine whether we're in multi-compilation
--- or single-compilation mode.
+-- or single-compilation mode (done in Main.main).
--
-- * gather the list of "static" hsc flags, and assign them to the global
-- static hsc flags variable.
| AnySuffixPred (String -> Bool) (String -> IO ())
processArgs :: [(String,OptKind)] -> [String] -> [String]
- -> IO [String] -- returns spare args
+ -> IO [String] -- returns spare args
processArgs _spec [] spare = return (reverse spare)
+
processArgs spec args@(('-':arg):args') spare = do
case findArg spec arg of
- Just (rest,action) ->
- do args' <- processOneArg action rest args
- processArgs spec args' spare
- Nothing ->
- processArgs spec args' (('-':arg):spare)
+ Just (rest,action) -> do args' <- processOneArg action rest args
+ processArgs spec args' spare
+ Nothing -> processArgs spec args' (('-':arg):spare)
+
processArgs spec (arg:args) spare =
processArgs spec args (arg:spare)
findArg :: [(String,OptKind)] -> String -> Maybe (String,OptKind)
findArg spec arg
= case [ (remove_spaces rest, k)
- | (pat,k) <- spec, Just rest <- [my_prefix_match pat arg],
+ | (pat,k) <- spec,
+ Just rest <- [my_prefix_match pat arg],
arg_ok k rest arg ]
of
[] -> Nothing
static_flags =
[ ------- help -------------------------------------------------------
- ( "?" , NoArg long_usage)
- , ( "-help" , NoArg long_usage)
+ ( "?" , NoArg showGhcUsage)
+ , ( "-help" , NoArg showGhcUsage)
------- version ----------------------------------------------------
exitWith ExitSuccess))
------- verbosity ----------------------------------------------------
- , ( "n" , NoArg (writeIORef v_Dry_run True) )
+ , ( "n" , NoArg setDryRun )
------- recompilation checker --------------------------------------
, ( "recomp" , NoArg (writeIORef v_Recomp True) )
, ( "dppr-user-length", AnySuffix (add v_Opt_C) )
-- rest of the debugging flags are dynamic
- ------- Interface files ---------------------------------------------
- , ( "hi" , NoArg (writeIORef v_ProduceHi True) )
- , ( "nohi" , NoArg (writeIORef v_ProduceHi False) )
-
--------- Profiling --------------------------------------------------
, ( "auto-dicts" , NoArg (add v_Opt_C "-fauto-sccs-on-dicts") )
, ( "auto-all" , NoArg (add v_Opt_C "-fauto-sccs-on-all-toplevs") )
, ( "odir" , HasArg (writeIORef v_Output_dir . Just) )
, ( "o" , SepArg (writeIORef v_Output_file . Just) )
, ( "osuf" , HasArg (writeIORef v_Object_suf . Just) )
+ , ( "hcsuf" , HasArg (writeIORef v_HC_suf . Just) )
, ( "hisuf" , HasArg (writeIORef v_Hi_suf) )
- , ( "tmpdir" , HasArg (writeIORef v_TmpDir . (++ "/")) )
- , ( "ohi" , HasArg (\s -> case s of
- "-" -> writeIORef v_Hi_on_stdout True
- _ -> writeIORef v_Output_hi (Just s)) )
+ , ( "hidir" , HasArg (writeIORef v_Hi_dir . Just) )
+ , ( "buildtag" , HasArg (writeIORef v_Build_tag) )
+ , ( "tmpdir" , HasArg setTmpDir)
+ , ( "ohi" , HasArg (writeIORef v_Output_hi . Just) )
-- -odump?
, ( "keep-hc-file" , AnySuffix (\_ -> writeIORef v_Keep_hc_files True) )
, ( "package" , HasArg (addPackage) )
, ( "syslib" , HasArg (addPackage) ) -- for compatibility w/ old vsns
- , ( "-list-packages" , NoArg (listPackages) )
- , ( "-add-package" , NoArg (newPackage) )
- , ( "-delete-package" , SepArg (deletePackage) )
-
------- Specific phases --------------------------------------------
- , ( "pgmL" , HasArg (writeIORef v_Pgm_L) )
- , ( "pgmP" , HasArg (writeIORef v_Pgm_P) )
- , ( "pgmc" , HasArg (writeIORef v_Pgm_c) )
- , ( "pgmm" , HasArg (writeIORef v_Pgm_m) )
- , ( "pgms" , HasArg (writeIORef v_Pgm_s) )
- , ( "pgma" , HasArg (writeIORef v_Pgm_a) )
- , ( "pgml" , HasArg (writeIORef v_Pgm_l) )
+ , ( "pgm" , HasArg setPgm )
, ( "optdep" , HasArg (add v_Opt_dep) )
, ( "optl" , HasArg (add v_Opt_l) )
, ( "optdll" , HasArg (add v_Opt_dll) )
- ------ Warning opts -------------------------------------------------
- , ( "W" , NoArg (writeIORef v_Warning_opt W_) )
- , ( "Wall" , NoArg (writeIORef v_Warning_opt W_all) )
- , ( "Wnot" , NoArg (writeIORef v_Warning_opt W_not) )
- , ( "w" , NoArg (writeIORef v_Warning_opt W_not) )
-
----- Linker --------------------------------------------------------
, ( "static" , NoArg (writeIORef v_Static True) )
+ , ( "dynamic" , NoArg (writeIORef v_Static False) )
, ( "rdynamic" , NoArg (return ()) ) -- ignored for compat w/ gcc
----- RTS opts ------------------------------------------------------
-#ifdef not_yet
, ( "H" , HasArg (setHeapSize . fromIntegral . decodeSize) )
-#endif
+ , ( "Rghc-timing" , NoArg (enableTimingStats) )
------ Compiler flags -----------------------------------------------
, ( "O2-for-C" , NoArg (writeIORef v_minus_o2_for_C True) )
, ( "fexcess-precision" , NoArg (do writeIORef v_Excess_precision True
add v_Opt_C "-fexcess-precision"))
- -- flags that are "active negatives"
- , ( "fno-implicit-prelude" , PassFlag (add v_Opt_C) )
- , ( "fno-prune-tydecls" , PassFlag (add v_Opt_C) )
- , ( "fno-prune-instdecls" , PassFlag (add v_Opt_C) )
- , ( "fno-pre-inlining" , PassFlag (add v_Opt_C) )
+ -- Optimisation flags are treated specially, so the normal
+ -- -fno-* pattern below doesn't work. We therefore allow
+ -- certain optimisation passes to be turned off explicitly:
+ , ( "fno-strictness" , NoArg (writeIORef v_Strictness False) )
+ , ( "fno-cpr" , NoArg (writeIORef v_CPR False) )
+ , ( "fno-cse" , NoArg (writeIORef v_CSE False) )
-- All other "-fno-<blah>" options cancel out "-f<blah>" on the hsc cmdline
, ( "fno-", PrefixPred (\s -> isStaticHscFlag ("f"++s))
, ( "f", AnySuffixPred (isStaticHscFlag) (add v_Opt_C) )
]
------------------------------------------------------------------------------
--- parse the dynamic arguments
-
--- v_InitDynFlags
--- is the "baseline" dynamic flags, initialised from
--- the defaults and command line options.
---
--- v_DynFlags
--- is the dynamic flags for the current compilation. It is reset
--- to the value of v_InitDynFlags before each compilation, then
--- updated by reading any OPTIONS pragma in the current module.
-
-GLOBAL_VAR(v_InitDynFlags, defaultDynFlags, DynFlags)
-GLOBAL_VAR(v_DynFlags, defaultDynFlags, DynFlags)
-
-updDynFlags f = do
- dfs <- readIORef v_DynFlags
- writeIORef v_DynFlags (f dfs)
-
-getDynFlags :: IO DynFlags
-getDynFlags = readIORef v_DynFlags
-
-dynFlag :: (DynFlags -> a) -> IO a
-dynFlag f = do dflags <- readIORef v_DynFlags; return (f dflags)
-
-setDynFlag f = updDynFlags (\dfs -> dfs{ flags = f : flags dfs })
-unSetDynFlag f = updDynFlags (\dfs -> dfs{ flags = filter (/= f) (flags dfs) })
-
--- we can only change HscC to HscAsm and vice-versa with dynamic flags
--- (-fvia-C and -fasm).
-setLang l = do
- dfs <- readIORef v_DynFlags
- case hscLang dfs of
- HscC -> writeIORef v_DynFlags dfs{ hscLang = l }
- HscAsm -> writeIORef v_DynFlags dfs{ hscLang = l }
- _ -> return ()
-
-setVerbosityAtLeast n =
- updDynFlags (\dfs -> if verbosity dfs < n
- then dfs{ verbosity = n }
- else dfs)
-
-setVerbosity "" = updDynFlags (\dfs -> dfs{ verbosity = 2 })
-setVerbosity n
- | all isDigit n = updDynFlags (\dfs -> dfs{ verbosity = read n })
- | otherwise = throwDyn (OtherError "can't parse verbosity flag (-v<n>)")
-
-getVerbFlag = do
- verb <- dynFlag verbosity
- if verb >= 3 then return "-v" else return ""
-
dynamic_flags = [
- ( "cpp", NoArg (updateState (\s -> s{ cpp_flag = True })) )
+ ( "cpp", NoArg (updDynFlags (\s -> s{ cppFlag = True })) )
, ( "#include", HasArg (addCmdlineHCInclude) )
, ( "v", OptPrefix (setVerbosity) )
, ( "opta", HasArg (addOpt_a) )
------ HsCpp opts ---------------------------------------------------
+ -- With a C compiler whose system() doesn't use a UNIX shell (i.e.
+ -- mingwin gcc), -D and -U args must *not* be quoted, as the quotes
+ -- will be interpreted as part of the arguments, and not stripped;
+ -- on all other systems, quoting is necessary, to avoid interpretation
+ -- of shell metacharacters in the arguments (e.g. green-card's
+ -- -DBEGIN_GHC_ONLY='}-' trick).
+#ifndef mingw32_TARGET_OS
, ( "D", Prefix (\s -> addOpt_P ("-D'"++s++"'") ) )
, ( "U", Prefix (\s -> addOpt_P ("-U'"++s++"'") ) )
+#else
+ , ( "D", Prefix (\s -> addOpt_P ("-D"++s) ) )
+ , ( "U", Prefix (\s -> addOpt_P ("-U"++s) ) )
+#endif
------ Debugging ----------------------------------------------------
, ( "dstg-stats", NoArg (writeIORef v_StgStats True) )
, ( "ddump-worker-wrapper", NoArg (setDynFlag Opt_D_dump_worker_wrapper) )
, ( "dshow-passes", NoArg (setVerbosity "2") )
, ( "ddump-rn-trace", NoArg (setDynFlag Opt_D_dump_rn_trace) )
+ , ( "ddump-tc-trace", NoArg (setDynFlag Opt_D_dump_tc_trace) )
, ( "ddump-rn-stats", NoArg (setDynFlag Opt_D_dump_rn_stats) )
, ( "ddump-stix", NoArg (setDynFlag Opt_D_dump_stix) )
, ( "ddump-simpl-stats", NoArg (setDynFlag Opt_D_dump_simpl_stats) )
- , ( "ddump-interpsyn", NoArg (setDynFlag Opt_D_dump_InterpSyn) )
+ , ( "ddump-bcos", NoArg (setDynFlag Opt_D_dump_BCOs) )
, ( "dsource-stats", NoArg (setDynFlag Opt_D_source_stats) )
, ( "dverbose-core2core", NoArg (setDynFlag Opt_D_verbose_core2core) )
, ( "dverbose-stg2stg", NoArg (setDynFlag Opt_D_verbose_stg2stg) )
, ( "dstg-lint", NoArg (setDynFlag Opt_DoStgLinting) )
, ( "dusagesp-lint", NoArg (setDynFlag Opt_DoUSPLinting) )
- ------ Warnings ----------------------------------------------------
-
- , ( "fwarn-duplicate-exports", NoArg (setDynFlag Opt_WarnDuplicateExports) )
- , ( "fwarn-hi-shadowing", NoArg (setDynFlag Opt_WarnHiShadows) )
- , ( "fwarn-incomplete-patterns", NoArg (setDynFlag Opt_WarnIncompletePatterns) )
- , ( "fwarn-missing-fields", NoArg (setDynFlag Opt_WarnMissingFields) )
- , ( "fwarn-missing-methods", NoArg (setDynFlag Opt_WarnMissingMethods))
- , ( "fwarn-missing-signatures", NoArg (setDynFlag Opt_WarnMissingSigs) )
- , ( "fwarn-name-shadowing", NoArg (setDynFlag Opt_WarnNameShadowing) )
- , ( "fwarn-overlapping-patterns", NoArg (setDynFlag Opt_WarnOverlappingPatterns ) )
- , ( "fwarn-simple-patterns", NoArg (setDynFlag Opt_WarnSimplePatterns))
- , ( "fwarn-type-defaults", NoArg (setDynFlag Opt_WarnTypeDefaults) )
- , ( "fwarn-unused-binds", NoArg (setDynFlag Opt_WarnUnusedBinds) )
- , ( "fwarn-unused-imports", NoArg (setDynFlag Opt_WarnUnusedImports) )
- , ( "fwarn-unused-matches", NoArg (setDynFlag Opt_WarnUnusedMatches) )
- , ( "fwarn-deprecations", NoArg (setDynFlag Opt_WarnDeprecations) )
-
------ Machine dependant (-m<blah>) stuff ---------------------------
- , ( "monly-2-regs", NoArg (updateState (\s -> s{stolen_x86_regs = 2}) ))
- , ( "monly-3-regs", NoArg (updateState (\s -> s{stolen_x86_regs = 3}) ))
- , ( "monly-4-regs", NoArg (updateState (\s -> s{stolen_x86_regs = 4}) ))
+ , ( "monly-2-regs", NoArg (updDynFlags (\s -> s{stolen_x86_regs = 2}) ))
+ , ( "monly-3-regs", NoArg (updDynFlags (\s -> s{stolen_x86_regs = 3}) ))
+ , ( "monly-4-regs", NoArg (updDynFlags (\s -> s{stolen_x86_regs = 4}) ))
- ------ Compiler flags -----------------------------------------------
-
- , ( "fasm" , AnySuffix (\_ -> setLang HscAsm) )
+ ------ Warning opts -------------------------------------------------
+ , ( "W" , NoArg (mapM_ setDynFlag minusWOpts) )
+ , ( "Wall" , NoArg (mapM_ setDynFlag minusWallOpts) )
+ , ( "Wnot" , NoArg (mapM_ unSetDynFlag minusWallOpts) ) /* DEPREC */
+ , ( "w" , NoArg (mapM_ unSetDynFlag minusWallOpts) )
- , ( "fvia-c" , NoArg (setLang HscC) )
- , ( "fvia-C" , NoArg (setLang HscC) )
+ ------ Compiler flags -----------------------------------------------
- , ( "fglasgow-exts", NoArg (setDynFlag Opt_GlasgowExts) )
- , ( "fno-implicit-prelude", NoArg (setDynFlag Opt_NoImplicitPrelude) )
+ , ( "fasm", AnySuffix (\_ -> setLang HscAsm) )
+ , ( "fvia-c", NoArg (setLang HscC) )
+ , ( "fvia-C", NoArg (setLang HscC) )
+ , ( "filx", NoArg (setLang HscILX) )
- , ( "fallow-overlapping-instances",
- NoArg (setDynFlag Opt_AllowOverlappingInstances) )
+ -- "active negatives"
+ , ( "fno-implicit-prelude", NoArg (setDynFlag Opt_NoImplicitPrelude) )
- , ( "fallow-undecidable-instances",
- NoArg (setDynFlag Opt_AllowUndecidableInstances) )
+ -- the rest of the -f* and -fno-* flags
+ , ( "fno-", PrefixPred (\f -> isFFlag f) (\f -> unSetDynFlag (getFFlag f)) )
+ , ( "f", PrefixPred (\f -> isFFlag f) (\f -> setDynFlag (getFFlag f)) )
+ ]
- , ( "fgenerics", NoArg (setDynFlag Opt_Generics) )
+-- these -f<blah> flags can all be reversed with -fno-<blah>
+
+fFlags = [
+ ( "warn-duplicate-exports", Opt_WarnDuplicateExports ),
+ ( "warn-hi-shadowing", Opt_WarnHiShadows ),
+ ( "warn-incomplete-patterns", Opt_WarnIncompletePatterns ),
+ ( "warn-missing-fields", Opt_WarnMissingFields ),
+ ( "warn-missing-methods", Opt_WarnMissingMethods ),
+ ( "warn-missing-signatures", Opt_WarnMissingSigs ),
+ ( "warn-name-shadowing", Opt_WarnNameShadowing ),
+ ( "warn-overlapping-patterns", Opt_WarnOverlappingPatterns ),
+ ( "warn-simple-patterns", Opt_WarnSimplePatterns ),
+ ( "warn-type-defaults", Opt_WarnTypeDefaults ),
+ ( "warn-unused-binds", Opt_WarnUnusedBinds ),
+ ( "warn-unused-imports", Opt_WarnUnusedImports ),
+ ( "warn-unused-matches", Opt_WarnUnusedMatches ),
+ ( "warn-deprecations", Opt_WarnDeprecations ),
+ ( "glasgow-exts", Opt_GlasgowExts ),
+ ( "allow-overlapping-instances", Opt_AllowOverlappingInstances ),
+ ( "allow-undecidable-instances", Opt_AllowUndecidableInstances ),
+ ( "generics", Opt_Generics )
+ ]
- , ( "freport-compile", NoArg (setDynFlag Opt_ReportCompile) )
- ]
+isFFlag f = f `elem` (map fst fFlags)
+getFFlag f = fromJust (lookup f fFlags)
-----------------------------------------------------------------------------
-- convert sizes like "3.5M" into integers
| c == "K" || c == "k" = truncate (n * 1000)
| c == "M" || c == "m" = truncate (n * 1000 * 1000)
| c == "G" || c == "g" = truncate (n * 1000 * 1000 * 1000)
- | otherwise = throwDyn (OtherError ("can't decode size: " ++ str))
+ | otherwise = throwDyn (CmdLineError ("can't decode size: " ++ str))
where (m, c) = span pred str
n = read m :: Double
pred c = isDigit c || c == '.'
-floatOpt :: IORef Double -> String -> IO ()
-floatOpt ref str
- = writeIORef ref (read str :: Double)
-#ifdef not_yet
-foreign import "setHeapSize" unsafe setHeapSize :: Int -> IO ()
-#endif
+-----------------------------------------------------------------------------
+-- RTS Hooks
+
+foreign import "setHeapSize" unsafe setHeapSize :: Int -> IO ()
+foreign import "enableTimingStats" unsafe enableTimingStats :: IO ()
-----------------------------------------------------------------------------
-- Build the Hsc static command line opts
_ -> error "unknown opt level"
-- ToDo: -Ofile
- let stg_opts = [ "-flet-no-escape" ]
- -- let-no-escape always on for now
-
-- take into account -fno-* flags by removing the equivalent -f*
-- flag from our list.
anti_flags <- getStaticOpts v_Anti_opt_C
- let basic_opts = opt_C_ ++ optimisation_opts ++ stg_opts
+ let basic_opts = opt_C_ ++ optimisation_opts
filtered_opts = filter (`notElem` anti_flags) basic_opts
static <- (do s <- readIORef v_Static; if s then return "-static"
return ( static : filtered_opts )
-----------------------------------------------------------------------------
--- Running an external program
+-- Via-C compilation stuff
+
+-- flags returned are: ( all C compilations
+-- , registerised HC compilations
+-- )
+
+machdepCCOpts
+ | prefixMatch "alpha" cTARGETPLATFORM
+ = return ( ["-static", "-Xlinker -noprefix_recognition"], [] )
+
+ | prefixMatch "hppa" cTARGETPLATFORM
+ -- ___HPUX_SOURCE, not _HPUX_SOURCE, is #defined if -ansi!
+ -- (very nice, but too bad the HP /usr/include files don't agree.)
+ = return ( ["-static", "-D_HPUX_SOURCE"], [] )
+
+ | prefixMatch "m68k" cTARGETPLATFORM
+ -- -fno-defer-pop : for the .hc files, we want all the pushing/
+ -- popping of args to routines to be explicit; if we let things
+ -- be deferred 'til after an STGJUMP, imminent death is certain!
+ --
+ -- -fomit-frame-pointer : *don't*
+ -- It's better to have a6 completely tied up being a frame pointer
+ -- rather than let GCC pick random things to do with it.
+ -- (If we want to steal a6, then we would try to do things
+ -- as on iX86, where we *do* steal the frame pointer [%ebp].)
+ = return ( [], ["-fno-defer-pop", "-fno-omit-frame-pointer"] )
+
+ | prefixMatch "i386" cTARGETPLATFORM
+ -- -fno-defer-pop : basically the same game as for m68k
+ --
+ -- -fomit-frame-pointer : *must* in .hc files; because we're stealing
+ -- the fp (%ebp) for our register maps.
+ = do n_regs <- dynFlag stolen_x86_regs
+ sta <- readIORef v_Static
+ return ( [ if sta then "-DDONT_WANT_WIN32_DLL_SUPPORT" else "",
+ if suffixMatch "mingw32" cTARGETPLATFORM then "-mno-cygwin" else "" ],
+ [ "-fno-defer-pop", "-fomit-frame-pointer",
+ "-DSTOLEN_X86_REGS="++show n_regs ]
+ )
+
+ | prefixMatch "mips" cTARGETPLATFORM
+ = return ( ["-static"], [] )
+
+ | prefixMatch "powerpc" cTARGETPLATFORM || prefixMatch "rs6000" cTARGETPLATFORM
+ = return ( ["-static"], ["-finhibit-size-directive"] )
+
+ | otherwise
+ = return ( [], [] )
+
+
+
+addOpt_L a = updDynFlags (\s -> s{opt_L = a : opt_L s})
+addOpt_P a = updDynFlags (\s -> s{opt_P = a : opt_P s})
+addOpt_c a = updDynFlags (\s -> s{opt_c = a : opt_c s})
+addOpt_a a = updDynFlags (\s -> s{opt_a = a : opt_a s})
+addOpt_m a = updDynFlags (\s -> s{opt_m = a : opt_m s})
+
+addCmdlineHCInclude a = updDynFlags (\s -> s{cmdlineHcIncludes = a : cmdlineHcIncludes s})
+
+getOpts :: (DynFlags -> [a]) -> IO [a]
+ -- We add to the options from the front, so we need to reverse the list
+getOpts opts = dynFlag opts >>= return . reverse
--- sigh, here because both DriverMkDepend & DriverPipeline need it.
+-- we can only change HscC to HscAsm and vice-versa with dynamic flags
+-- (-fvia-C and -fasm).
+-- NB: we can also set the new lang to ILX, via -filx. I hope this is right
+setLang l = updDynFlags (\ dfs -> case hscLang dfs of
+ HscC -> dfs{ hscLang = l }
+ HscAsm -> dfs{ hscLang = l }
+ HscILX -> dfs{ hscLang = l }
+ _ -> dfs)
+
+setVerbosity "" = updDynFlags (\dfs -> dfs{ verbosity = 3 })
+setVerbosity n
+ | all isDigit n = updDynFlags (\dfs -> dfs{ verbosity = read n })
+ | otherwise = throwDyn (UsageError "can't parse verbosity flag (-v<n>)")
-runSomething phase_name cmd
- = do
+getVerbFlag = do
verb <- dynFlag verbosity
- when (verb >= 2) $ putStrLn ("*** " ++ phase_name)
- when (verb >= 3) $ putStrLn cmd
- hFlush stdout
-
- -- test for -n flag
- n <- readIORef v_Dry_run
- unless n $ do
-
- -- and run it!
-#ifndef mingw32_TARGET_OS
- exit_code <- system cmd `catchAllIO`
- (\_ -> throwDyn (PhaseFailed phase_name (ExitFailure 1)))
-#else
- tmp <- newTempName "sh"
- h <- openFile tmp WriteMode
- hPutStrLn h cmd
- hClose h
- exit_code <- system ("sh - " ++ tmp) `catchAllIO`
- (\_ -> throwDyn (PhaseFailed phase_name (ExitFailure 1)))
- removeFile tmp
-#endif
-
- if exit_code /= ExitSuccess
- then throwDyn (PhaseFailed phase_name exit_code)
- else do when (verb >= 3) (putStr "\n")
- return ()
-
+ if verb >= 3 then return "-v" else return ""