Commit 851154f0 authored by David Himmelstrup's avatar David Himmelstrup
Browse files

-fno-code shouldn't be a mode.

I've removed -fno-code from Main to make it work
equally well with --make and -c.
I've also allowed it not to write hi files unless
-fwrite-iface is given.
parent 7f24ae51
...@@ -100,7 +100,6 @@ codeOutput dflags this_mod location foreign_stubs pkg_deps flat_abstractC ...@@ -100,7 +100,6 @@ codeOutput dflags this_mod location foreign_stubs pkg_deps flat_abstractC
#else #else
panic "ILX support not compiled into this ghc"; panic "ILX support not compiled into this ghc";
#endif #endif
HscNothing -> return ();
} }
; return stubs_exist ; return stubs_exist
} }
......
...@@ -130,7 +130,7 @@ compile hsc_env mod_summary maybe_old_linkable old_iface mod_index nmods = do ...@@ -130,7 +130,7 @@ compile hsc_env mod_summary maybe_old_linkable old_iface mod_index nmods = do
dflags = dflags0 { includePaths = current_dir : old_paths } dflags = dflags0 { includePaths = current_dir : old_paths }
-- Figure out what lang we're generating -- Figure out what lang we're generating
let hsc_lang = hscTarget dflags let hsc_lang = hscMaybeAdjustTarget dflags StopLn src_flavour (hscTarget dflags)
-- ... and what the next phase should be -- ... and what the next phase should be
let next_phase = hscNextPhase dflags src_flavour hsc_lang let next_phase = hscNextPhase dflags src_flavour hsc_lang
-- ... and what file to generate the output into -- ... and what file to generate the output into
...@@ -204,6 +204,8 @@ compile hsc_env mod_summary maybe_old_linkable old_iface mod_index nmods = do ...@@ -204,6 +204,8 @@ compile hsc_env mod_summary maybe_old_linkable old_iface mod_index nmods = do
HscInterpreted | not (isHsBoot src_flavour) -- We can't compile boot files to HscInterpreted | not (isHsBoot src_flavour) -- We can't compile boot files to
-- bytecode so don't even try. -- bytecode so don't even try.
-> runCompiler hscCompileInteractive handleInterpreted -> runCompiler hscCompileInteractive handleInterpreted
HscNothing
-> runCompiler hscCompileNothing handleBatch
_other _other
-> runCompiler hscCompileBatch handleBatch -> runCompiler hscCompileBatch handleBatch
...@@ -717,7 +719,7 @@ runPhase (Hsc src_flavour) stop dflags0 basename suff input_fn get_output_fn _ma ...@@ -717,7 +719,7 @@ runPhase (Hsc src_flavour) stop dflags0 basename suff input_fn get_output_fn _ma
else return False else return False
-- get the DynFlags -- get the DynFlags
let hsc_lang = hscTarget dflags let hsc_lang = hscMaybeAdjustTarget dflags stop src_flavour (hscTarget dflags)
let next_phase = hscNextPhase dflags src_flavour hsc_lang let next_phase = hscNextPhase dflags src_flavour hsc_lang
output_fn <- get_output_fn next_phase (Just location4) output_fn <- get_output_fn next_phase (Just location4)
...@@ -765,7 +767,7 @@ runPhase CmmCpp stop dflags basename suff input_fn get_output_fn maybe_loc ...@@ -765,7 +767,7 @@ runPhase CmmCpp stop dflags basename suff input_fn get_output_fn maybe_loc
runPhase Cmm stop dflags basename suff input_fn get_output_fn maybe_loc runPhase Cmm stop dflags basename suff input_fn get_output_fn maybe_loc
= do = do
let hsc_lang = hscTarget dflags let hsc_lang = hscMaybeAdjustTarget dflags stop HsSrcFile (hscTarget dflags)
let next_phase = hscNextPhase dflags HsSrcFile hsc_lang let next_phase = hscNextPhase dflags HsSrcFile hsc_lang
output_fn <- get_output_fn next_phase maybe_loc output_fn <- get_output_fn next_phase maybe_loc
...@@ -1376,8 +1378,27 @@ hscNextPhase dflags other hsc_lang = ...@@ -1376,8 +1378,27 @@ hscNextPhase dflags other hsc_lang =
HscC -> HCc HscC -> HCc
HscAsm | dopt Opt_SplitObjs dflags -> SplitMangle HscAsm | dopt Opt_SplitObjs dflags -> SplitMangle
| otherwise -> As | otherwise -> As
HscNothing -> HCc HscNothing -> StopLn
HscInterpreted -> StopLn
_other -> StopLn _other -> StopLn
hscMaybeAdjustTarget :: DynFlags -> Phase -> HscSource -> HscTarget -> HscTarget
hscMaybeAdjustTarget dflags stop HsBootFile current_hsc_lang
= HscNothing -- No output (other than Foo.hi-boot) for hs-boot files
hscMaybeAdjustTarget dflags stop other current_hsc_lang
= hsc_lang
where
keep_hc = dopt Opt_KeepHcFiles dflags
hsc_lang
-- don't change the lang if we're interpreting
| current_hsc_lang == HscInterpreted = current_hsc_lang
-- force -fvia-C if we are being asked for a .hc file
| HCc <- stop = HscC
| keep_hc = HscC
-- otherwise, stick to the plan
| otherwise = current_hsc_lang
GLOBAL_VAR(v_Split_info, ("",0), (String,Int)) GLOBAL_VAR(v_Split_info, ("",0), (String,Int))
-- The split prefix and number of files -- The split prefix and number of files
...@@ -174,7 +174,6 @@ data DynFlag ...@@ -174,7 +174,6 @@ data DynFlag
| Opt_RecompChecking | Opt_RecompChecking
| Opt_DryRun | Opt_DryRun
| Opt_DoAsmMangling | Opt_DoAsmMangling
| Opt_WriteIface
| Opt_ExcessPrecision | Opt_ExcessPrecision
| Opt_ReadUserPackageConf | Opt_ReadUserPackageConf
| Opt_NoHsMain | Opt_NoHsMain
...@@ -406,7 +405,6 @@ defaultDynFlags = ...@@ -406,7 +405,6 @@ defaultDynFlags =
-- a good thing anyway, but it seems fragile. -- a good thing anyway, but it seems fragile.
Opt_DoAsmMangling, Opt_DoAsmMangling,
Opt_WriteIface,
-- and the default no-optimisation options: -- and the default no-optimisation options:
Opt_IgnoreInterfacePragmas, Opt_IgnoreInterfacePragmas,
...@@ -836,10 +834,8 @@ dynamic_flags = [ ...@@ -836,10 +834,8 @@ dynamic_flags = [
, ( "stubdir" , HasArg (upd . setStubDir . Just)) , ( "stubdir" , HasArg (upd . setStubDir . Just))
------- Keeping temporary files ------------------------------------- ------- Keeping temporary files -------------------------------------
, ( "keep-hc-file" , AnySuffix (\_ -> do setDynFlag Opt_KeepHcFiles , ( "keep-hc-file" , AnySuffix (\_ -> setDynFlag Opt_KeepHcFiles))
setTarget HscC)) , ( "keep-s-file" , AnySuffix (\_ -> setDynFlag Opt_KeepSFiles))
, ( "keep-s-file" , AnySuffix (\_ -> do setDynFlag Opt_KeepSFiles
setTarget HscAsm))
, ( "keep-raw-s-file", AnySuffix (\_ -> setDynFlag Opt_KeepRawSFiles)) , ( "keep-raw-s-file", AnySuffix (\_ -> setDynFlag Opt_KeepRawSFiles))
, ( "keep-tmp-files" , AnySuffix (\_ -> setDynFlag Opt_KeepTmpFiles)) , ( "keep-tmp-files" , AnySuffix (\_ -> setDynFlag Opt_KeepTmpFiles))
...@@ -945,8 +941,7 @@ dynamic_flags = [ ...@@ -945,8 +941,7 @@ dynamic_flags = [
------ Compiler flags ----------------------------------------------- ------ Compiler flags -----------------------------------------------
, ( "fno-code", NoArg (do setTarget HscNothing , ( "fno-code", NoArg (setTarget HscNothing))
unSetDynFlag Opt_WriteIface))
, ( "fasm", AnySuffix (\_ -> setTarget HscAsm) ) , ( "fasm", AnySuffix (\_ -> setTarget HscAsm) )
, ( "fvia-c", NoArg (setTarget HscC) ) , ( "fvia-c", NoArg (setTarget HscC) )
, ( "fvia-C", NoArg (setTarget HscC) ) , ( "fvia-C", NoArg (setTarget HscC) )
...@@ -1004,8 +999,7 @@ fFlags = [ ...@@ -1004,8 +999,7 @@ fFlags = [
( "case-merge", Opt_CaseMerge ), ( "case-merge", Opt_CaseMerge ),
( "unbox-strict-fields", Opt_UnboxStrictFields ), ( "unbox-strict-fields", Opt_UnboxStrictFields ),
( "excess-precision", Opt_ExcessPrecision ), ( "excess-precision", Opt_ExcessPrecision ),
( "asm-mangling", Opt_DoAsmMangling ), ( "asm-mangling", Opt_DoAsmMangling )
( "write-iface", Opt_WriteIface )
] ]
glasgowExtsFlags = [ glasgowExtsFlags = [
......
...@@ -529,11 +529,9 @@ hscNormalIface simpl_result ...@@ -529,11 +529,9 @@ hscNormalIface simpl_result
hscWriteIface :: (ModIface, Bool, ModDetails, a) -> Comp (ModIface, ModDetails, a) hscWriteIface :: (ModIface, Bool, ModDetails, a) -> Comp (ModIface, ModDetails, a)
hscWriteIface (iface, no_change, details, a) hscWriteIface (iface, no_change, details, a)
= do hsc_env <- gets compHscEnv = do mod_summary <- gets compModSummary
mod_summary <- gets compModSummary
let writeIface = dopt Opt_WriteIface (hsc_dflags hsc_env)
liftIO $ do liftIO $ do
unless (no_change || not writeIface) unless no_change
$ writeIfaceFile (ms_location mod_summary) iface $ writeIfaceFile (ms_location mod_summary) iface
return (iface, details, a) return (iface, details, a)
......
...@@ -147,13 +147,7 @@ main = ...@@ -147,13 +147,7 @@ main =
ShowInterface f -> showIface f ShowInterface f -> showIface f
DoMake -> doMake session srcs DoMake -> doMake session srcs
DoMkDependHS -> doMkDependHS session (map fst srcs) DoMkDependHS -> doMkDependHS session (map fst srcs)
StopBefore p StopBefore p -> oneShot dflags p srcs
-- Stop after compiling Haskell if we aren't
-- interested in any further results.
| HscNothing <- hscTarget dflags
-> oneShot dflags HCc srcs
| otherwise
-> oneShot dflags p srcs
DoInteractive -> interactiveUI session srcs Nothing DoInteractive -> interactiveUI session srcs Nothing
DoEval expr -> interactiveUI session srcs (Just expr) DoEval expr -> interactiveUI session srcs (Just expr)
...@@ -354,6 +348,11 @@ mode_flags = ...@@ -354,6 +348,11 @@ mode_flags =
, ( "-make" , PassFlag (setMode DoMake)) , ( "-make" , PassFlag (setMode DoMake))
, ( "-interactive" , PassFlag (setMode DoInteractive)) , ( "-interactive" , PassFlag (setMode DoInteractive))
, ( "e" , HasArg (\s -> setMode (DoEval s) "-e")) , ( "e" , HasArg (\s -> setMode (DoEval s) "-e"))
-- -fno-code says to stop after Hsc but don't generate any code.
, ( "fno-code" , PassFlag (\f -> do setMode (StopBefore HCc) f
addFlag "-fno-code"
addFlag "-no-recomp"))
] ]
setMode :: CmdLineMode -> String -> ModeM () setMode :: CmdLineMode -> String -> ModeM ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment