summaryrefslogtreecommitdiff
path: root/compiler/GHC
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-03-29 16:17:27 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-04-01 00:40:07 -0400
commit29326979eeb887e97f18bdc7852bb33a5b437362 (patch)
treee6dfb5c24aa4dd786399a0a601cac9d87c39d269 /compiler/GHC
parent751b21448c8894f603d1a3848ef5f51e7e80b3fe (diff)
downloadhaskell-29326979eeb887e97f18bdc7852bb33a5b437362.tar.gz
Properly initialise UnitEnv
Diffstat (limited to 'compiler/GHC')
-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
}
-- -----------------------------------------------------------------------------