Skip to content

Instantly share code, notes, and snippets.

@mpickering
Last active December 23, 2021 14:53
Show Gist options
  • Save mpickering/c2a839fd6754fa76fdb6dc638f88638c to your computer and use it in GitHub Desktop.
Save mpickering/c2a839fd6754fa76fdb6dc638f88638c to your computer and use it in GitHub Desktop.
Backport instructions
stage1.*.ghc.hs.opts += -finfo-table-map -fdistinct-constructor-tables
stage1.ghc-bin.ghc.link.opts += -eventlog

These instructions will tell you how to build 8.10.2 with the -hi, -finfo-table-map and -fdistinct-constructor-tables patch backported.

GHC Branch: https://gitlab.haskell.org/mpickering/ghc/-/commits/ghc-con-info-backport

Building GHC

  1. mkdir _build, Copy the hadrian.settings file into _build.
  2. git submodule update --init
  3. perl boot
  4. ./configure
  5. ./hadrian/build.cabal.sh -j4

You will now have an instrumented version of GHC which has support for the -hi mode, -finfo-table-map and -fdistinct-constructor-tables flags.

Building graphql-engine

  1. Modify the cabal.project file in the package * stanza to build dependencies with -finfo-table-map and -fdistinct-constructor-tables.
  2. Modify graphql-engine.cabal by adding -eventlog to ghc-options.
  3. Remove specific 8.10.2 bounds from cabal.project.freeze.
  4. Modify RUN_INVOCATION to pass -hi -l-au
  5. Start server normally, the resulting eventlog ends up in the server/ directory.

Viewing the profile

If you wish to view the profile, use eventlog2html. This is still very rough so it might not be so easy to understand what's going on.

https://github.com/mpickering/eventlog2html/tree/wip/profile-info-table

@jberryman
Copy link

Building GHC worked for me, after switching to 8.6.5, thanks!

@jberryman
Copy link

Built graphql-engine successfully. I just added the following lines to cabal.project but I assume changing the path should work fine too:

with-compiler: /path/to/ghc/_build/stage1/bin/ghc
with-hc-pkg: /path/to/ghc/_build/stage1/bin/ghc-pkg

@m4dc4p
Copy link

m4dc4p commented Apr 23, 2021

Do the same instructions (and branch) apply if you want to do this with GHC 8.10.4? For example, would attempting to merge con-info-backport to the ghc-8.10 be one way?

In any case, thanks so much for putting this together!

@mpickering
Copy link
Author

@m4c4p You can try rebasing I suppose? I don't think the backport is based on exactly the 8.10.2 commit.

@m4dc4p
Copy link

m4dc4p commented Apr 26, 2021

After adding your fork as a remote (git remote add mpickering https://gitlab.haskell.org/mpickering/ghc), I was able to merge this branch into ghc's 8.10 branch and build successfully. Thanks for the great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment