[GHC] #13237: Extend TH with addModCStub
GHC
ghc-devs at haskell.org
Wed Feb 8 17:18:51 UTC 2017
#13237: Extend TH with addModCStub
-------------------------------------+-------------------------------------
Reporter: | Owner:
facundo.dominguez | facundo.dominguez
Type: feature request | Status: patch
Priority: normal | Milestone: 8.2.1
Component: Template Haskell | Version: 8.0.1
Resolution: | Keywords: inline-c
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3106
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by mboes):
To clarify the context, a solution to this feature would lift a long
standing usability problem for inline-c. That package generates C code,
which then has to be linked with all the other object code from a project.
Since GHC doesn't know about this, we have to lie to Cabal by listing the
generated C file as an extra source file.
But that's a very gross hack. Only meant to work around the fact that GHC
has no direct support for appending arbitrary object code to the output of
the current compilation unit. But in essence, what inline-c is doing is no
different from what GHC already needs to do in when compiling modules with
foreign exports or foreign import wrappers: it creates C stubs whose
object code must be included with the rest of the object code for the
module.
There are now at least a dozen open source libraries that depend on
inline-c, and likely many more closed source ones. But the current hack
explained above causes problems: listing a generated file as a source file
tends to confuse GHC's and Stack's recompilation checking. Worse, in some
cases the generated C source file causes the build to fail. More details
here: https://github.com/fpco/inline-c/issues/21.
Being able to programmatically register C stubs in the current compilation
unit would solve both problems at once.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13237#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list