Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mpilgrem opened this issue Jun 4, 2023 · 0 comments

Comments

@mpilgrem
Copy link

mpilgrem commented Jun 4, 2023

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 added a commit to mpilgrem/hoogle that referenced this issue Jun 4, 2023
…Windows

CPP is used to tailor for Windows and GHC >= 9.0. In that case, ${pkgroot} is not expanded and the bogus prefix is stripped.

Otherwise, ${pkgroot} is expanded. For compatibility with GHC < 9.0, $topdir is still stripped, if present.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant