Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 92848e61 by Evgeny Malyshev at 2026-10-23T20:26:04-04:00 hadrian: Include transitive dependencies in Haddock builds Haddock needs indirect dependency interfaces to resolve references to definitions outside a package's direct dependencies. Expose Cabal's configured dependency closure through ContextData and use it alongside the direct list, preserving direct-interface precedence. Bump Shake's cache version for the serialized oracle change. Add a Hadrian selftest requiring template-haskell's indirect ghc-prim interface. Fixes #25850. Fixes #27786. Assisted-By: OpenAI Codex Metric Increase: haddock.Cabal - - - - - 6 changed files: - + changelog.d/25850 - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Hadrian/Haskell/Cabal/Type.hs - hadrian/src/Main.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/Selftest.hs Changes: ===================================== changelog.d/25850 ===================================== @@ -0,0 +1,5 @@ +section: packaging +synopsis: Include transitive dependencies when building library documentation with + Hadrian, so Haddock can resolve references to indirect dependencies. +issues: #25850 #27786 +mrs: !16638 ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -321,6 +321,7 @@ resolveContextData context@Context {..} = do (C.hsSourceDirs buildInfo) , depIds = depIds , depNames = map (C.display . C.mungedName . snd) extDeps + , transitiveDepNames = map (C.display . C.mungedName') depPkgs , includeDirs = map C.getSymbolicPath (C.includeDirs buildInfo) , includes = map C.getSymbolicPath (C.includes buildInfo) , installIncludes = map C.getSymbolicPath (C.installIncludes buildInfo) ===================================== hadrian/src/Hadrian/Haskell/Cabal/Type.hs ===================================== @@ -48,6 +48,7 @@ data ContextData = ContextData , srcDirs :: [String] , depIds :: [String] , depNames :: [String] + , transitiveDepNames :: [String] , includeDirs :: [String] , includes :: [String] , installIncludes :: [String] ===================================== hadrian/src/Main.hs ===================================== @@ -68,7 +68,7 @@ main = do -- from PackageData or other oracle value types). This forces -- Shake to wipe the stale database instead of crashing on -- deserialisation. - shakeVersion = "3" + shakeVersion = "4" , shakeChange = ChangeModtimeAndDigest , shakeFiles = buildRoot -/- Base.shakeFilesDir , shakeProgress = Progress.hadrianProgress cwd ===================================== hadrian/src/Rules/Documentation.hs ===================================== @@ -422,9 +422,12 @@ buildManPage = do checkSphinxWarnings dir copyFileUntracked (dir -/- "ghc.1") file --- | Find the Haddock files for the dependencies of the current library. +-- | Find the Haddock files for the direct and indirect dependencies of the current library. haddockDependencies :: Context -> Action [(Package, FilePath)] haddockDependencies context = do - depNames <- interpretInContext context (getContextData depNames) + directDeps <- interpretInContext context (getContextData depNames) + transitiveDeps <- interpretInContext context (getContextData transitiveDepNames) + -- Preserve the preference for direct dependencies when resolving links. + let depNames = nub (directDeps ++ transitiveDeps) sequence [ (,) <$> pure depPkg <*> (pkgHaddockFile $ vanillaContext (stage context) depPkg) | Just depPkg <- map findPackageByName depNames, (pkgName depPkg) `notElem` haddockExclude ] ===================================== hadrian/src/Rules/Selftest.hs ===================================== @@ -8,6 +8,7 @@ import Base import Context import Oracles.ModuleFiles import Packages +import Rules.Documentation (haddockDependencies) import Settings import Target import Utilities @@ -71,6 +72,11 @@ testDependencies = do test $ stage1Deps /= stage0Deps test $ stage1Deps == stage2Deps + putBuild "==== T25850: Transitive Haddock dependencies" + haddockDeps <- map fst <$> haddockDependencies (vanillaContext Stage1 templateHaskell) + unless (ghcPrim `elem` haddockDeps) $ + fail "T25850: Haddock is missing the indirect ghc-prim dependency of template-haskell" + testLookupAll :: Action () testLookupAll = do putBuild "==== lookupAll" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/92848e6186123d5820bcfb2f4ef5059e... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/92848e6186123d5820bcfb2f4ef5059e... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help