summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
2d9800c)
* Make it so that interface files track dependencies on
all modules except Prelude modules.
(Was "library" modules, distinguished by a gross hack
but that messed up StgHugs.)
, mkPrelModule -- :: UserString -> Module
, isDynamicModule -- :: Module -> Bool
, mkPrelModule -- :: UserString -> Module
, isDynamicModule -- :: Module -> Bool
, DllFlavour, dll, notDll
-- ModFlavour
, DllFlavour, dll, notDll
-- ModFlavour
- , ModFlavour, libMod, userMod
-- Where to find a .hi file
, WhereFrom(..), SearchPath, mkSearchPath
-- Where to find a .hi file
, WhereFrom(..), SearchPath, mkSearchPath
we don't record the fact that this module depends on it, nor usages of things
inside it.
we don't record the fact that this module depends on it, nor usages of things
inside it.
+Apr 00: We want to record dependencies on all modules other than
+prelude modules else STG Hugs gets confused because it uses this
+info to know what modules to link. (Compiled GHC uses command line
+options to specify this.)
+
-data ModFlavour = LibMod -- A library-ish module
+data ModFlavour = PrelMod -- A Prelude module
| UserMod -- Not library-ish
| UserMod -- Not library-ish
-
-libMod = LibMod
-userMod = UserMod
-- Haskell module names can include the quote character ',
-- so the module names have the z-encoding applied to them
-- Haskell module names can include the quote character ',
-- so the module names have the z-encoding applied to them
+isPrelModuleName :: ModuleName -> Bool
+ -- True for names of prelude modules
+isPrelModuleName m = take 4 (_UNPK_ m) == "Prel"
pprModuleName :: ModuleName -> SDoc
pprModuleName nm = pprEncodedFS nm
pprModuleName :: ModuleName -> SDoc
pprModuleName nm = pprEncodedFS nm
+mkModule :: FilePath -- Directory in which this module is
+ -> ModuleName -- Name of the module
+ -> DllFlavour
+ -> Module
+mkModule dir_path mod_nm is_dll
+ | isPrelModuleName mod_nm = mkPrelModule mod_nm
+ | otherwise = Module mod_nm UserMod is_dll
+ -- Make every module into a 'user module'
+ -- except those constructed by mkPrelModule
+
mkVanillaModule :: ModuleName -> Module
mkVanillaModule name = Module name UserMod dell
mkVanillaModule :: ModuleName -> Module
mkVanillaModule name = Module name UserMod dell
mkPrelModule name = Module name sys dll
where
sys | opt_CompilingPrelude = UserMod
mkPrelModule name = Module name sys dll
where
sys | opt_CompilingPrelude = UserMod
dll | opt_Static || opt_CompilingPrelude = NotDll
| otherwise = Dll
dll | opt_Static || opt_CompilingPrelude = NotDll
| otherwise = Dll
isDynamicModule (Module _ _ Dll) = True
isDynamicModule _ = False
isDynamicModule (Module _ _ Dll) = True
isDynamicModule _ = False
-isLibModule :: Module -> Bool
-isLibModule (Module _ LibMod _) = True
-isLibModule _ = False
+isPrelModule :: Module -> Bool
+isPrelModule (Module _ PrelMod _) = True
+isPrelModule _ = False
-
- is_sys | isLibraryPath dir_path = LibMod
- | otherwise = UserMod
-
- -- Dreadfully crude way to tell whether a module is a "library"
- -- module or not. The current story is simply that if path is
- -- absolute we treat it as a library. Specifically:
- -- /usr/lib/ghc/
- -- C:/usr/lib/ghc
- -- C:\user\lib
- isLibraryPath ('/' : _ ) = True
- isLibraryPath (_ : ':' : '/' : _) = True
- isLibraryPath (_ : ':' : '\\' : _) = True
- isLibraryPath other = False
-
xiffus = reverse dotted_suffix
dotted_suffix = case suffix of
[] -> []
xiffus = reverse dotted_suffix
dotted_suffix = case suffix of
[] -> []
add_hib file_nm = (hi_env, add_to_map addNewOne hib_env file_nm)
add_to_map combiner env file_nm
add_hib file_nm = (hi_env, add_to_map addNewOne hib_env file_nm)
add_to_map combiner env file_nm
- = addToFM_C combiner env mod_nm (path, mkModule mod_nm is_sys is_dll)
+ = addToFM_C combiner env mod_nm (path, mkModule dir_path mod_nm is_dll)
where
mod_nm = mkSrcModuleFS file_nm
where
mod_nm = mkSrcModuleFS file_nm
)
import TysWiredIn ( tupleTyCon, unboxedTupleTyCon, listTyCon )
import Type ( funTyCon )
)
import TysWiredIn ( tupleTyCon, unboxedTupleTyCon, listTyCon )
import Type ( funTyCon )
-import Module ( ModuleName, mkThisModule, mkVanillaModule, moduleName )
+import Module ( ModuleName, mkThisModule, moduleName )
import TyCon ( TyCon )
import FiniteMap
import Unique ( Unique, Uniquable(..) )
import TyCon ( TyCon )
import FiniteMap
import Unique ( Unique, Uniquable(..) )
mkImportedGlobalName :: ModuleName -> OccName -> RnM d Name
mkImportedGlobalName mod_name occ
= lookupModuleRn mod_name `thenRn` \ mod ->
mkImportedGlobalName :: ModuleName -> OccName -> RnM d Name
mkImportedGlobalName mod_name occ
= lookupModuleRn mod_name `thenRn` \ mod ->
- newImportedGlobalName mod_name occ mod --(mkVanillaModule mod_name)
+ newImportedGlobalName mod_name occ mod
mkImportedGlobalFromRdrName :: RdrName -> RnM d Name
mkImportedGlobalFromRdrName rdr_name
mkImportedGlobalFromRdrName :: RdrName -> RnM d Name
mkImportedGlobalFromRdrName rdr_name
)
import Module ( Module, moduleString, pprModule,
mkVanillaModule, pprModuleName,
)
import Module ( Module, moduleString, pprModule,
mkVanillaModule, pprModuleName,
- moduleUserString, moduleName, isLibModule,
+ moduleUserString, moduleName, isPrelModule,
ModuleName, WhereFrom(..),
)
import RdrName ( RdrName, rdrNameOcc )
ModuleName, WhereFrom(..),
)
import RdrName ( RdrName, rdrNameOcc )
addModDeps mod mod_deps new_deps
= foldr add mod_deps new_deps
where
addModDeps mod mod_deps new_deps
= foldr add mod_deps new_deps
where
- is_lib = isLibModule mod -- Don't record dependencies when importing a library module
+ is_lib = isPrelModule mod -- Don't record dependencies when importing a prelude module
add (imp_mod, version, has_orphans, is_boot, _) deps
| is_lib && not has_orphans = deps
| otherwise = addToFM_C combine deps imp_mod (version, has_orphans, is_boot, Nothing)
add (imp_mod, version, has_orphans, is_boot, _) deps
| is_lib && not has_orphans = deps
| otherwise = addToFM_C combine deps imp_mod (version, has_orphans, is_boot, Nothing)
-- but don't actually *use* anything from Foo
-- In which case record an empty dependency list
where
-- but don't actually *use* anything from Foo
-- In which case record an empty dependency list
where
- is_lib_module = isLibModule mod
+ is_lib_module = isPrelModule mod
(False, lookupFM hi_map mod_name)
| otherwise
(False, lookupFM hi_map mod_name)
| otherwise
- -- Check if there's a library module of that name
+ -- Check if there's a prelude module of that name
-- If not, look for an hi-boot file
= case lookupFM hi_map mod_name of
-- If not, look for an hi-boot file
= case lookupFM hi_map mod_name of
- stuff@(Just (_, mod)) | isLibModule mod -> (False, stuff)
- other -> (True, lookupFM hiboot_map mod_name)
+ stuff@(Just (_, mod)) | isPrelModule mod -> (False, stuff)
+ other -> (True, lookupFM hiboot_map mod_name)
trace_msg = sep [hsep [ptext SLIT("Reading"),
ppr from,
trace_msg = sep [hsep [ptext SLIT("Reading"),
ppr from,
<Para>
GHC <Emphasis>only</Emphasis> keeps detailed dependency information
<Para>
GHC <Emphasis>only</Emphasis> keeps detailed dependency information
-for “user” modules, not for “library” modules.
+for “user” modules, not for “Prelude” modules.
+It distinguishes Prelude modules because their names start with
+"Prel", so don't start your modules that way!
+
+<!-- April 2000: hack disabled. Now we use a different hack!
+
It distinguishes the two by a hack: a module whose
<Filename>.hi</Filename> file has an absolute path name is considered
a library module, while a relative path name indicates a user module.
It distinguishes the two by a hack: a module whose
<Filename>.hi</Filename> file has an absolute path name is considered
a library module, while a relative path name indicates a user module.
“<Filename>B:/</Filename>”,
“<Filename>B:\</Filename>” etc).
</Para>
“<Filename>B:/</Filename>”,
“<Filename>B:\</Filename>” etc).
</Para>
<Para>
Patrick Sansom had a workshop paper about how all this is done (though
<Para>
Patrick Sansom had a workshop paper about how all this is done (though