Commit d1c8731a authored by ian@well-typed.com's avatar ian@well-typed.com

Fix the recompilation check for dynamic libraries

I've put mkSOName in HscTypes for now; I'm not sure what the best place
for it is.
parent 30b08711
...@@ -1185,13 +1185,6 @@ searchForLibUsingGcc dflags so dirs = do ...@@ -1185,13 +1185,6 @@ searchForLibUsingGcc dflags so dirs = do
-- ---------------------------------------------------------------------------- -- ----------------------------------------------------------------------------
-- Loading a dyanmic library (dlopen()-ish on Unix, LoadLibrary-ish on Win32) -- Loading a dyanmic library (dlopen()-ish on Unix, LoadLibrary-ish on Win32)
mkSOName :: Platform -> FilePath -> FilePath
mkSOName platform root
= case platformOS platform of
OSDarwin -> ("lib" ++ root) <.> "dylib"
OSMinGW32 -> root <.> "dll"
_ -> ("lib" ++ root) <.> "so"
-- Darwin / MacOS X only: load a framework -- Darwin / MacOS X only: load a framework
-- a framework is a dynamic library packaged inside a directory of the same -- a framework is a dynamic library packaged inside a directory of the same
-- name. They are searched for in different paths than normal libraries. -- name. They are searched for in different paths than normal libraries.
......
...@@ -371,7 +371,7 @@ linkingNeeded dflags linkables pkg_deps = do ...@@ -371,7 +371,7 @@ linkingNeeded dflags linkables pkg_deps = do
| Just c <- map (lookupPackage pkg_map) pkg_deps, | Just c <- map (lookupPackage pkg_map) pkg_deps,
lib <- packageHsLibs dflags c ] lib <- packageHsLibs dflags c ]
pkg_libfiles <- mapM (uncurry findHSLib) pkg_hslibs pkg_libfiles <- mapM (uncurry (findHSLib dflags)) pkg_hslibs
if any isNothing pkg_libfiles then return True else do if any isNothing pkg_libfiles then return True else do
e_lib_times <- mapM (tryIO . getModificationUTCTime) e_lib_times <- mapM (tryIO . getModificationUTCTime)
(catMaybes pkg_libfiles) (catMaybes pkg_libfiles)
...@@ -408,9 +408,11 @@ ghcLinkInfoSectionName :: String ...@@ -408,9 +408,11 @@ ghcLinkInfoSectionName :: String
ghcLinkInfoSectionName = ".debug-ghc-link-info" ghcLinkInfoSectionName = ".debug-ghc-link-info"
-- if we use the ".debug" prefix, then strip will strip it by default -- if we use the ".debug" prefix, then strip will strip it by default
findHSLib :: [String] -> String -> IO (Maybe FilePath) findHSLib :: DynFlags -> [String] -> String -> IO (Maybe FilePath)
findHSLib dirs lib = do findHSLib dflags dirs lib = do
let batch_lib_file = "lib" ++ lib <.> "a" let batch_lib_file = if dopt Opt_Static dflags
then "lib" ++ lib <.> "a"
else mkSOName (targetPlatform dflags) lib
found <- filterM doesFileExist (map (</> batch_lib_file) dirs) found <- filterM doesFileExist (map (</> batch_lib_file) dirs)
case found of case found of
[] -> return Nothing [] -> return Nothing
......
...@@ -37,6 +37,8 @@ module HscTypes ( ...@@ -37,6 +37,8 @@ module HscTypes (
PackageInstEnv, PackageRuleBase, PackageInstEnv, PackageRuleBase,
mkSOName,
-- * Annotations -- * Annotations
prepareAnnotations, prepareAnnotations,
...@@ -157,6 +159,7 @@ import Fingerprint ...@@ -157,6 +159,7 @@ import Fingerprint
import MonadUtils import MonadUtils
import Bag import Bag
import ErrUtils import ErrUtils
import Platform
import Util import Util
import Control.Monad ( mplus, guard, liftM, when ) import Control.Monad ( mplus, guard, liftM, when )
...@@ -1778,6 +1781,15 @@ type OrigNameCache = ModuleEnv (OccEnv Name) ...@@ -1778,6 +1781,15 @@ type OrigNameCache = ModuleEnv (OccEnv Name)
\end{code} \end{code}
\begin{code}
mkSOName :: Platform -> FilePath -> FilePath
mkSOName platform root
= case platformOS platform of
OSDarwin -> ("lib" ++ root) <.> "dylib"
OSMinGW32 -> root <.> "dll"
_ -> ("lib" ++ root) <.> "so"
\end{code}
%************************************************************************ %************************************************************************
%* * %* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment