diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-07-24 15:13:49 -0700 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-09-21 11:53:56 -0700 |
commit | 06d46b1e4507e09eb2a7a04998a92610c8dc6277 (patch) | |
tree | 7dc84733d3b6a8313c272c2c8fed4cc0b5d30e90 /compiler/iface/MkIface.hs | |
parent | 09d214dcd8e831c128c684facb7c8da1d63c58bc (diff) | |
download | haskell-06d46b1e4507e09eb2a7a04998a92610c8dc6277.tar.gz |
Unify hsig and hs-boot; add preliminary "hs-boot" merging.
This patch drops the file level distinction between hs-boot and hsig;
we figure out which one we are compiling based on whether or not there
is a corresponding hs file lying around.
To make the "import A" syntax continue to work for bare hs-boot
files, we also introduce hs-boot merging, which takes an A.hi-boot
and converts it to an A.hi when there is no A.hs file in scope.
This will be generalized in Backpack to merge multiple A.hi files together;
which means we can jettison the "load multiple interface files" functionality.
This works automatically for --make, but for one-shot compilation
we need a new mode: ghc --merge-requirements A will generate an A.hi/A.o
from a local A.hi-boot file; Backpack will extend this mechanism further.
Has Haddock submodule update to deal with change in msHsFilePath behavior.
- This commit drops support for the hsig extension. Can
we support it? It's annoying because the finder code is
written with the assumption that where there's an hs-boot
file, there's always an hs file too. To support hsig, you'd
have to probe two locations. Easier to just not support it.
- #10333 affects us, modifying an hs-boot still doesn't trigger
recomp.
- See compiler/main/Finder.hs: this diff is very skeevy, but
it seems to work.
- This code cunningly doesn't drop hs-boot files from the
"drop hs-boot files" module graph, if they don't have a
corresponding hs file. I have no idea if this actually is useful.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: simonpj, austin, bgamari, spinda
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1098
Diffstat (limited to 'compiler/iface/MkIface.hs')
-rw-r--r-- | compiler/iface/MkIface.hs | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/compiler/iface/MkIface.hs b/compiler/iface/MkIface.hs index 757bebac93..99544c4e4f 100644 --- a/compiler/iface/MkIface.hs +++ b/compiler/iface/MkIface.hs @@ -15,6 +15,7 @@ module MkIface ( -- including computing version information mkIfaceTc, + mkIfaceDirect, writeIfaceFile, -- Write the interface file @@ -160,6 +161,35 @@ mkIface hsc_env maybe_old_fingerprint mod_details warns hpc_info dir_imp_mods self_trust dependent_files safe_mode mod_details +-- | Make an interface from a manually constructed 'ModIface'. We use +-- this when we are merging 'ModIface's. We assume that the 'ModIface' +-- has accurate entries but not accurate fingerprint information (so, +-- like @intermediate_iface@ in 'mkIface_'.) +mkIfaceDirect :: HscEnv + -> Maybe Fingerprint + -> ModIface + -> IO (ModIface, Bool) +mkIfaceDirect hsc_env maybe_old_fingerprint iface0 = do + -- Sort some things to make sure we're deterministic + let intermediate_iface = iface0 { + mi_exports = mkIfaceExports (mi_exports iface0), + mi_insts = sortBy cmp_inst (mi_insts iface0), + mi_fam_insts = sortBy cmp_fam_inst (mi_fam_insts iface0), + mi_rules = sortBy cmp_rule (mi_rules iface0) + } + dflags = hsc_dflags hsc_env + (final_iface, no_change_at_all) + <- {-# SCC "versioninfo" #-} + addFingerprints hsc_env maybe_old_fingerprint + intermediate_iface + (map snd (mi_decls iface0)) + + -- Debug printing + dumpIfSet_dyn dflags Opt_D_dump_hi "FINAL INTERFACE" + (pprModIface final_iface) + + return (final_iface, no_change_at_all) + -- | make an interface from the results of typechecking only. Useful -- for non-optimising compilation, or where we aren't generating any -- object code at all ('HscNothing'). @@ -357,11 +387,6 @@ mkIface_ hsc_env maybe_old_fingerprint return (errs_and_warns, Just (final_iface, no_change_at_all)) where - cmp_rule = comparing ifRuleName - -- Compare these lexicographically by OccName, *not* by unique, - -- because the latter is not stable across compilations: - cmp_inst = comparing (nameOccName . ifDFun) - cmp_fam_inst = comparing (nameOccName . ifFamInstTcName) dflags = hsc_dflags hsc_env @@ -379,8 +404,6 @@ mkIface_ hsc_env maybe_old_fingerprint deliberatelyOmitted :: String -> a deliberatelyOmitted x = panic ("Deliberately omitted: " ++ x) - ifFamInstTcName = ifFamInstFam - flattenVectInfo (VectInfo { vectInfoVar = vVar , vectInfoTyCon = vTyCon , vectInfoParallelVars = vParallelVars @@ -394,6 +417,16 @@ mkIface_ hsc_env maybe_old_fingerprint , ifaceVectInfoParallelTyCons = nameSetElems vParallelTyCons } +cmp_rule :: IfaceRule -> IfaceRule -> Ordering +cmp_rule = comparing ifRuleName +-- Compare these lexicographically by OccName, *not* by unique, +-- because the latter is not stable across compilations: +cmp_inst :: IfaceClsInst -> IfaceClsInst -> Ordering +cmp_inst = comparing (nameOccName . ifDFun) + +cmp_fam_inst :: IfaceFamInst -> IfaceFamInst -> Ordering +cmp_fam_inst = comparing (nameOccName . ifFamInstFam) + ----------------------------- writeIfaceFile :: DynFlags -> FilePath -> ModIface -> IO () writeIfaceFile dflags hi_file_path new_iface |