Put findLinkable in Finder.lhs, where it can be found in non-ghci stage1 compilers!
import Type ( tidyType )
import VarEnv ( emptyTidyEnv )
import BasicTypes ( Fixity, FixitySig(..), defaultFixity )
-import Linker ( HValue, unload, extendLinkEnv, findLinkable )
+import Linker ( HValue, unload, extendLinkEnv )
import GHC.Exts ( unsafeCoerce# )
import Foreign
import Control.Exception as Exception ( Exception, try )
{-# OPTIONS -optc-DNON_POSIX_SOURCE #-}
module Linker ( HValue, initLinker, showLinkerState,
- findLinkable,
linkLibraries, linkExpr,
unload, extendLinkEnv,
LibrarySpec(..)
import Packages ( PackageConfig(..), PackageName, PackageConfigMap, lookupPkg,
packageDependents, packageNameString )
import DriverState ( v_Library_paths, v_Cmdline_libraries, getPackageConfigMap )
-import DriverUtil ( splitFilename3 )
-import Finder ( findModule )
+import Finder ( findModule, findLinkable )
import HscTypes ( Linkable(..), isObjectLinkable, nameOfObject, byteCodeOfObject,
Unlinked(..), isInterpretable, isObject, Dependencies(..),
HscEnv(..), PersistentCompilerState(..), ExternalPackageState(..),
return (Just file_path)
else
findFile mk_file_path dirs }
-
-
-findLinkable :: ModuleName -> ModLocation -> IO (Maybe Linkable)
-findLinkable mod locn
- | Just obj_fn <- ml_obj_file locn
- = do obj_exist <- doesFileExist obj_fn
- if not obj_exist
- then return Nothing
- else
- do let stub_fn = case splitFilename3 obj_fn of
- (dir, base, ext) -> dir ++ "/" ++ base ++ ".stub_o"
- stub_exist <- doesFileExist stub_fn
- obj_time <- getModificationTime obj_fn
- if stub_exist
- then return (Just (LM obj_time mod [DotO obj_fn, DotO stub_fn]))
- else return (Just (LM obj_time mod [DotO obj_fn]))
- | otherwise
- = return Nothing
\end{code}
\begin{code}
mkHomeModLocation, -- :: ModuleName -> String -> FilePath
-- -> IO ModLocation
+ findLinkable, -- :: ModuleName -> ModLocation -> IO (Maybe Linkable)
+
hiBootExt, -- :: String
hiBootVerExt, -- :: String
import Module
import UniqFM ( filterUFM )
import Packages ( PackageConfig(..) )
+import HscTypes ( Linkable(..), Unlinked(..) )
import DriverState
-import DriverUtil ( split_longest_prefix )
+import DriverUtil ( split_longest_prefix, splitFilename3 )
import FastString
import Config
import Util
addToFinderCache mod_name result
return result
\end{code}
+
+-- -----------------------------------------------------------------------------
+-- findLinkable isn't related to the other stuff in here,
+-- but there' no other obvious place for it
+
+\begin{code}
+findLinkable :: ModuleName -> ModLocation -> IO (Maybe Linkable)
+findLinkable mod locn
+ | Just obj_fn <- ml_obj_file locn
+ = do obj_exist <- doesFileExist obj_fn
+ if not obj_exist
+ then return Nothing
+ else
+ do let stub_fn = case splitFilename3 obj_fn of
+ (dir, base, ext) -> dir ++ "/" ++ base ++ ".stub_o"
+ stub_exist <- doesFileExist stub_fn
+ obj_time <- getModificationTime obj_fn
+ if stub_exist
+ then return (Just (LM obj_time mod [DotO obj_fn, DotO stub_fn]))
+ else return (Just (LM obj_time mod [DotO obj_fn]))
+ | otherwise
+ = return Nothing
+\end{code}
\ No newline at end of file