This is the fourteenth edition of our GHC activities report, which describes the work on GHC and related projects that we are doing at Well-Typed. The current edition covers roughly the months of August and September 2022. You can find the previous editions collected under the ghc-activities-report tag.

A bit of background: One aspect of our work at Well-Typed is to support GHC and the Haskell core infrastructure. Several companies, including IOHK and GitHub via the Haskell Foundation, are providing us with funding to do this work. We are also working with Hasura on better debugging tools and improvements to HLS. We are very grateful on behalf of the whole Haskell community for the support these companies provide.

If you are interested in also contributing funding to ensure we can continue or even scale up this kind of work, please get in touch.

Of course, GHC is a large community effort, and Well-Typed’s contributions are just a small part of this. This report does not aim to give an exhaustive picture of all GHC work that is ongoing, and there are many fantastic features currently being worked on that are omitted here simply because none of us are currently involved in them in any way. Furthermore, the aspects we do mention are still the work of many people. In many cases, we have just been helping with the last few steps of integration. We are immensely grateful to everyone contributing to GHC!

Team

The current GHC team consists of Ben Gamari, Andreas Klebinger, Matthew Pickering, Zubin Duggal and Sam Derbyshire. Many others within Well-Typed are contributing to GHC more occasionally.

Releases

  • August and September were quiet months due to holidays and now our attention is turning to the forthcoming 9.4.3, 9.2.5 releases and 9.6 branch.

  • Zubin has been preparing GHC 9.2.5 and backporting critical runtime performance fixes like #21755 to the branch.

Driver

  • Matt finished an extension to interface files which allows the whole core program to be stored in an interface file. This improves restart times of GHCi and can massively improve compilation times of projects involving many Template Haskell splices. (!7502)

  • Matt investigated a number of issues to do with interface file determinism and added some CI jobs to try to check that we are producing deterministic interfaces. (!8895)

Compiler performance

  • Andreas investigated the benefit of being less aggressive in pruning specializations in #18532, where it turned out the current behaviour is already optimal.

  • Andreas investigated GHC and core lint performance in #22200. This resulted in !9055 where a few key improvements improved compile times for builds using -dcore-lint by ~15% in the common case and ~30% in edge cases.

  • Matt did another round of space usage investigation and fixed a number of leaks in the simplifier. These changes are most obvious when compiling very large modules. The fixes focused on making sure we didn’t retain old bindings across simplifier passes. (#22102, !8896)

Typechecker

  • Sam improved how GHC picks Given quantified constraints when trying to solve a Wanted constraint, by picking the quantified constraint with the weakest precondition (if one exists). This fixes #22216 and #22223.

Error messages

  • Sam finalised and landed a patch adding error codes to error messages (!8849). All errors and warnings that GHC emits using the new diagnostic infrastructure now come with an associated unique code, e.g. error: [GHC-53633] Pattern match is redundant. These can then be used for looking up documentation, for example in the Haskell Error Index. This is part of a Haskell Foundation proposal.

Code generation

  • Andreas changed the tag inference pass to apply in a few more situations in !8747. In particular, code returning variables that are statically known to be properly tagged, as well as dataToTag, benefit from this change and will produce more efficient code.

  • Ben and Andreas fixed code generation bug #21968 which sometimes caused incorrect results when compiling without optimization.

  • Andreas fixed #22042 where GHC sometimes produced invalid bytecode inside GHCi.

  • Ben fixed a bug in code generation for intMulMayOflo# on AArch64 (#21624) and updated test-primops to exercise the affected codepath.

  • Ben fixed a bug in code generation on x86_64 (#21968) where under some conditions a switch discriminator could clobber a live value.

  • Ben fixed a bug in the LLVM code generator which would break GHC-generated initializers. (#22019)

Core-to-Core pipeline

  • Andreas investigated #21960 about regressions in the 9.2/9.4 point releases. They were tracked back to the simple fix for #21694. Simon Peyton Jones provided a more robust solution in !8862.

  • Andreas identified #22075 where GHC would sometimes enter a infinite loop while compiling a program involving recursive top level bindings which Simon Peyton Jones then fixed in !8905.

Runtime system

  • Ben fixed an bug in newArrayArray# in 9.2 where zero-sized arrays would integer underflow when initializing the card array. (#21962)
  • Ben continued work in teaching the runtime linker about constructor/deconstructor priorities, improving reliability of interoperation with C++ code. (#21947)
  • Ben diagnosed and fixed a bug in the nonmoving collector where objects could be inappropriately scavenged. (#21885)

Profiling

  • Ben reworked GHC’s handling of IPE information, significantly reducing the on-disk size and improving initialization efficiency. (!8868)

Libraries

  • Ben finished and merged his thread introspection branch, allowing user programs to enumerate the threads of a program and query the label, state, and stack of each. (!2816)
  • Ben reworked the exception provenance proposal and rewrote his prototype implementation.

Packaging

  • Ben fixed a number of packaging issues (#21901, #21965, #21713, #21974, #21506, #21956, #21988, #21976, #21974) and worked to improve CI to ensure that such regressions are caught in the future.

  • Matt fixed a number of packaging issues to do with Hackage documentation and added CI jobs which generate documentation suitable for upload to Hackage. (!8846, !8841)

Hadrian

  • Matt improved Hadrian build times by increasing the amount of parallelism available. On a full build the total time is 75% of the time before these patches. (!8879)
  • Sam made some improvements to Hadrian bootstrapping on Windows.

Infrastructure

  • Ben worked to fix various CI issues (#21986) and began work on testing cross-compilers under CI. (#21480)
  • Ben finished his work removing the make build system from GHC’s source tree, dropping over 10kLoC from the repository. (#17527)
  • Ben looked into the feasibility of notarizing macOS binary distributions. (#17418)