On Fri, 2005-12-02 at 11:06 +0000, Simon Marlow wrote:
> On 30 November 2005 12:29, Duncan Coutts wrote:
> 
> > 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. 
> 
> Yes to the idea in principle; please go ahead and complete the patch.

Ok, attached is the full patch. It has to be in two parts since the
darcs repos for ghc and the libraries are separate.

I've briefly tested the change. I built Gtk2Hs with ghc-6.5 with the
patch. I modified (and registered) the gtk.package.conf file so that it
specified:

extra-libraries: "gtk-x11-2.0", [...snip...], "pthread"
extra-ghci-libraries: "gtk-x11-2.0", [...snip...]

Then building an executable with ghc-6.5 --make worked fine and using -v
showed that in the link phase it was indeed specifying -lpthread.

Then loading ghci-6.5 -package gtk worked too. Previously we'd expect
this to fail if we specified "pthread" in extra-libraries since on Linux
the pthread library is actually a GNU ld script.

Then just to double check I set the package file as:

extra-libraries: "gtk-x11-2.0", [...snip...], "pthread"
extra-ghci-libraries: "gtk-x11-2.0", [...snip...], "pthread"

and indeed in that case we get back the situation where loading pthread
fails:

Loading package gtk-0.9.10.1 ... ghc-6.5: can't load .so/.DLL for:
pthread (/usr/lib/libpthread.so: invalid ELF header)

So I think I've covered everything, registering using ghc-pkg works when
extra-ghci-libraries is specified and ghc/ghci seem to be doing the
right thing with it.

The patches are against ghc-HEAD (or the darcs mirror thereof). It'd be
great if this could also be applied to the ghc-6.4-branch so that it
makes it into ghc-6.4.2 since this would allow us to get Gtk2Hs working
with GHCi on Windows (where we have the problem that the Gtk+ *.a and
*.dll names do not exactly match).

Duncan
New patches:

[Use extraGHCiLibraries (if supplied) in GHCi linker rather than extraLibraries
Duncan Coutts <[EMAIL PROTECTED]>**20051207105654
 Also extend the parser.
] {
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 ]
hunk ./ghc/compiler/main/ParsePkgConf.y 85
+                       "extraGHCiLibraries"-> p{extraGHCiLibraries= $3}
}

Context:

[[project @ 2005-12-02 15:16:08 by simonmar]
simonmar**20051202151608
 remove one mention of hslibs
] 
[[project @ 2005-12-02 14:22:06 by simonmar]
simonmar**20051202142206
 - remove hslibs link
 - add Building Guide link
 - remove the word "hierarchical" from "hierarchical libraries"
] 
[[project @ 2005-12-02 14:09:21 by simonmar]
simonmar**20051202140921
 revert rev. 1.22 again, just in case this is the cause of the
 segfaults reported on OpenBSD and SuSE.
] 
[[project @ 2005-12-02 12:45:16 by simonmar]
simonmar**20051202124516
 Fix Windows build
 
 Patch submitted by: Esa Ilari Vuokko <eivuokko at gmail.com>
] 
[[project @ 2005-11-30 16:56:51 by simonmar]
simonmar**20051130165651
 fix bug in the case of an uncaught exception
] 
[[project @ 2005-11-30 15:58:47 by simonmar]
simonmar**20051130155847
 check for overrun of the fd_set, some OSs give you more descriptors
 than FD_SETSIZE
] 
[[project @ 2005-11-30 14:20:06 by simonpj]
simonpj**20051130142006
 -----------------------------------------
        Fix 'mkName' operator in Template Haskell
        so that it handles built-in syntax
        -----------------------------------------
 
        Merge to stable branch
 
 The 'mkName' function in Template Haskell wasn't dealing correctly with
 built-in syntax.  The parser generates Exact RdrNames for built-in syntax
 operators, such as ':' and '[]'; and hence so should Convert.
 
 At the same time I'm now generating a better error message in TH when
 you use a constructor as a variable or vice versa.
] 
[.hi is now boring
John Goerzen <[EMAIL PROTECTED]>**20051130185834] 
[TAG Last state before ghc 6.4 branch split
John Goerzen <[EMAIL PROTECTED]>**20051130171550] 
[Removed more obsolete dirs
John Goerzen <[EMAIL PROTECTED]>**20051130171526] 
[Removed obsolete directories
John Goerzen <[EMAIL PROTECTED]>**20051130171453] 
[TAG Initial conversion from CVS complete
John Goerzen <[EMAIL PROTECTED]>**20051130033234] 
Patch bundle hash:
d1ad237b15072c3a4d19a39df98a06c836b05f7f
New patches:

[Add extraGHCiLibraries to the InstalledPackageInfo and extend the parser.
Duncan Coutts <[EMAIL PROTECTED]>**20051207105621] {
hunk ./Cabal/Distribution/InstalledPackageInfo.hs 97
+       extraGHCiLibraries:: [String],    -- overrides extraLibraries for GHCi
hunk ./Cabal/Distribution/InstalledPackageInfo.hs 131
+        extraGHCiLibraries= [],
hunk ./Cabal/Distribution/InstalledPackageInfo.hs 252
+ , listField   "extra-ghci-libraries"
+       showToken          parseTokenQ
+       extraGHCiLibraries (\xs pkg -> pkg{extraGHCiLibraries=xs})
}

Context:

