summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorLemmih <lemmih@gmail.com>2006-03-18 17:17:28 +0000
committerLemmih <lemmih@gmail.com>2006-03-18 17:17:28 +0000
commit4a3042fcc68554ef59966430d2c6f1b70470d222 (patch)
treec6fa3d75afd0754bcbf47768c40283ca50c740b7 /ghc
parent3eacdc7faf0d0e87a7201253f9f12c1fb4db7249 (diff)
downloadhaskell-4a3042fcc68554ef59966430d2c6f1b70470d222.tar.gz
-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.
Diffstat (limited to 'ghc')
-rw-r--r--ghc/compiler/main/CodeOutput.lhs1
-rw-r--r--ghc/compiler/main/DriverPipeline.hs29
-rw-r--r--ghc/compiler/main/DynFlags.hs14
-rw-r--r--ghc/compiler/main/HscMain.lhs6
-rw-r--r--ghc/compiler/main/Main.hs13
5 files changed, 26 insertions, 37 deletions
diff --git a/ghc/compiler/main/CodeOutput.lhs b/ghc/compiler/main/CodeOutput.lhs
index d1b293353a..0148ca4343 100644
--- a/ghc/compiler/main/CodeOutput.lhs
+++ b/ghc/compiler/main/CodeOutput.lhs
@@ -100,6 +100,7 @@ codeOutput dflags this_mod location foreign_stubs pkg_deps flat_abstractC
#else
panic "ILX support not compiled into this ghc";
#endif
+ HscNothing -> return ();
}
; return stubs_exist
}
diff --git a/ghc/compiler/main/DriverPipeline.hs b/ghc/compiler/main/DriverPipeline.hs
index ac98eff593..2dbee8841f 100644
--- a/ghc/compiler/main/DriverPipeline.hs
+++ b/ghc/compiler/main/DriverPipeline.hs
@@ -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 }
-- Figure out what lang we're generating
- let hsc_lang = hscMaybeAdjustTarget dflags StopLn src_flavour (hscTarget dflags)
+ let hsc_lang = hscTarget dflags
-- ... and what the next phase should be
let next_phase = hscNextPhase dflags src_flavour hsc_lang
-- ... and what file to generate the output into
@@ -204,8 +204,6 @@ 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
-- bytecode so don't even try.
-> runCompiler hscCompileInteractive handleInterpreted
- HscNothing
- -> runCompiler hscCompileNothing handleBatch
_other
-> runCompiler hscCompileBatch handleBatch
@@ -719,7 +717,7 @@ runPhase (Hsc src_flavour) stop dflags0 basename suff input_fn get_output_fn _ma
else return False
-- get the DynFlags
- let hsc_lang = hscMaybeAdjustTarget dflags stop src_flavour (hscTarget dflags)
+ let hsc_lang = hscTarget dflags
let next_phase = hscNextPhase dflags src_flavour hsc_lang
output_fn <- get_output_fn next_phase (Just location4)
@@ -767,7 +765,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
= do
- let hsc_lang = hscMaybeAdjustTarget dflags stop HsSrcFile (hscTarget dflags)
+ let hsc_lang = hscTarget dflags
let next_phase = hscNextPhase dflags HsSrcFile hsc_lang
output_fn <- get_output_fn next_phase maybe_loc
@@ -1378,27 +1376,8 @@ hscNextPhase dflags other hsc_lang =
HscC -> HCc
HscAsm | dopt Opt_SplitObjs dflags -> SplitMangle
| otherwise -> As
- HscNothing -> StopLn
- HscInterpreted -> StopLn
+ HscNothing -> HCc
_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))
-- The split prefix and number of files
diff --git a/ghc/compiler/main/DynFlags.hs b/ghc/compiler/main/DynFlags.hs
index 8f6ac1fee7..f0c95bca32 100644
--- a/ghc/compiler/main/DynFlags.hs
+++ b/ghc/compiler/main/DynFlags.hs
@@ -174,6 +174,7 @@ data DynFlag
| Opt_RecompChecking
| Opt_DryRun
| Opt_DoAsmMangling
+ | Opt_WriteIface
| Opt_ExcessPrecision
| Opt_ReadUserPackageConf
| Opt_NoHsMain
@@ -405,6 +406,7 @@ defaultDynFlags =
-- a good thing anyway, but it seems fragile.
Opt_DoAsmMangling,
+ Opt_WriteIface,
-- and the default no-optimisation options:
Opt_IgnoreInterfacePragmas,
@@ -834,8 +836,10 @@ dynamic_flags = [
, ( "stubdir" , HasArg (upd . setStubDir . Just))
------- Keeping temporary files -------------------------------------
- , ( "keep-hc-file" , AnySuffix (\_ -> setDynFlag Opt_KeepHcFiles))
- , ( "keep-s-file" , AnySuffix (\_ -> setDynFlag Opt_KeepSFiles))
+ , ( "keep-hc-file" , AnySuffix (\_ -> do setDynFlag Opt_KeepHcFiles
+ setTarget HscC))
+ , ( "keep-s-file" , AnySuffix (\_ -> do setDynFlag Opt_KeepSFiles
+ setTarget HscAsm))
, ( "keep-raw-s-file", AnySuffix (\_ -> setDynFlag Opt_KeepRawSFiles))
, ( "keep-tmp-files" , AnySuffix (\_ -> setDynFlag Opt_KeepTmpFiles))
@@ -941,7 +945,8 @@ dynamic_flags = [
------ Compiler flags -----------------------------------------------
- , ( "fno-code", NoArg (setTarget HscNothing))
+ , ( "fno-code", NoArg (do setTarget HscNothing
+ unSetDynFlag Opt_WriteIface))
, ( "fasm", AnySuffix (\_ -> setTarget HscAsm) )
, ( "fvia-c", NoArg (setTarget HscC) )
, ( "fvia-C", NoArg (setTarget HscC) )
@@ -999,7 +1004,8 @@ fFlags = [
( "case-merge", Opt_CaseMerge ),
( "unbox-strict-fields", Opt_UnboxStrictFields ),
( "excess-precision", Opt_ExcessPrecision ),
- ( "asm-mangling", Opt_DoAsmMangling )
+ ( "asm-mangling", Opt_DoAsmMangling ),
+ ( "write-iface", Opt_WriteIface )
]
glasgowExtsFlags = [
diff --git a/ghc/compiler/main/HscMain.lhs b/ghc/compiler/main/HscMain.lhs
index 3af61b11fb..f2bc84ad13 100644
--- a/ghc/compiler/main/HscMain.lhs
+++ b/ghc/compiler/main/HscMain.lhs
@@ -529,9 +529,11 @@ hscNormalIface simpl_result
hscWriteIface :: (ModIface, Bool, ModDetails, a) -> Comp (ModIface, ModDetails, a)
hscWriteIface (iface, no_change, details, a)
- = do mod_summary <- gets compModSummary
+ = do hsc_env <- gets compHscEnv
+ mod_summary <- gets compModSummary
+ let writeIface = dopt Opt_WriteIface (hsc_dflags hsc_env)
liftIO $ do
- unless no_change
+ unless (no_change || not writeIface)
$ writeIfaceFile (ms_location mod_summary) iface
return (iface, details, a)
diff --git a/ghc/compiler/main/Main.hs b/ghc/compiler/main/Main.hs
index ec5a116894..468c0a632c 100644
--- a/ghc/compiler/main/Main.hs
+++ b/ghc/compiler/main/Main.hs
@@ -147,7 +147,13 @@ main =
ShowInterface f -> showIface f
DoMake -> doMake session srcs
DoMkDependHS -> doMkDependHS session (map fst srcs)
- StopBefore p -> oneShot dflags p srcs
+ StopBefore p
+ -- 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
DoEval expr -> interactiveUI session srcs (Just expr)
@@ -348,11 +354,6 @@ mode_flags =
, ( "-make" , PassFlag (setMode DoMake))
, ( "-interactive" , PassFlag (setMode DoInteractive))
, ( "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 ()