Commit 508a505e authored by simonpj's avatar simonpj
Browse files

[project @ 2005-01-27 10:44:00 by simonpj]

--------------------------------------------
          Replace hi-boot files with hs-boot files
  	--------------------------------------------

This major commit completely re-organises the way that recursive modules
are dealt with.

  * It should have NO EFFECT if you do not use recursive modules

  * It is a BREAKING CHANGE if you do

====== Warning: .hi-file format has changed, so if you are
======		updating into an existing HEAD build, you'll
======		need to make clean and re-make


The details:  [documentation still to be done]

* Recursive loops are now broken with Foo.hs-boot (or Foo.lhs-boot),
  not Foo.hi-boot

* An hs-boot files is a proper source file.  It is compiled just like
  a regular Haskell source file:
	ghc Foo.hs		generates Foo.hi, Foo.o
	ghc Foo.hs-boot		generates Foo.hi-boot, Foo.o-boot

* hs-boot files are precisely a subset of Haskell. In particular:
	- they have the same import, export, and scoping rules
	- errors (such as kind errors) in hs-boot files are checked
  You do *not* need to mention the "original" name of something in
  an hs-boot file, any more than you do in any other Haskell module.

* The Foo.hi-boot file generated by compiling Foo.hs-boot is a machine-
  generated interface file, in precisely the same format as Foo.hi

* When compiling Foo.hs, its exports are checked for compatibility with
  Foo.hi-boot (previously generated by compiling Foo.hs-boot)

* The dependency analyser (ghc -M) knows about Foo.hs-boot files, and
  generates appropriate dependencies.  For regular source files it
  generates
	Foo.o : Foo.hs
	Foo.o : Baz.hi		-- Foo.hs imports Baz
	Foo.o : Bog.hi-boot	-- Foo.hs source-imports Bog

  For a hs-boot file it generates similar dependencies
	Bog.o-boot : Bog.hs-boot
	Bog.o-boot : Nib.hi	-- Bog.hs-boto imports Nib

* ghc -M is also enhanced to use the compilation manager dependency
  chasing, so that
	ghc -M Main
  will usually do the job.  No need to enumerate all the source files.

* The -c flag is no longer a "compiler mode". It simply means "omit the
  link step", and synonymous with -no-link.
parent f9d8c8e0
......@@ -86,6 +86,10 @@ WAYS=$(GhcCompilerWays)
# - create a link tree. The problem with requiring link trees is that
# Windows doesn't support symbolic links.
ifeq "$(stage)" ""
stage=1
endif
boot ::
$(MKDIRHIER) stage$(stage)
for i in $(ALL_DIRS); do \
......@@ -100,6 +104,8 @@ boot ::
# PS: 'ln -s foo baz' takes 'foo' relative to the path to 'baz'
# whereas 'cp foo baz' treats the two paths independently.
# Hence the "../.." in the ln command line
ifeq "$(stage)" "1"
ifeq "$(ghc_ge_603)" "NO"
ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
for i in */*hi-boot*; do \
cp -u -f $$i stage$(stage)/$$i; \
......@@ -109,9 +115,7 @@ else
$(LN_S) -f ../../$$i stage$(stage)/$$i || true ; \
done
endif
ifeq "$(stage)" ""
stage=1
endif
endif
ifeq "$(stage)" "1"
......
\begin{code}
module DataCon where
import Name( Name )
data DataCon
dataConName :: DataCon -> Name
isVanillaDataCon :: DataCon -> Bool
\end{code}
\begin{code}
module IdInfo where
data IdInfo
data GlobalIdDetails
notGlobalId :: GlobalIdDetails
seqIdInfo :: IdInfo -> ()
\end{code}
\ No newline at end of file
\begin{code}
module MkId where
import Name( Name )
import DataCon( DataCon, DataConIds )
mkDataConIds :: Name -> Name -> DataCon -> DataConIds
\end{code}
......@@ -15,7 +15,7 @@ module Module
, pprModule -- :: ModuleName -> SDoc
, ModLocation(..),
, showModMsg
, addBootSuffix, addBootSuffix_maybe, addBootSuffixLocn,
, moduleString -- :: ModuleName -> EncodedString
, moduleUserString -- :: ModuleName -> UserString
......@@ -30,7 +30,7 @@ module Module
, delModuleEnvList, delModuleEnv, plusModuleEnv, lookupModuleEnv
, lookupWithDefaultModuleEnv, mapModuleEnv, mkModuleEnv, emptyModuleEnv
, moduleEnvElts, unitModuleEnv, isEmptyModuleEnv, foldModuleEnv
, extendModuleEnv_C
, extendModuleEnv_C, filterModuleEnv,
, ModuleSet, emptyModuleSet, mkModuleSet, moduleSetElts, extendModuleSet, elemModuleSet
......@@ -40,11 +40,9 @@ module Module
import OccName
import Outputable
import Unique ( Uniquable(..) )
import Maybes ( expectJust )
import UniqFM
import UniqSet
import Binary
import StringBuffer ( StringBuffer )
import FastString
\end{code}
......@@ -58,15 +56,9 @@ import FastString
data ModLocation
= ModLocation {
ml_hs_file :: Maybe FilePath,
-- the source file, if we have one. Package modules
-- The source file, if we have one. Package modules
-- probably don't have source files.
ml_hspp_file :: Maybe FilePath,
-- filename of preprocessed source, if we have
-- preprocessed it.
ml_hspp_buf :: Maybe StringBuffer,
-- the actual preprocessed source, maybe.
ml_hi_file :: FilePath,
-- Where the .hi file is, whether or not it exists
-- yet. Always of form foo.hi, even if there is an
......@@ -81,18 +73,6 @@ data ModLocation
instance Outputable ModLocation where
ppr = text . show
-- Rather a gruesome function to have in Module
showModMsg :: Bool -> Module -> ModLocation -> String
showModMsg use_object mod location =
mod_str ++ replicate (max 0 (16 - length mod_str)) ' '
++" ( " ++ expectJust "showModMsg" (ml_hs_file location) ++ ", "
++ (if use_object
then ml_obj_file location
else "interpreted")
++ " )"
where mod_str = moduleUserString mod
\end{code}
For a module in another package, the hs_file and obj_file
......@@ -103,6 +83,23 @@ correspond to actual files yet: for example, even if the object
file doesn't exist, the ModLocation still contains the path to
where the object file will reside if/when it is created.
\begin{code}
addBootSuffix :: FilePath -> FilePath
-- Add the "-boot" suffix to .hs, .hi and .o files
addBootSuffix path = path ++ "-boot"
addBootSuffix_maybe :: Bool -> FilePath -> FilePath
addBootSuffix_maybe is_boot path
| is_boot = addBootSuffix path
| otherwise = path
addBootSuffixLocn :: ModLocation -> ModLocation
addBootSuffixLocn locn
= locn { ml_hs_file = fmap addBootSuffix (ml_hs_file locn)
, ml_hi_file = addBootSuffix (ml_hi_file locn)
, ml_obj_file = addBootSuffix (ml_obj_file locn) }
\end{code}
%************************************************************************
%* *
......@@ -188,7 +185,9 @@ lookupModuleEnv :: ModuleEnv a -> Module -> Maybe a
lookupWithDefaultModuleEnv :: ModuleEnv a -> a -> Module -> a
elemModuleEnv :: Module -> ModuleEnv a -> Bool
foldModuleEnv :: (a -> b -> b) -> b -> ModuleEnv a -> b
filterModuleEnv :: (a -> Bool) -> ModuleEnv a -> ModuleEnv a
filterModuleEnv = filterUFM
elemModuleEnv = elemUFM
extendModuleEnv = addToUFM
extendModuleEnv_C = addToUFM_C
......
\begin{code}
module Module where
data Module
\end{code}
\begin{code}
module Name where
data Name
\end{code}
\begin{code}
module OccName where
data OccName
\end{code}
\begin{code}
module CgBindery where
import VarEnv( IdEnv )
data CgIdInfo
data VolatileLoc
data StableLoc
type CgBindings = IdEnv CgIdInfo
nukeVolatileBinds :: CgBindings -> CgBindings
\end{code}
\ No newline at end of file
\begin{code}
module CgExpr where
import StgSyn( StgExpr )
import CgMonad( Code )
cgExpr :: StgExpr -> Code
\end{code}
\begin{code}
module ClosureInfo where
data LambdaFormInfo
data ClosureInfo
\end{code}
\ No newline at end of file
This diff is collapsed.
......@@ -9,6 +9,7 @@ module Desugar ( deSugar, deSugarExpr ) where
#include "HsVersions.h"
import CmdLineOpts ( DynFlag(..), DynFlags(..), dopt, opt_SccProfilingOn )
import DriverPhases ( isHsBoot )
import HscTypes ( ModGuts(..), ModGuts, HscEnv(..), GhciMode(..),
Dependencies(..), TypeEnv, IsBootInterface )
import HsSyn ( RuleDecl(..), RuleBndr(..), HsExpr(..), LHsExpr,
......@@ -59,6 +60,7 @@ deSugar :: HscEnv -> TcGblEnv -> IO (Bag WarnMsg, Maybe ModGuts)
deSugar hsc_env
tcg_env@(TcGblEnv { tcg_mod = mod,
tcg_src = hsc_src,
tcg_type_env = type_env,
tcg_imports = imports,
tcg_exports = exports,
......@@ -146,6 +148,7 @@ deSugar hsc_env
mod_guts = ModGuts {
mg_module = mod,
mg_boot = isHsBoot hsc_src,
mg_exports = exports,
mg_deps = deps,
mg_usages = usages,
......
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