# RFC: Introduce a serialisable bytecode format and corresponding "bytecode" way

**URL:** <https://discourse.haskell.org/t/rfc-introduce-a-serialisable-bytecode-format-and-corresponding-bytecode-way/12678>\
**Category:** Uncategorized\
**Created:** [August 11, 2025, 1:39pm UTC](https://discourse.haskell.org/t/rfc-introduce-a-serialisable-bytecode-format-and-corresponding-bytecode-way/12678 "2025-08-11T13:39:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpickering](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mpickering/32/4585_2.png) [@mpickering](https://discourse.haskell.org/u/mpickering)\
**Post date:** [August 11, 2025, 1:39pm UTC](https://discourse.haskell.org/t/rfc-introduce-a-serialisable-bytecode-format-and-corresponding-bytecode-way/12678/1 "2025-08-11T13:39:55Z")

</div>

We are planning on adding a new “bytecode” way, to enable the persisting and packaging of bytecode artifacts. At this stage it would be useful to gather feedback from any interested parties on the proposed interface for the [design](https://gitlab.haskell.org/ghc/ghc/-/issues/26298).

Please leave comments on this thread or on the [GHC tracking ticket](https://gitlab.haskell.org/ghc/ghc/-/issues/26298) if you have any questions or suggestions.

> GHC’s bytecode interpreter is widely used in GHCi and for Template Haskell evaluation with (`-fprefer-bytecode`), but until now it has only ever generated transient, in-memory bytecode. Every time you load a module in GHCi, the bytecode is regenerated from source.
> 
> The primary advantage of making bytecode into a persistable artifact is allowing caching of bytecode for REPL and tooling use.
> 
> This is not intended to replace native code for production executables, native code remains faster for runtime performance, but rather to extend GHC’s capabilities where fast build times, portability, and tooling integration are more important than peak execution speed

---

<div class="post-metadata">

**Author:** ![mpickering](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mpickering/32/4585_2.png) [@mpickering](https://discourse.haskell.org/u/mpickering)\
**Post date:** [August 26, 2025, 12:57pm UTC](https://discourse.haskell.org/t/rfc-introduce-a-serialisable-bytecode-format-and-corresponding-bytecode-way/12678/2 "2025-08-26T12:57:50Z")

</div>

A cabal proposal for that side of the work: [Support for bytecode files and libraries by mpickering · Pull Request #2 · haskell/cabal-proposals · GitHub](https://github.com/haskell/cabal-proposals/pull/2)

---

<div class="post-metadata">

**Author:** ![Kleidukos](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/kleidukos/32/1213_2.png) [@Kleidukos](https://discourse.haskell.org/u/Kleidukos)\
**Post date:** [August 26, 2025, 1:24pm UTC](https://discourse.haskell.org/t/rfc-introduce-a-serialisable-bytecode-format-and-corresponding-bytecode-way/12678/3 "2025-08-26T13:24:36Z")

</div>

Thanks for pursuing this work. I may not know much in the way of compiler design but I do know that it’s going to be a fantastic thing to have.

---

<div class="post-metadata">

**Author:** ![mpickering](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mpickering/32/4585_2.png) [@mpickering](https://discourse.haskell.org/u/mpickering)\
**Post date:** [November 10, 2025, 10:18am UTC](https://discourse.haskell.org/t/rfc-introduce-a-serialisable-bytecode-format-and-corresponding-bytecode-way/12678/4 "2025-11-10T10:18:02Z")

</div>

The cabal-proposal has been accepted after a period of discussion. 🎉

> <https://github.com/haskell/cabal-proposals/pull/2>
>
> This proposal describes extensions to \`Cabal\` and \`cabal-install\` to support bui…lding, installing, and managing persistent bytecode artifacts (\`.gbc\` files) and bytecode libraries alongside native code for faster development workflows.
> 
> \* \[GHC #26298\](https://gitlab.haskell.org/ghc/ghc/-/issues/26298)
> \* \[Cabal #11188\](https://github.com/haskell/cabal/issues/11188)
> \* Discourse post: \[RFC: Introduce a serialisable bytecode format and corresponding bytecode way\](https://discourse.haskell.org/t/rfc-introduce-a-serialisable-bytecode-format-and-corresponding-bytecode-way/12678)
> 
> \[Rendered\](https://github.com/haskell/cabal-proposals/blob/wip/bytecode-options/proposals/bytecode-files.md)

---

<div class="post-metadata">

**Author:** ![mpickering](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mpickering/32/4585_2.png) [@mpickering](https://discourse.haskell.org/u/mpickering)\
**Post date:** [November 24, 2025, 10:35am UTC](https://discourse.haskell.org/t/rfc-introduce-a-serialisable-bytecode-format-and-corresponding-bytecode-way/12678/5 "2025-11-24T10:35:51Z")

</div>

The GHC patch to implement bytecode library support is entering the final stages of review. Please leave any comments there if you have thoughts about bytecode libraries.

> **[driver: Add support for building and using bytecode libraries (!15062) ·...](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/15062)**
>
> This patch contains two separate commits. Add the -bytecodelib flag, to produce a bytecode library. Support loading bytecode libraries to satisfy package dependencies...
