We’re happy to support the Haskell Foundation in planning a workshop for new GHC contributors on 7th-9th June. Workshop registration has now closed, but you can still register to attend ZuriHac on 10th-12th June!

This is the seventeenth 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 February and March 2023. You can find the previous editions collected under the ghc-activities-report tag.

We are delighted that Hasura have recently started sponsoring our GHC maintenance work, building on our long-running collaboration on Haskell tooling. Many thanks to them and to the other sponsors, Juspay and GitHub via the Haskell Foundation. In addition, Mercury are funding specific work on improved performance for GHC, HLS and related projects. We are also grateful to our past sponsors, including Microsoft Research and IOG.

However, some of our sponsorship agreements are coming to an end and we need more sponsorship to sustain the team! If your company might be able to contribute funding to ensure that we can continue this valuable work, please read about how you can help or 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 existing GHC team consists of Ben Gamari, Andreas Klebinger, Matthew Pickering, Zubin Duggal, Sam Derbyshire and Rodrigo Mesquita. Many others within Well-Typed are contributing to GHC more occasionally.

Releases

  • Ben released GHC 9.6.1, the first major release in the 9.6 series, having previously prepared several alphas and the release candidate.

  • Zubin released GHC 9.2.6 and GHC 9.2.7, bugfix releases in the 9.2 series.

Parser

  • Sam and Adam ensured that the changes to overloaded labels from GHC proposal 170 didn’t steal syntax by preventing the . character from appearing in labels. This avoids a breaking change that was discovered in the 9.6 alphas.

Typechecker and renamer

  • Sam completed a significant overhaul of the treatment of duplicate record fields in the renamer and typechecker.

    Some highlights:

    • Template Haskell support for duplicate record fields.
    • Improve disambiguation of record updates involving sum types (#21443).
    • Stop displaying mangled field names such as $sel:MkD:fld to the user.

    Fixed tickets: #13352, #14848, #17381, #17551, #19664, #21443, #21444, #21720, #21898, #21946, #21959, #22125, #22160, #22424, #23010, #23062, #23063 and #23177.

  • Sam introduced a warning when users rely on a certain constraint solver bug involving expansion of superclass constraints (!9921 !10020). This was done to introduce a migration cycle, so that people have the time to update their programs, based on feedback from the 9.6 alphas.

  • Sam fixed a small bug with type variable scoping in SPECIALISE pragmas (#22913).

  • Sam identified and fixed a missing type-synonym expansion in the typechecker (#22985).

  • Rodrigo fixed a bug in which strictness annotations in Template Haskell quotes could be dropped (#23036).

Error messages and warnings

  • Adam implemented GHC proposal 541, which allows users to assign custom warning categories to WARNING pragmas, for example:

    {-# WARNING in "x-partial" head "This is a partial function...." #-}

    With this change, it became possible to attach custom warnings to head/tail which can be silenced selectively. This allowed completion of CLC proposal 87 and CLC proposal 114.

  • Matt migrated error messages related to interface loading to the new diagnostic-based infrastructure (!10135).

  • Sam reviewed and assisted other contributors with several contributions migrating error messages to the new diagnostic infrastructure.

  • Rodrigo stopped ghci’s own Prelude import from annoyingly triggering the missing-import-lists warning.

Primops

  • Sam updated a few pointer equality operations, such as sameMutableArray#, sameMutVar# and eqStableName#, to be levity-polymorphic (!9976).

Code generation

  • Andreas fixed a tag inference bug for the bytecode interpreter (#22840).

  • Ben improved the code generation of bitmasks on AArch64 by precisely checking whether a value is a bitmask immediate (#23030).

  • Ben improved code generation for atomic read and writes on AArch64, by using in-line primops (#22115).

  • Zubin fixed a bug in which multiline-comments were incorrectly handled in the AArch64 native code generator (#23002).

Debug information

  • In an ongoing quest to reduce the size of compiler results containing debug information, Finley implemented compression of info-table provenance entry map data (!9893). With this feature, -finfo-table-map enabled build results are roughly 20% smaller in size.

Runtime system

  • Ben fixed a bug in the alignment of capabilities, fixing the segfault reported in #22965.

  • Ben has been working to track down a variety of memory ordering issues uncovered by newer AArch64 implementations (#23185, #22872, #23222).

  • Ben inserted write barriers for IND and IND_STATIC info tables. The fact that these were missing caused segfaults seen in #22872.

Garbage collector

  • Ben fixed a plethora of bugs in the non-moving garbage collector, in particular refactoring the treatment of weak pointers. He also reduced maximum pause times during synchronisation. See !9609.

    Fixed bugs: #22327, #22926, #22927, #22929, #22930, and #22931.

  • Ben prevented slop from being zeroed when using the non-moving garbage collector, as this could cause races (#23170).

Runtime performance

  • Matthew and Andreas investigated various regressions that were reported in the text and bytestring packages. They discovered:

    • That patches to use sub-word sized instructions, such as using eqWord8# on Word8s instead of extending to Word before comparing, were regressing performance due to partial register stalls (see e.g. #20405). Reverting those patches recovered the original performance characteristics.

    • That the inlining of join points can introduce heap checks in hot code paths, as described in #22936. The patch which made GHC more eager to inline certain join points was reverted.

    • That knock-on inlining differences caused by recent changes to the GHC.Unicode module were causing regressions in functions such as toUpper. Adding a NOINLINE pragma to a certain large function (!9958) resolved the issue.

Packaging

  • Ben bumped the win32-tarballs submodule, alleviating certain ABI incompatibility issues resulting from the move to a Clang toolchain in GHC 9.4.

  • Matthew fixed some inconsistencies in version numbers in the documentation generated by Hadrian (#23121).

Testsuite & CI

  • Ben and Rodrigo made a few tests more consistent by ensuring that handles are flushed at the correct point.

GHC build system

  • Ben stopped Hadrian from unnecessarily packaging the lib/settings file (#20253, #22982).

  • Ben fixed an issue where running ./configure twice on MacOS could cause strange errors in FIND_CXX_STD_LIB (#23116).

  • Rodrigo and Matthew worked towards plugin loading soundness by giving GHC a proper unit-id and making Hadrian add hashes to package IDs (#20742, !10119)

head.hackage

  • Ben worked on improving reliability of head.hackage, as several spurious failures had been triggered by cabal suddenly finding different build plans after a package was updated on hackage.

    This included adding a freeze file to freeze the Hackage index state, as well as introducing extra constraints to avoid ever including certain outdated packages in a build plan.

  • Ben continued work in moving head.hackage to use the foliage tool for Hackage repository generation. This work will both simplify head.hackage’s infrastructure and allow the repository to be frozen with cabal’s index-state field.

GHC Proposals

  • Adam drafted several GHC proposals:

    • GHC proposal 579 modifies the format of proposals and their evaluation criteria to make backwards compatibility a more explicit concern.

    • GHC proposal 581 extends ExplicitNamespaces, building on a previous design by others.

    • GHC proposal 583 proposes changes to the HasField class used for overloaded record fields, to unblock the implementation of OverloadedRecordUpdate.