summaryrefslogtreecommitdiff
path: root/compiler/main
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/main')
-rw-r--r--compiler/main/DriverPipeline.hs10
-rw-r--r--compiler/main/HscTypes.lhs12
2 files changed, 18 insertions, 4 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 483e5c8f59..08420efde6 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -371,7 +371,7 @@ linkingNeeded dflags linkables pkg_deps = do
| Just c <- map (lookupPackage pkg_map) pkg_deps,
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
e_lib_times <- mapM (tryIO . getModificationUTCTime)
(catMaybes pkg_libfiles)
@@ -408,9 +408,11 @@ ghcLinkInfoSectionName :: String
ghcLinkInfoSectionName = ".debug-ghc-link-info"
-- if we use the ".debug" prefix, then strip will strip it by default
-findHSLib :: [String] -> String -> IO (Maybe FilePath)
-findHSLib dirs lib = do
- let batch_lib_file = "lib" ++ lib <.> "a"
+findHSLib :: DynFlags -> [String] -> String -> IO (Maybe FilePath)
+findHSLib dflags dirs lib = do
+ 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)
case found of
[] -> return Nothing
diff --git a/compiler/main/HscTypes.lhs b/compiler/main/HscTypes.lhs
index 7c1f169440..ec5f6ee792 100644
--- a/compiler/main/HscTypes.lhs
+++ b/compiler/main/HscTypes.lhs
@@ -37,6 +37,8 @@ module HscTypes (
PackageInstEnv, PackageRuleBase,
+ mkSOName,
+
-- * Annotations
prepareAnnotations,
@@ -157,6 +159,7 @@ import Fingerprint
import MonadUtils
import Bag
import ErrUtils
+import Platform
import Util
import Control.Monad ( mplus, guard, liftM, when )
@@ -1778,6 +1781,15 @@ type OrigNameCache = ModuleEnv (OccEnv Name)
\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}
+
%************************************************************************
%* *