Zubin pushed to branch wip/26661 at Glasgow Haskell Compiler / GHC

Commits:

1 changed file:

Changes:

  • hadrian/src/Rules/Register.hs
    ... ... @@ -29,6 +29,7 @@ import Distribution.Version (Version)
    29 29
     import qualified Distribution.Types.PackageId as Cabal
    
    30 30
     import qualified Distribution.Types.PackageName as Cabal
    
    31 31
     import qualified Distribution.Parsec as Cabal
    
    32
    +import qualified Distribution.Text as Cabal
    
    32 33
     import qualified Distribution.Compat.Parsing as Cabal
    
    33 34
     import qualified Distribution.Parsec.FieldLineStream as Cabal
    
    34 35
     import qualified Distribution.Compat.CharParsing as CabalCharParsing
    
    ... ... @@ -118,8 +119,16 @@ registerPackageRules rs stage iplace = do
    118 119
         root -/- relativePackageDbPath (PackageDbLoc stage iplace) -/- "*.conf" %> \conf -> do
    
    119 120
             historyDisable
    
    120 121
     
    
    121
    -        pkgName <- getPackageNameFromConfFile conf
    
    122
    -        let pkg = unsafeFindPackageByName pkgName
    
    122
    +        let (pkgName, version) =
    
    123
    +              case parseCabalName (takeBaseName conf) of
    
    124
    +                Left err -> error $ "registerPackage: Couldn't parse " ++
    
    125
    +                                    takeBaseName conf ++ ": " ++ err
    
    126
    +                Right x -> x
    
    127
    +            pkg = unsafeFindPackageByName pkgName
    
    128
    +
    
    129
    +        -- We may need to remove a pkg conf file with a different hash computed in a previous build
    
    130
    +        -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26661
    
    131
    +        liftIO $ removeFiles (root -/- relativePackageDbPath (PackageDbLoc stage iplace)) [pkgName ++ "-" ++ Cabal.display version ++ "*.conf"]
    
    123 132
     
    
    124 133
             when (pkg == compiler) $ need =<< ghcLibDeps stage iplace
    
    125 134
     
    
    ... ... @@ -253,14 +262,6 @@ copyConf rs context@Context {..} conf = do
    253 262
         stdOutToPkgIds :: String -> [String]
    
    254 263
         stdOutToPkgIds = drop 1 . concatMap words . lines
    
    255 264
     
    
    256
    -getPackageNameFromConfFile :: FilePath -> Action String
    
    257
    -getPackageNameFromConfFile conf
    
    258
    -    | takeBaseName conf == "rts" = return "rts"
    
    259
    -    | otherwise = case parseCabalName (takeBaseName conf) of
    
    260
    -        Left err -> error $ "getPackageNameFromConfFile: Couldn't parse " ++
    
    261
    -                            takeBaseName conf ++ ": " ++ err
    
    262
    -        Right (name, _) -> return name
    
    263
    -
    
    264 265
     -- | Parse a cabal-like name
    
    265 266
     parseCabalName :: String -> Either String (String, Version)
    
    266 267
     -- Try to parse a name with a hash, but otherwise parse a name without one.