Hi Simon,

Attached is a simple code change to allow packages to specify a
different list of "extra libraries" to link with when using the ghci and
dlopen/LoadLibrary compared to when using the native system linker.

This shouldn't be a very commonly used feature and it probably doesn't
need to be well advertised since in general we'd rather people didn't
make distinctions between ghc and ghci.

But it should allow solutions to a couple problems people run into when
using foreign libs and ghci. One common problem is that libs like
pthread are not real libs on glibc systems. They are gnu linker scripts.
Obviously they work in the native linker case and not when one tries to
dlopen them.

The other problem I've found is that Gtk+ on Win32 has names for
it's .dll files that do not exactly match the .a names. (They have some
versioning scheme which involves appending "-0" to the name.) The native
linker has no problem with this because the .a/.lib files internally
point to the appropriate .dll file to use. But of course ghci cannot
know that. So at the moment we can have Gtk2Hs package files that works
for ghc or ghci but not both at the same time.

So the patch; I hope I'm picking the right place to put this feature in.
I guess hs-plugins will need patching separately? Or will it use this
code path too?

If you think this is the right approach then I'll finish off the patch
by extending the InstalledPackageInfo data type and the parser
appropriately.

Duncan
New patches:

[Use extraGHCiLibraries over extraLibraries for GHCi
Duncan Coutts <[EMAIL PROTECTED]>**20051130121139] {
hunk ./ghc/compiler/ghci/Linker.lhs 759
-        let libs      =  Packages.hsLibraries pkg ++ Packages.extraLibraries 
pkg
-                               ++ [ lib | '-':'l':lib <- Packages.ldOptions 
pkg ]
+        let libs      =  Packages.hsLibraries pkg
+       -- Because of slight differences between the GHC dynamic linker and
+       -- the native system linker some packages have to link with a
+       -- different list of libraries when using GHCi. Examples include: libs
+       -- that are actually gnu ld scripts, and the possability that the .a
+       -- libs do not exactly match the .so/.dll equivalents. So if the
+       -- package file provides an "extra-ghci-libraries" field then we use
+       -- that instead of the "extra-libraries" field.
+                     ++ (if null Packages.extraGHCiLibraries pkg
+                           then Packages.extraLibraries pkg
+                           else Packages.extraGHCiLibraries pkg)
+                     ++ [ lib | '-':'l':lib <- Packages.ldOptions pkg ]
}

Context:

[TAG Initial conversion from CVS complete
John Goerzen <[EMAIL PROTECTED]>**20051130033234] 
Patch bundle hash:
5ae55ed08f84890fb02a24255a36c53c0c2e7f8e
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to