hoogle icon indicating copy to clipboard operation
hoogle copied to clipboard

Accommodate `${pkgroot}`, used in `haddock-html` in GHC boot libraries since GHC 9.0.1

Open mpilgrem opened this issue 2 years ago • 0 comments

From GHC 9.0.1 (at least, on Windows), the *.conf files for GHC boot libraries have used ${pkgroot} (not $topdir) in the haddock-html field. For example (on Windows):

GHC 8.10.7 had for base-4.14.3.0.conf (extracts):

name:                 base
version:              4.14.3.0
...
haddock-html:         $topdir/../doc/html/libraries/base-4.14.3.0

GHC 9.0.1 had for base-4.15.0.0.conf (extracts):

name:                 base
version:              4.15.0.0
...
haddock-html:         ${pkgroot}/../../docs/html/libraries/base

From at least GHC package manager version 7.8.4, ghc-pkg dump --expand-pkgroot is available to 'expand ${pkgroot}-relative paths to absolute in output package descriptions'.

However, this is not accommodated in Input.Cabal.readGhcPkg, which currently has (extracts):

readGhcPkg :: Settings -> IO (Map.Map PkgName Package)
readGhcPkg settings = do
    topdir <- findExecutable "ghc-pkg"
    -- important to use BS process reading so it's in Binary format, see #194
    (exit, stdout, stderr) <- BS.readProcessWithExitCode "ghc-pkg" ["dump"] mempty
    ...
    let g (stripPrefix "$topdir" -> Just x) | Just t <- topdir = takeDirectory t ++ x
        g x = x
    let fixer p = p{packageLibrary = True, packageDocs = g <$> packageDocs p}
    ...

But for one wrinkle, I think the solution would be simply to call ghc-pkg dump --expand-pkgroot:

    (exit, stdout, stderr) <- BS.readProcessWithExitCode "ghc-pkg" ["dump", "--expand-pkgroot"] mempty

The wrinkle is that I think the *.conf files for GHC boot libraries for GHC >= 9.0 (up to at least GHC 9.6.2) have incorrect entries in the haddock-html fields on Windows - see https://gitlab.haskell.org/ghc/ghc/-/issues/23476.

mpilgrem avatar Jun 04 '23 13:06 mpilgrem