[commit: ghc] master: Fix package dependencies (#657) (a804d57)

git at git.haskell.org git at git.haskell.org
Tue Oct 23 20:18:57 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/a804d57a6b29df8ba51f064ca42dd7f0500eea27/ghc

>---------------------------------------------------------------

commit a804d57a6b29df8ba51f064ca42dd7f0500eea27
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Fri Aug 24 11:25:39 2018 +0100

    Fix package dependencies (#657)
    
    This fixes #654.
    
    There are only two important changes.
    
    1) The first one fixes missing dependencies:
    
    ```diff
    -pkgDependencies = fmap (fmap PD.dependencies) . readPackageDataFile
    +pkgDependencies = fmap (fmap (map pkgName . packageDependencies)) . readCabalFile
    ```
    
    Here `PD.dependencies` returned versioned package names, e.g. `ghc-8.7`, which then failed to match with non-versioned package names such as `ghc` in `contextDependencies`. Switching from `PD.dependencies` to `packageDependencies` fixes this.
    
    2) I clearly remember that we didn't have this bug before, so I added some tests for our package dependency infrastructure to prevent such regressions in future:
    
    ```haskell
    testDependencies :: Action ()
    testDependencies = do
        putBuild "==== pkgDependencies"
        depLists <- mapM (pkgDependencies . vanillaContext Stage1) ghcPackages
        test $ and [ deps == sort deps | Just deps <- depLists ]
        putBuild "==== Dependencies of the 'ghc-bin' binary"
        ghcDeps <- pkgDependencies (vanillaContext Stage1 ghc)
        test $ isJust ghcDeps
        test $ pkgName compiler `elem` fromJust ghcDeps
        stage0Deps <- contextDependencies (vanillaContext Stage0 ghc)
        stage1Deps <- contextDependencies (vanillaContext Stage1 ghc)
        stage2Deps <- contextDependencies (vanillaContext Stage2 ghc)
        test $ vanillaContext Stage0 compiler `notElem` stage1Deps
        test $ vanillaContext Stage1 compiler `elem`    stage1Deps
        test $ vanillaContext Stage2 compiler `notElem` stage1Deps
        test $ stage1Deps /= stage0Deps
        test $ stage1Deps == stage2Deps
    ```
    
    Everything else are cosmetic changes, fixing minor issues in comments, and adding TODOs. To figure out the failure in #654 I had to read some code I didn't write and my hands were automatically fixing some style inconsistencies with the rest of the Hadrian code base. (I'd like to emphasise that I make no judgement about which style is better, it's merely an attempt to make the code base look more homogeneous, which I think is useful.)


>---------------------------------------------------------------

a804d57a6b29df8ba51f064ca42dd7f0500eea27
 src/Expression.hs               |   7 +-
 src/Hadrian/Haskell/Cabal.hs    |  15 +-
 src/Hadrian/Oracles/TextFile.hs |  17 +--
 src/Rules/Library.hs            | 322 +++++++++++++++++++---------------------
 src/Rules/Selftest.hs           |  23 ++-
 src/Utilities.hs                |  11 +-
 6 files changed, 199 insertions(+), 196 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc a804d57a6b29df8ba51f064ca42dd7f0500eea27


More information about the ghc-commits mailing list