
Matthew Pickering pushed to branch wip/splice-imports-2025 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 ------------------------- - - - - - 27516810 by Matthew Pickering at 2025-04-15T12:44:31+01:00 Explicit level imports 2024 - - - - - 218 changed files: - compiler/GHC.hs - compiler/GHC/Data/Graph/Directed/Reachability.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Downsweep.hs - compiler/GHC/Driver/DynFlags.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/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/MakeAction.hs - compiler/GHC/Driver/MakeFile.hs - + compiler/GHC/Driver/Messager.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline.hs-boot - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/Linker/Deps.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Header.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Runtime/Loader.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Plugin.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/Types.hs - compiler/GHC/Tc/Types/LclEnv.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Name/Reader.hs - compiler/GHC/Unit/External.hs - compiler/GHC/Unit/Finder.hs - compiler/GHC/Unit/Home/PackageTable.hs - compiler/GHC/Unit/Module/Deps.hs - compiler/GHC/Unit/Module/External/Graph.hs - compiler/GHC/Unit/Module/Graph.hs - compiler/GHC/Unit/Module/Imported.hs - compiler/GHC/Unit/Module/ModNodeKey.hs - compiler/GHC/Unit/Module/ModSummary.hs - + compiler/GHC/Unit/Module/Stage.hs - compiler/Language/Haskell/Syntax/ImpExp.hs - compiler/ghc.cabal.in - docs/users_guide/exts/template_haskell.rst - libraries/base/tests/IO/Makefile - libraries/ghc-internal/src/GHC/Internal/LanguageExtensions.hs - testsuite/tests/ado/ado004.stderr - testsuite/tests/annotations/should_fail/annfail03.stderr - testsuite/tests/annotations/should_fail/annfail04.stderr - testsuite/tests/annotations/should_fail/annfail06.stderr - testsuite/tests/annotations/should_fail/annfail09.stderr - testsuite/tests/count-deps/CountDepsParser.stdout - testsuite/tests/dependent/should_compile/T14729.stderr - testsuite/tests/dependent/should_compile/T15743.stderr - testsuite/tests/dependent/should_compile/T15743e.stderr - testsuite/tests/deriving/should_compile/T14682.stderr - testsuite/tests/determinism/determ021/determ021.stdout - testsuite/tests/driver/json2.stderr - testsuite/tests/gadt/T19847a.stderr - testsuite/tests/ghc-api/fixed-nodes/FixedNodes.hs - + testsuite/tests/ghc-api/fixed-nodes/InterfaceModuleGraph.hs - + testsuite/tests/ghc-api/fixed-nodes/InterfaceModuleGraph.stdout - testsuite/tests/ghc-api/fixed-nodes/ModuleGraphInvariants.hs - testsuite/tests/ghc-api/fixed-nodes/all.T - testsuite/tests/indexed-types/should_compile/T15711.stderr - testsuite/tests/indexed-types/should_compile/T15852.stderr - testsuite/tests/indexed-types/should_compile/T3017.stderr - testsuite/tests/interface-stability/template-haskell-exports.stdout - testsuite/tests/module/mod185.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/partial-sigs/should_compile/ADT.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr1.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr2.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr3.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr4.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr5.stderr - testsuite/tests/partial-sigs/should_compile/AddAndOr6.stderr - testsuite/tests/partial-sigs/should_compile/BoolToBool.stderr - testsuite/tests/partial-sigs/should_compile/DataFamilyInstanceLHS.stderr - testsuite/tests/partial-sigs/should_compile/Defaulting1MROn.stderr - testsuite/tests/partial-sigs/should_compile/Defaulting2MROff.stderr - testsuite/tests/partial-sigs/should_compile/Defaulting2MROn.stderr - testsuite/tests/partial-sigs/should_compile/Either.stderr - testsuite/tests/partial-sigs/should_compile/EqualityConstraint.stderr - testsuite/tests/partial-sigs/should_compile/Every.stderr - testsuite/tests/partial-sigs/should_compile/EveryNamed.stderr - testsuite/tests/partial-sigs/should_compile/ExpressionSig.stderr - testsuite/tests/partial-sigs/should_compile/ExpressionSigNamed.stderr - testsuite/tests/partial-sigs/should_compile/ExtraConstraints1.stderr - testsuite/tests/partial-sigs/should_compile/ExtraConstraints2.stderr - testsuite/tests/partial-sigs/should_compile/ExtraConstraints3.stderr - testsuite/tests/partial-sigs/should_compile/ExtraNumAMROff.stderr - testsuite/tests/partial-sigs/should_compile/ExtraNumAMROn.stderr - testsuite/tests/partial-sigs/should_compile/Forall1.stderr - testsuite/tests/partial-sigs/should_compile/GenNamed.stderr - testsuite/tests/partial-sigs/should_compile/HigherRank1.stderr - testsuite/tests/partial-sigs/should_compile/HigherRank2.stderr - testsuite/tests/partial-sigs/should_compile/LocalDefinitionBug.stderr - testsuite/tests/partial-sigs/should_compile/Meltdown.stderr - testsuite/tests/partial-sigs/should_compile/MonoLocalBinds.stderr - testsuite/tests/partial-sigs/should_compile/NamedTyVar.stderr - testsuite/tests/partial-sigs/should_compile/NamedWildcardInDataFamilyInstanceLHS.stderr - testsuite/tests/partial-sigs/should_compile/NamedWildcardInTypeFamilyInstanceLHS.stderr - testsuite/tests/partial-sigs/should_compile/ParensAroundContext.stderr - testsuite/tests/partial-sigs/should_compile/PatBind.stderr - testsuite/tests/partial-sigs/should_compile/PatBind2.stderr - testsuite/tests/partial-sigs/should_compile/PatternSig.stderr - testsuite/tests/partial-sigs/should_compile/Recursive.stderr - testsuite/tests/partial-sigs/should_compile/ScopedNamedWildcards.stderr - testsuite/tests/partial-sigs/should_compile/ScopedNamedWildcardsGood.stderr - testsuite/tests/partial-sigs/should_compile/ShowNamed.stderr - testsuite/tests/partial-sigs/should_compile/SimpleGen.stderr - testsuite/tests/partial-sigs/should_compile/SkipMany.stderr - testsuite/tests/partial-sigs/should_compile/SomethingShowable.stderr - testsuite/tests/partial-sigs/should_compile/TypeFamilyInstanceLHS.stderr - testsuite/tests/partial-sigs/should_compile/Uncurry.stderr - testsuite/tests/partial-sigs/should_compile/UncurryNamed.stderr - testsuite/tests/partial-sigs/should_compile/WarningWildcardInstantiations.stderr - testsuite/tests/plugins/defaulting-plugin/DefaultLifted.hs - testsuite/tests/polykinds/T15592.stderr - testsuite/tests/polykinds/T15592b.stderr - testsuite/tests/printer/T18052a.stderr - testsuite/tests/quasiquotation/qq001/qq001.stderr - testsuite/tests/quasiquotation/qq002/qq002.stderr - testsuite/tests/quasiquotation/qq003/qq003.stderr - testsuite/tests/quasiquotation/qq004/qq004.stderr - testsuite/tests/roles/should_compile/Roles1.stderr - testsuite/tests/roles/should_compile/Roles14.stderr - testsuite/tests/roles/should_compile/Roles2.stderr - testsuite/tests/roles/should_compile/Roles3.stderr - testsuite/tests/roles/should_compile/Roles4.stderr - testsuite/tests/roles/should_compile/T8958.stderr - testsuite/tests/showIface/DocsInHiFile1.stdout - testsuite/tests/showIface/DocsInHiFileTH.stdout - testsuite/tests/showIface/HaddockIssue849.stdout - testsuite/tests/showIface/HaddockOpts.stdout - testsuite/tests/showIface/HaddockSpanIssueT24378.stdout - testsuite/tests/showIface/LanguageExts.stdout - testsuite/tests/showIface/MagicHashInHaddocks.stdout - testsuite/tests/showIface/NoExportList.stdout - testsuite/tests/showIface/PragmaDocs.stdout - testsuite/tests/showIface/ReExports.stdout - + testsuite/tests/splice-imports/ClassA.hs - + testsuite/tests/splice-imports/InstanceA.hs - + testsuite/tests/splice-imports/Makefile - + testsuite/tests/splice-imports/SI01.hs - + testsuite/tests/splice-imports/SI01A.hs - + testsuite/tests/splice-imports/SI02.hs - + testsuite/tests/splice-imports/SI03.hs - + testsuite/tests/splice-imports/SI03.stderr - + testsuite/tests/splice-imports/SI04.hs - + testsuite/tests/splice-imports/SI05.hs - + testsuite/tests/splice-imports/SI05.stderr - + testsuite/tests/splice-imports/SI05A.hs - + testsuite/tests/splice-imports/SI06.hs - + testsuite/tests/splice-imports/SI07.hs - + testsuite/tests/splice-imports/SI07.stderr - + testsuite/tests/splice-imports/SI07A.hs - + testsuite/tests/splice-imports/SI08.hs - + testsuite/tests/splice-imports/SI08.stderr - + testsuite/tests/splice-imports/SI09.hs - + testsuite/tests/splice-imports/SI10.hs - + testsuite/tests/splice-imports/SI13.hs - + testsuite/tests/splice-imports/SI14.hs - + testsuite/tests/splice-imports/SI14.stderr - + testsuite/tests/splice-imports/SI15.hs - + testsuite/tests/splice-imports/SI15.stderr - + testsuite/tests/splice-imports/SI16.hs - + testsuite/tests/splice-imports/SI16.stderr - + testsuite/tests/splice-imports/SI17.hs - + testsuite/tests/splice-imports/SI18.hs - + testsuite/tests/splice-imports/SI18.stderr - + testsuite/tests/splice-imports/SI19.hs - + testsuite/tests/splice-imports/SI19A.hs - + testsuite/tests/splice-imports/SI20.hs - + testsuite/tests/splice-imports/SI21.hs - + testsuite/tests/splice-imports/SI21.stderr - + testsuite/tests/splice-imports/SI22.hs - + testsuite/tests/splice-imports/SI22.stderr - + testsuite/tests/splice-imports/SI23.hs - + testsuite/tests/splice-imports/SI23A.hs - + testsuite/tests/splice-imports/SI24.hs - + testsuite/tests/splice-imports/all.T - testsuite/tests/th/T16976z.stderr - testsuite/tests/th/T17820a.stderr - testsuite/tests/th/T17820b.stderr - testsuite/tests/th/T17820c.stderr - testsuite/tests/th/T17820d.stderr - testsuite/tests/th/T17820e.stderr - testsuite/tests/th/T21547.stderr - testsuite/tests/th/T23829_hasty.stderr - testsuite/tests/th/T23829_hasty_b.stderr - testsuite/tests/th/T23829_tardy.ghc.stderr - testsuite/tests/th/T5795.stderr - testsuite/tests/th/TH_Roles2.stderr - testsuite/tests/typecheck/should_compile/T12763.stderr - testsuite/tests/typecheck/should_compile/T18406b.stderr - testsuite/tests/typecheck/should_compile/T18529.stderr - testsuite/tests/typecheck/should_compile/T21023.stderr - utils/check-exact/ExactPrint.hs - utils/count-deps/Main.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e36f78d1d4cb6e428a8e530f43fb4d2... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e36f78d1d4cb6e428a8e530f43fb4d2... You're receiving this email because of your account on gitlab.haskell.org.