[GHC] #14298: Let Template Haskell dynamically add a library against which to link

GHC ghc-devs at haskell.org
Fri Sep 29 17:02:56 UTC 2017


#14298: Let Template Haskell dynamically add a library against which to link
-------------------------------------+-------------------------------------
           Reporter:  harpocrates    |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Template       |           Version:  8.2.1
  Haskell                            |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 As of today, Template Haskell supports emitting foreign files (for C
 compiler languages) via `addForeignFile`. In doing so, GHC takes on the
 work of compiling these, linking against them, and then cleaning up any
 other files.

 This makes packages like `inline-c`
 ([https://hackage.haskell.org/package/inline-c]) possible, where you can
 write C snippets in quasiquotes and these can interact with your Haskell
 code. The user doesn't need to pass extra options to GHC (except to enable
 the right language extensions), and they don't have to see any of the
 intermediate generated artifacts.

 Unfortunately, that breaks down for non C compiler languages. It would be
 nice for TH to also support directly adding a static library, since then
 one could

   * use TH's `runIO` to generate static libraries by calling out to
 whatever other compilers
   * add the contents of those libraries via TH
   * delete the temporary files created in the process (again using
 `runIO`)
   * have GHC statically link against the content (from the second bullet
 point)

 I'm not sure what the API for this could be, but maybe adding a
 `StaticLibrary` constructor to the `ForeignSrcLang` data type (so one
 could use `addForeignFile :: ForeignSrcLang -> String -> Q ()`)?

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14298>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list