Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/d146fdbbf8941a8344f0ec300e79dbeabc08d1ea

>---------------------------------------------------------------

commit d146fdbbf8941a8344f0ec300e79dbeabc08d1ea
Author: Simon Marlow <[email protected]>
Date:   Wed Aug 3 09:39:48 2011 +0100

    Followup to #5289 changes: fix searching for dynamic libraries and use
    of the RTS addDLL() API on Windows.  When searching for DLLs we should
    include the .dll extension, but addDLL() takes a filename without the
    extension.

>---------------------------------------------------------------

 compiler/ghci/Linker.lhs  |    4 +---
 compiler/ghci/ObjLink.lhs |   19 +++++++++++++++++--
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/compiler/ghci/Linker.lhs b/compiler/ghci/Linker.lhs
index 63c68c5..747edde 100644
--- a/compiler/ghci/Linker.lhs
+++ b/compiler/ghci/Linker.lhs
@@ -1091,9 +1091,7 @@ searchForLibUsingGcc dflags so dirs = do
 mkSOName :: FilePath -> FilePath
 mkSOName root
  | isDarwinTarget  = ("lib" ++ root) <.> "dylib"
- | isWindowsTarget = -- Win32 DLLs have no .dll extension here, because
-                     -- addDLL tries both foo.dll and foo.drv
-                     root
+ | isWindowsTarget = root <.> "dll"
  | otherwise       = ("lib" ++ root) <.> "so"
 
 -- Darwin / MacOS X only: load a framework
diff --git a/compiler/ghci/ObjLink.lhs b/compiler/ghci/ObjLink.lhs
index cd593f7..f459145 100644
--- a/compiler/ghci/ObjLink.lhs
+++ b/compiler/ghci/ObjLink.lhs
@@ -23,6 +23,7 @@ module ObjLink (
 import Panic
 import BasicTypes      ( SuccessFlag, successIf )
 import Config          ( cLeadingUnderscore )
+import Util
 
 import Control.Monad    ( when )
 import Foreign.C
@@ -30,7 +31,7 @@ import Foreign                ( nullPtr )
 import GHC.Exts         ( Ptr(..) )
 import GHC.IO.Encoding  ( fileSystemEncoding )
 import qualified GHC.Foreign as GHC
-
+import System.FilePath  ( dropExtension )
 
 
 -- ---------------------------------------------------------------------------
@@ -62,10 +63,24 @@ prefixUnderscore
  | cLeadingUnderscore == "YES" = ('_':)
  | otherwise                   = id
 
+-- | loadDLL loads a dynamic library using the OS's native linker
+-- (i.e. dlopen() on Unix, LoadLibrary() on Windows).  It takes either
+-- an absolute pathname to the file, or a relative filename
+-- (e.g. "libfoo.so" or "foo.dll").  In the latter case, loadDLL
+-- searches the standard locations for the appropriate library.
+--
 loadDLL :: String -> IO (Maybe String)
 -- Nothing      => success
 -- Just err_msg => failure
-loadDLL str = do
+loadDLL str0 = do
+  let
+     -- On Windows, addDLL takes a filename without an extension, because
+     -- it tries adding both .dll and .drv.  To keep things uniform in the
+     -- layers above, loadDLL always takes a filename with an extension, and
+     -- we drop it here on Windows only.
+     str | isWindowsHost = dropExtension str0
+         | otherwise     = str0
+  --
   maybe_errmsg <- withFileCString str $ \dll -> c_addDLL dll
   if maybe_errmsg == nullPtr
        then return Nothing



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to