Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,413
    • Issues 5,413
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 602
    • Merge requests 602
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #21078
Closed
Open
Issue created Feb 14, 2022 by Sylvain Henry@hsyl20Developer3 of 14 checklist items completed3/14 checklist items

Add JavaScript backend

Giving GHC a proper JavaScript backend has been discussed before (#7496 (closed), #7933 (closed)) but it has never been done. We propose to do it by adapting code from GHCJS. Maintaining GHCJS out of GHC's tree is a lot of work that isn't sustainable. Moreover having a proper JS backend in GHC would make the compiler much easier to setup for end users and to maintain/enhance for GHC(JS) devs.

GHCJS's code currently relies on GHC 8.10 branch and there are several things that need to be adapted or removed. E.g. shims (JS code to replace C code) should be upstreamed in hackage libraries, we don't need to use GHC's hooks anymore, plugin support should be properly added (#20964 (closed), #14335), etc.

Hence we plan to add features one by one as if we were implementing the backend from scratch, except that we will copy/adapt a lot of code from GHCJS so the process should be faster and we already know that GHCJS's code works.

  • Wiki page: https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend
  • most up-to-date GHCJS branch: https://github.com/ghcjs/ghc/tree/ghc-8.10-ghcjs
    • status: https://github.com/ghcjs/ghc/blob/ghc-8.10-ghcjs/README.GHCJS.md
  • green GHCJS testsuite work: https://gitlab.haskell.org/ghc/ghc/-/commits/wip/jdm/ghcjs-testsuite/

TODO for 9.6:

  • Adapt GHCJS code into a new JS backend
  • Make testsuite green
  • Add CI job for the JS backend #22128 (closed)
  • Merge JS backend into main branch

TODO later:

  • fix boot libraries that use C sources (reimplement in Haskell, in JS, or wait for C sources support via Emscripten)
  • Reimplement GHCJS optimizations:
    • compactor #22352
    • JS code optimizer (peephole optimization)
  • Implement HPC support
  • Better documentation of the internals
  • Reimplement "inline Javascript" feature of GHCJS that was done via custom FFI import syntax
  • Implement support for C sources via an adapter for Emscripten generated code #22367
  • Support foreign exports (async/sync)
  • Support Template Haskell with external interpreter

Our team at IOG is committed to do this but any help and feedback is appreciated.

Edited Dec 19, 2022 by Sylvain Henry
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking