[GHC] #9656: Process and thread init/deinit hooks for C libraries
GHC
ghc-devs at haskell.org
Thu Oct 2 04:41:13 UTC 2014
#9656: Process and thread init/deinit hooks for C libraries
-------------------------------------+-------------------------------------
Reporter: 3noch | Owner:
Type: feature | Status: closed
request | Milestone:
Priority: normal | Version: 7.8.3
Component: Compiler | Keywords: FFI
Resolution: invalid | Architecture: Unknown/Multiple
Operating System: | Difficulty: Unknown
Unknown/Multiple | Blocked By:
Type of failure: | Related Tickets:
None/Unknown |
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by 3noch):
The mysql package punts on this issue because it uses the single-threaded
lib, so it can get away without calling most of the init/deinit functions
manually. One issue is that the main library init function is not thread
safe so must be called before any threads are created (or mutex
protected). In a C program, this is easily done by adding a few calls in
main. The trouble when connecting Haskell apps to these libraries is that
we don't have that kind of access to "main" and thus have to come up with
awkward APIs and monads, etc. to make sure everything happens properly. Of
course, as I said, it's possible to do this in user-land, its just painful
and makes Haskell less friendly in real-world scenarios where you want to
interop with stuff like this.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9656#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list