X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fghci%2FLinker.lhs;h=eaf452199eb1e7c38fd902e0d7e30ebd48a4ea22;hp=cc90cb57020084c2d86bff1f49622c1992768883;hb=16b9e80dc14db24509f051f294b5b51943285090;hpb=5e54b553bbb112167412ee9164135d56b06f5721 diff --git a/compiler/ghci/Linker.lhs b/compiler/ghci/Linker.lhs index cc90cb5..eaf4521 100644 --- a/compiler/ghci/Linker.lhs +++ b/compiler/ghci/Linker.lhs @@ -245,11 +245,18 @@ dataConInfoPtrToName x = do where (modWords, occWord) = ASSERT (length rest1 > 0) (parseModOcc [] (tail rest1)) parseModOcc :: [[Word8]] -> [Word8] -> ([[Word8]], [Word8]) - parseModOcc acc str + -- We only look for dots if str could start with a module name, + -- i.e. if it starts with an upper case character. + -- Otherwise we might think that "X.:->" is the module name in + -- "X.:->.+", whereas actually "X" is the module name and + -- ":->.+" is a constructor name. + parseModOcc acc str@(c : _) + | isUpper $ chr $ fromIntegral c = case break (== dot) str of (top, []) -> (acc, top) - (top, _:bot) -> parseModOcc (top : acc) bot - + (top, _ : bot) -> parseModOcc (top : acc) bot + parseModOcc acc str = (acc, str) + -- | Get the 'HValue' associated with the given name. -- -- May cause loading the module that contains the name. @@ -1105,42 +1112,32 @@ loadFrameworks pkg -- If it isn't present, we assume it's a dynamic library. locateOneObj :: [FilePath] -> String -> IO LibrarySpec locateOneObj dirs lib + | not ("HS" `isPrefixOf` lib) + -- For non-Haskell libraries (e.g. gmp, iconv) we assume dynamic library + = assumeDll | not isDynamicGhcLib - -- When the GHC package was not compiled as dynamic library - -- (=DYNAMIC not set), we search for .o libraries. - = do mb_libSpec <- if cUseArchivesForGhci - then do mb_arch_path <- findFile mk_arch_path dirs - case mb_arch_path of - Just arch_path -> - return (Just (Archive arch_path)) - Nothing -> - return Nothing - else do mb_obj_path <- findFile mk_obj_path dirs - case mb_obj_path of - Just obj_path -> - return (Just (Object obj_path)) - Nothing -> - return Nothing - case mb_libSpec of - Just ls -> return ls - Nothing -> return (DLL lib) - + -- When the GHC package was not compiled as dynamic library + -- (=DYNAMIC not set), we search for .o libraries or, if they + -- don't exist, .a libraries. + = findObject `orElse` findArchive `orElse` assumeDll | otherwise -- When the GHC package was compiled as dynamic library (=DYNAMIC set), -- we search for .so libraries first. - = do { mb_lib_path <- findFile mk_dyn_lib_path dirs - ; case mb_lib_path of - Just _ -> return (DLL dyn_lib_name) - Nothing -> - do { mb_obj_path <- findFile mk_obj_path dirs - ; case mb_obj_path of - Just obj_path -> return (Object obj_path) - Nothing -> return (DLL lib) }} -- We assume + = findDll `orElse` findObject `orElse` findArchive `orElse` assumeDll where mk_obj_path dir = dir (lib <.> "o") mk_arch_path dir = dir ("lib" ++ lib <.> "a") dyn_lib_name = lib ++ "-ghc" ++ cProjectVersion mk_dyn_lib_path dir = dir mkSOName dyn_lib_name + findObject = liftM (fmap Object) $ findFile mk_obj_path dirs + findArchive = liftM (fmap Archive) $ findFile mk_arch_path dirs + findDll = liftM (fmap DLL) $ findFile mk_dyn_lib_path dirs + assumeDll = return (DLL lib) + infixr `orElse` + f `orElse` g = do m <- f + case m of + Just x -> return x + Nothing -> g -- ---------------------------------------------------------------------------- -- Loading a dyanmic library (dlopen()-ish on Unix, LoadLibrary-ish on Win32)