[Git][ghc/ghc][wip/T25965] 3 commits: driver: Use ModuleGraph for oneshot and --make mode

Simon Peyton Jones pushed to branch wip/T25965 at Glasgow Haskell Compiler / GHC Commits: d47bf776 by Matthew Pickering at 2025-04-14T16:44:41+01:00 driver: Use ModuleGraph for oneshot and --make mode This patch uses the `hsc_mod_graph` field for both oneshot and --make mode. Therefore, if part of the compiler requires usage of the module graph, you do so in a uniform way for the two different modes. The `ModuleGraph` describes the relationship between the modules in the home package and units in external packages. The `ModuleGraph` can be queried when information about the transitive closure of a package is needed. For example, the primary use of the ModuleGraph from within the compiler is in the loader, which needs to know the transitive closure of a module so it can load all the relevant objects for evaluation. In --make mode, downsweep computes the ModuleGraph before any compilation starts. In oneshot mode, a thunk is created at the start of compilation, which when forced will compute the module graph beneath the current module. The thunk is only forced at the moment when the user uses Template Haskell. Finally, there are some situations where we need to discover what dependencies to load but haven't loaded a module graph at all. In this case, there is a fallback which computes the transitive closure on the fly and doesn't cache the result. Presumably if you are going to call getLinkDeps a lot, you would compute the right ModuleGraph before you started. Importantly, this removes the ExternalModuleGraph abstraction. This was quite awkward to work with since it stored information about the home package inside the EPS. This patch will also be very useful when implementing explicit level imports, which requires more significant use of the module graph in order to determine which level instances are available at. Towards #25795 ------------------------- Metric Decrease: MultiLayerModulesTH_Make MultiLayerModulesTH_OneShot ------------------------- - - - - - 395e0ad1 by sheaf at 2025-04-16T12:33:26-04:00 base: remove .Internal modules (e.g. GHC.TypeLits) This commit removes the following internal modules from base, as per CLC proposal 217: - GHC.TypeNats.Internal - GHC.TypeLits.Internal - GHC.ExecutionStack.Internal Fixes #25007 - - - - - 15201e7e by Simon Peyton Jones at 2025-04-16T23:00:04+01:00 Fix infelicities in the Specialiser On the way to #23109 (unary classes) I discovered some infelicities (or maybe tiny bugs, I forget) in the type-class specialiser. I also tripped over #25965, an outright bug in the rule matcher Specifically: * I enhanced `wantCallsFor`, whih previously always said `True`, to discard calls of class-ops, data constructors etc. This is a bit more efficient; and it means we don't need to worry about filtering them out later. * I tidied up some tricky logic that eliminated redundant specialisations. It wasn't working correctly. See the expanded Note [Specialisations already covered], and (MP3) in Note [Specialising polymorphic dictionaries]. And the new top-level `alreadyCovered` function, which now goes via `GHC.Core.Rules.ruleLhsIsMoreSpecific` I also added a useful Note [The (CI-KEY) invariant] * I fixed a tricky bug in the `go_fam_fam` in `GHC.Core.Unify.uVarOrFam`, which allows matching to succeed without binding all type varibles. This caused #25965. I enhanced Note [Apartness and type families] some more - - - - - 42 changed files: - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Driver/Downsweep.hs - compiler/GHC/Driver/Env.hs - compiler/GHC/Driver/Env/Types.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Errors/Types.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/MakeAction.hs - + compiler/GHC/Driver/Messager.hs - compiler/GHC/Driver/Pipeline.hs-boot - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Linker/Deps.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Runtime/Loader.hs - compiler/GHC/Tc/Solver/Equality.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Unit/External.hs - compiler/GHC/Unit/Finder.hs - − compiler/GHC/Unit/Module/External/Graph.hs - compiler/GHC/Unit/Module/Graph.hs - compiler/GHC/Unit/Module/ModNodeKey.hs - compiler/ghc.cabal.in - libraries/base/base.cabal.in - libraries/base/changelog.md - − libraries/base/src/GHC/ExecutionStack/Internal.hs - − libraries/base/src/GHC/TypeLits/Internal.hs - − libraries/base/src/GHC/TypeNats/Internal.hs - + testsuite/tests/ghc-api/fixed-nodes/InterfaceModuleGraph.hs - + testsuite/tests/ghc-api/fixed-nodes/InterfaceModuleGraph.stdout - testsuite/tests/ghc-api/fixed-nodes/all.T - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - testsuite/tests/plugins/defaulting-plugin/DefaultLifted.hs - + testsuite/tests/simplCore/should_compile/T25965.hs - testsuite/tests/simplCore/should_compile/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8c5dd598bba0307638c50f3d0b2e7a5... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8c5dd598bba0307638c50f3d0b2e7a5... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Simon Peyton Jones (@simonpj)