Skip to content

Clean up how inline-java attaches bytecode to Haskell modules #205

@facundominguez

Description

@facundominguez

This post summarizes the current state of the code. It needs to be clarified how to deal with some changes to management of C stubs.


The CStub datatype was introduced in https://gitlab.haskell.org/ghc/ghc/-/commit/5beeff46972b8b52e9f2572fff8b1ad9ace38cd8

The commit has examples of adapting code in GHC as inline-java might need, for instance [link].

The motivating note for the change also [link] provides insight for the update.


I also explored how inline-c sends C code to the Haskell compiler. But adapting our use of the CStub type as above looks better.

It turns out that instead of using mg_foreign, we could be using mg_foreign_files. This is a field of ModGuts which has file paths of C files, which can be created in a temporary location as addTempFile does. From the GHC source code:

  qAddTempFile suffix = do
    dflags <- getDynFlags
    logger <- getLogger
    tmpfs  <- hsc_tmpfs <$> getTopEnv
    liftIO $ newTempName logger tmpfs (tmpDir dflags) TFL_GhcSession suffix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions