summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/GHC/Driver/Main.hs4
-rw-r--r--compiler/GHC/Unit/Env.hs26
2 files changed, 25 insertions, 5 deletions
diff --git a/compiler/GHC/Driver/Main.hs b/compiler/GHC/Driver/Main.hs
index e25dfa7053..1650de05a7 100644
--- a/compiler/GHC/Driver/Main.hs
+++ b/compiler/GHC/Driver/Main.hs
@@ -168,6 +168,7 @@ import GHC.Cmm.Pipeline
import GHC.Cmm.Info
import GHC.Unit
+import GHC.Unit.Env
import GHC.Unit.Finder
import GHC.Unit.External
import GHC.Unit.State
@@ -247,6 +248,7 @@ newHscEnv dflags = do
fc_var <- initFinderCache
logger <- initLogger
tmpfs <- initTmpFs
+ unit_env <- initUnitEnv (ghcNameVersion dflags) (targetPlatform dflags)
-- FIXME: it's sad that we have so many "unitialized" fields filled with
-- empty stuff or lazy panics. We should have two kinds of HscEnv
-- (initialized or not) instead and less fields that are mutable over time.
@@ -261,7 +263,7 @@ newHscEnv dflags = do
, hsc_FC = fc_var
, hsc_type_env_var = Nothing
, hsc_interp = Nothing
- , hsc_unit_env = panic "hsc_unit_env not initialized"
+ , hsc_unit_env = unit_env
, hsc_plugins = []
, hsc_static_plugins = []
, hsc_unit_dbs = Nothing
diff --git a/compiler/GHC/Unit/Env.hs b/compiler/GHC/Unit/Env.hs
index d7de796434..565c6a8a8e 100644
--- a/compiler/GHC/Unit/Env.hs
+++ b/compiler/GHC/Unit/Env.hs
@@ -1,5 +1,6 @@
module GHC.Unit.Env
( UnitEnv (..)
+ , initUnitEnv
, preloadUnitsInfo
, preloadUnitsInfo'
)
@@ -14,12 +15,29 @@ import GHC.Unit.Types
import GHC.Platform
import GHC.Settings
import GHC.Data.Maybe
+import GHC.Utils.Panic.Plain
data UnitEnv = UnitEnv
- { ue_units :: !UnitState -- ^ Units
- , ue_home_unit :: !HomeUnit -- ^ Home unit
- , ue_platform :: !Platform -- ^ Platform
- , ue_namever :: !GhcNameVersion -- ^ GHC name/version (used for dynamic library suffix)
+ { ue_units :: !UnitState
+ -- ^ External units
+
+ , ue_home_unit :: !HomeUnit
+ -- ^ Home unit
+
+ , ue_platform :: !Platform
+ -- ^ Platform
+
+ , ue_namever :: !GhcNameVersion
+ -- ^ GHC name/version (used for dynamic library suffix)
+ }
+
+initUnitEnv :: GhcNameVersion -> Platform -> IO UnitEnv
+initUnitEnv namever platform = do
+ return $ UnitEnv
+ { ue_units = emptyUnitState
+ , ue_home_unit = panic "No home unit"
+ , ue_platform = platform
+ , ue_namever = namever
}
-- -----------------------------------------------------------------------------