[[project @ 2005-12-02 14:29:28 by simonmar]
simonmar**20051202142928
 avoid recursive module trap with Haddock
] 
[[project @ 2005-12-02 12:26:22 by simonmar]
simonmar**20051202122622
 Apply rev 1.24 from FreeBSD's copy of this file.  Commit message from
 FreeBSD:
 
    The algorithm that computes the tables used in the BM search
    algorithm sometimes access an array beyond it's length. This only
    happens in the last iteration of a loop, and the value fetched is
    not used then, so the bug is a relatively innocent one. Fix this by
    not fetching any value on the last iteration of said loop.
 
    Submitted by:       MKI <[EMAIL PROTECTED]>
 
 This is the cause of bug #1194393 (crash in darcs on Windows).
] 
[[project @ 2005-12-02 12:09:08 by malcolm]
malcolm**20051202120908
 Fix for parsing empty lists.
] 
[[project @ 2005-12-02 11:37:50 by malcolm]
malcolm**20051202113750
 Extra instances of Show.
] 
[[project @ 2005-12-02 11:21:32 by malcolm]
malcolm**20051202112132
 wibbles
] 
[[project @ 2005-12-01 17:55:58 by malcolm]
malcolm**20051201175558
 Improve contentspec pare error messages.
] 
[[project @ 2005-12-01 17:47:30 by malcolm]
malcolm**20051201174730
 Commit to error inside mixed content spec.
] 
[[project @ 2005-12-01 16:54:53 by malcolm]
malcolm**20051201165453
 update docs ready for another unstable release.
] 
[[project @ 2005-12-01 16:53:59 by malcolm]
malcolm**20051201165359
 formatting wibble
] 
[[project @ 2005-12-01 16:30:16 by malcolm]
malcolm**20051201163016
 Avoid confusing haddock.
] 
[[project @ 2005-12-01 16:22:11 by malcolm]
malcolm**20051201162211
 List missing file, update version num.
] 
[[project @ 2005-12-01 12:37:23 by simonmar]
simonmar**20051201123723
 oops, forgot to remove forkIO from here
] 
[[project @ 2005-12-01 12:32:24 by simonmar]
simonmar**20051201123224
 export childHandler
] 
[[project @ 2005-11-30 16:56:24 by simonmar]
simonmar**20051130165624
 - move forkIO into GHC.Conc, so that the I/O manager can use proper forkIO
   with an exception handler.  This required TopHandler.lhs-boot.  It's the
   right thing, though, since the forkIO implementation is GHC-specific.
 
 - check for out-of-range file descriptors in the I/O manager, rather than
   just exploding.  The I/O manager will exit ungracefully, but at least
   there will be an error message.
] 
[[project @ 2005-11-30 12:24:33 by simonmar]
simonmar**20051130122433
 export registerDelay
] 
[[project @ 2005-11-30 12:24:18 by simonmar]
simonmar**20051130122418
 Add
 
   registerDelay :: Int -> IO (TVar Bool)
 
 for implementing delays and timeouts in STM.  The delay is implemented
 in the same way as threadDelay.  Currently doesn't work on Windows or
 without -threaded (I do intend to make it work on Windows, though).
] 
[[project @ 2005-11-29 17:38:24 by malcolm]
malcolm**20051129173824
 Generated code requires fewer imports, and better whitespacing.
] 
[[project @ 2005-11-29 17:37:23 by malcolm]
malcolm**20051129173723
 New combinator 'optional'.
] 
[[project @ 2005-11-29 17:35:13 by malcolm]
malcolm**20051129173513
 Another fix for 'text' combinator.  When you find the end of the string,
 by discovering a tagged element, PUT THE ELEMENT BACK into the incoming
 token stream!  Otherwise it gets left out of the parsed sequence...
] 
[[project @ 2005-11-29 16:49:14 by malcolm]
malcolm**20051129164914
 Because 'text' might fail, we must wrap a definite required text item to
 permit it to return the empty string.
] 
[[project @ 2005-11-29 16:43:06 by malcolm]
malcolm**20051129164306
 The 'text' combinator should fail on empty input, rather than succeed
 with the empty string as result.  Otherwise, it cannot be used inside a
 choice combinator.
] 
[[project @ 2005-11-29 14:31:59 by ross]
ross**20051129143159
 As foreshadowed on the libraries list, introduce new classes:
 
 Applicative (formerly known as Idiom): generalizes (but does not replace)
 both Monad and Monoid.
 
 Traversable: containers that can be traversed, executing actions and
 re-assembling the results.  This class generalizes and replaces FunctorM,
 because it requires Applicative instead of Monad.
 
 Foldable: containers that can be folded over a Monoid.  Traversable
 supplies a default definition, but some structures, e.g. Set, are Foldable
 but not Traversable.
] 
[TAG Last common state before ghc-6-4-branch
John Goerzen <[EMAIL PROTECTED]>**20051128201854] 
[[project @ 2005-11-28 17:47:10 by malcolm]
malcolm**20051128174710
 Update DtdToHaskell to generate instances of the new XmlContent class.
 Generates compilable code, but still to be fully tested.
] 
[[project @ 2005-11-28 16:04:21 by panne]
panne**20051128160422
 Cleanly separated our representation of devices and contexts from OpenAL's.
 This makes it easier to attach some data later...
] 
[TAG Initial conversion from CVS complete
John Goerzen <[EMAIL PROTECTED]>**20051128200748] 
Patch bundle hash:
da741251b02029264a456aeca0d06a99f369c4fe
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to