From 6e5a247c3646033180925e99d230c17d2730e773 Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Mon, 7 Mar 2022 13:56:53 +0000 Subject: Remove partOfGhci check in the loader This special logic has been part of GHC ever since template haskell was introduced in 9af77fa423926fbda946b31e174173d0ec5ebac8. It's hard to believe in any case that this special logic pays its way at all. Given * The list is out-of-date, which has potential to lead to miscompilation when using "editline", which was removed in 2010 (46aed8a4). * The performance benefit seems negligable as each load only happens once anyway and packages specified by package flags are preloaded into the linker state at the start of compilation. Therefore we just remove this logic. Fixes #19791 --- compiler/GHC/Linker/Loader.hs | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/compiler/GHC/Linker/Loader.hs b/compiler/GHC/Linker/Loader.hs index 7ac5fffab1..8db50f0180 100644 --- a/compiler/GHC/Linker/Loader.hs +++ b/compiler/GHC/Linker/Loader.hs @@ -69,9 +69,6 @@ import GHC.Types.Unique.DFM import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Panic.Plain -#if defined(CAN_LOAD_DLL) -import GHC.Utils.Constants (isWindowsHost, isDarwinHost) -#endif import GHC.Utils.Error import GHC.Utils.Logger import GHC.Utils.TmpFs @@ -1295,23 +1292,6 @@ unload_wkr interp keep_linkables pls@LoaderState{..} = do -- letting go of them (plus of course depopulating -- the symbol table which is done in the main body) --- If this package is already part of the GHCi binary, we'll already --- have the right DLLs for this package loaded, so don't try to --- load them again. --- --- But on Win32 we must load them 'again'; doing so is a harmless no-op --- as far as the loader is concerned, but it does initialise the list --- of DLL handles that rts/Linker.c maintains, and that in turn is --- used by lookupSymbol. So we must call addDLL for each library --- just to get the DLL handle into the list. -#if defined(CAN_LOAD_DLL) -partOfGHCi :: [PackageName] -partOfGHCi - | isWindowsHost || isDarwinHost = [] - | otherwise = map (PackageName . mkFastString) - ["base", "template-haskell", "editline"] -#endif - showLS :: LibrarySpec -> String showLS (Objects nms) = "(static) [" ++ intercalate ", " nms ++ "]" showLS (Archive nm) = "(static archive) " ++ nm @@ -1429,16 +1409,14 @@ loadPackage interp hsc_env pkg maybePutSDoc logger (text "Loading unit " <> pprUnitInfoForUser pkg <> text " ... ") - -- See comments with partOfGHCi #if defined(CAN_LOAD_DLL) - when (unitPackageName pkg `notElem` partOfGHCi) $ do - loadFrameworks interp platform pkg - -- See Note [Crash early load_dyn and locateLib] - -- Crash early if can't load any of `known_dlls` - mapM_ (load_dyn interp hsc_env True) known_dlls - -- For remaining `dlls` crash early only when there is surely - -- no package's DLL around ... (not is_dyn) - mapM_ (load_dyn interp hsc_env (not is_dyn) . platformSOName platform) dlls + loadFrameworks interp platform pkg + -- See Note [Crash early load_dyn and locateLib] + -- Crash early if can't load any of `known_dlls` + mapM_ (load_dyn interp hsc_env True) known_dlls + -- For remaining `dlls` crash early only when there is surely + -- no package's DLL around ... (not is_dyn) + mapM_ (load_dyn interp hsc_env (not is_dyn) . platformSOName platform) dlls #endif -- After loading all the DLLs, we can load the static objects. -- Ordering isn't important here, because we do one final link -- cgit v1.2.1