| ... |
... |
@@ -214,7 +214,6 @@ findImportedModuleNoHsc fc fopts ue complete_home_units mb_home_unit mod_name mb |
|
214
|
214
|
| otherwise -> pprPanic "findImportModule" (ppr mod_name $$ ppr mb_pkg $$ ppr (homeUnitId <$> mb_home_unit) $$ ppr uid $$ ppr (map fst all_opts))
|
|
215
|
215
|
OtherPkg _ -> pkg_import
|
|
216
|
216
|
where
|
|
217
|
|
- cached_module_providers = M.findWithDefault Set.empty mod_name (cu_providers complete_home_units)
|
|
218
|
217
|
mb_home_unit_id = homeUnitId <$> mb_home_unit
|
|
219
|
218
|
all_opts = case mb_home_unit_id of
|
|
220
|
219
|
Nothing -> other_fopts
|
| ... |
... |
@@ -249,42 +248,42 @@ findImportedModuleNoHsc fc fopts ue complete_home_units mb_home_unit mod_name mb |
|
249
|
248
|
units = case mb_home_unit_id of
|
|
250
|
249
|
Nothing -> ue_homeUnitState ue
|
|
251
|
250
|
Just home_unit_id -> HUG.homeUnitEnv_units $ ue_findHomeUnitEnv home_unit_id ue
|
|
|
251
|
+
|
|
252
|
252
|
hpt_deps :: Set.Set UnitId
|
|
253
|
253
|
hpt_deps = homeUnitDepends units
|
|
|
254
|
+
|
|
|
255
|
+ -- TODO: this predicate is wrong, we need something more focused
|
|
|
256
|
+ sorted_deps = case finder_lookupHomeInterfaces fopts of
|
|
|
257
|
+ True -> Set.toList hpt_deps
|
|
|
258
|
+ False -> sortHomeUnitsByLikelihoodFor complete_home_units mb_home_unit_id mod_name hpt_deps
|
|
|
259
|
+
|
|
|
260
|
+ other_fopts =
|
|
|
261
|
+ [ (uid, initFinderOpts (homeUnitEnv_dflags (ue_findHomeUnitEnv uid ue)))
|
|
|
262
|
+ | uid <- sorted_deps
|
|
|
263
|
+ ]
|
|
|
264
|
+
|
|
|
265
|
+sortHomeUnitsByLikelihoodFor :: CompleteUnits -> Maybe UnitId -> ModuleName -> Set.Set UnitId -> [UnitId]
|
|
|
266
|
+sortHomeUnitsByLikelihoodFor complete_home_units mb_home_unit_id mod_name hpt_deps =
|
|
|
267
|
+ let
|
|
|
268
|
+ cached_module_providers = M.findWithDefault Set.empty mod_name (cu_providers complete_home_units)
|
|
254
|
269
|
cached_providing_deps = Set.intersection cached_module_providers hpt_deps
|
|
255
|
270
|
other_cached_providing_deps =
|
|
256
|
271
|
Set.toList $
|
|
257
|
272
|
maybe cached_providing_deps (\u -> Set.delete u cached_providing_deps) mb_home_unit_id
|
|
258
|
273
|
uncached_providing_deps =
|
|
259
|
|
- let candidates = Set.difference hpt_deps (cu_inventory complete_home_units)
|
|
|
274
|
+ let candidates = Set.difference hpt_deps cached_module_providers
|
|
260
|
275
|
excluded = maybe cached_providing_deps (\u -> Set.insert u cached_providing_deps) mb_home_unit_id
|
|
261
|
276
|
in Set.toList (Set.difference candidates excluded)
|
|
262
|
|
- other_providing_deps = other_cached_providing_deps ++ uncached_providing_deps
|
|
263
|
|
- other_fopts =
|
|
264
|
|
- [ (uid, initFinderOpts (homeUnitEnv_dflags (ue_findHomeUnitEnv uid ue)))
|
|
265
|
|
- | uid <- other_providing_deps
|
|
266
|
|
- ]
|
|
267
|
277
|
|
|
268
|
|
- !() = pprTrace "findImportedModuleNoHsc" (vcat lines) () where
|
|
269
|
|
-
|
|
270
|
|
- lines = [
|
|
271
|
|
- -- text "complete_home_units" <+> ppr complete_home_units,
|
|
272
|
|
- -- text "mb_home_unit " <+> ppr mb_home_unit,
|
|
273
|
|
- text "mod_name:" <+> ppr mod_name,
|
|
274
|
|
- text "cached_module_providers:" <+> ppr cached_module_providers,
|
|
275
|
|
- text "mb_home_unit_id:" <+> ppr mb_home_unit_id,
|
|
276
|
|
- -- text "all_opts:" <+> ppr all_opts,
|
|
277
|
|
- -- text "any_home_import:" <+> ppr any_home_import,
|
|
278
|
|
- -- text "pkg_import:" <+> ppr pkg_import ,
|
|
279
|
|
- -- text "unqual_import:" <+> ppr unqual_import,
|
|
280
|
|
- -- text "units:" <+> ppr units ,
|
|
281
|
|
- text "hpt_deps:" <+> ppr hpt_deps,
|
|
282
|
|
- text "cached_providing_deps:" <+> ppr cached_providing_deps,
|
|
283
|
|
- text "other_cached_providing_deps:" <+> ppr other_cached_providing_deps,
|
|
284
|
|
- text "uncached_providing_deps:" <+> ppr uncached_providing_deps,
|
|
285
|
|
- text "other_providing_deps:" <+> ppr other_providing_deps
|
|
286
|
|
- -- text "other_fopts:" <+> ppr other_fopts
|
|
287
|
|
- ]
|
|
|
278
|
+ all_deps = other_cached_providing_deps ++ uncached_providing_deps
|
|
|
279
|
+ in
|
|
|
280
|
+ assertPpr
|
|
|
281
|
+ (hpt_deps == Set.fromList all_deps)
|
|
|
282
|
+ ( text "Sorting must not remove HomeUnits"
|
|
|
283
|
+ $$ text "Module:" <+> ppr mod_name
|
|
|
284
|
+ $$ text "Original:" <+> ppr hpt_deps
|
|
|
285
|
+ $$ text "Sorted: " <+> ppr (Set.fromList all_deps))
|
|
|
286
|
+ all_deps
|
|
288
|
287
|
|
|
289
|
288
|
-- | Locate a plugin module requested by the user, for a compiler
|
|
290
|
289
|
-- plugin. This consults the same set of exposed packages as
|