[Git][ghc/ghc][wip/26661] hadrian: Remove old package.conf files when generating new ones
Zubin pushed to branch wip/26661 at Glasgow Haskell Compiler / GHC Commits: 4d2272c8 by Zubin Duggal at 2025-12-16T19:10:23+05:30 hadrian: Remove old package.conf files when generating new ones Old package.conf files might exists with different hashes, causing issues like #26661 Fixes #26661 - - - - - 1 changed file: - hadrian/src/Rules/Register.hs Changes: ===================================== hadrian/src/Rules/Register.hs ===================================== @@ -29,6 +29,7 @@ import Distribution.Version (Version) import qualified Distribution.Types.PackageId as Cabal import qualified Distribution.Types.PackageName as Cabal import qualified Distribution.Parsec as Cabal +import qualified Distribution.Text as Cabal import qualified Distribution.Compat.Parsing as Cabal import qualified Distribution.Parsec.FieldLineStream as Cabal import qualified Distribution.Compat.CharParsing as CabalCharParsing @@ -118,8 +119,16 @@ registerPackageRules rs stage iplace = do root -/- relativePackageDbPath (PackageDbLoc stage iplace) -/- "*.conf" %> \conf -> do historyDisable - pkgName <- getPackageNameFromConfFile conf - let pkg = unsafeFindPackageByName pkgName + let (pkgName, version) = + case parseCabalName (takeBaseName conf) of + Left err -> error $ "registerPackage: Couldn't parse " ++ + takeBaseName conf ++ ": " ++ err + Right x -> x + pkg = unsafeFindPackageByName pkgName + + -- We may need to remove a pkg conf file with a different hash computed in a previous build + -- See https://gitlab.haskell.org/ghc/ghc/-/issues/26661 + liftIO $ removeFiles (root -/- relativePackageDbPath (PackageDbLoc stage iplace)) [pkgName ++ "-" ++ Cabal.display version ++ "*.conf"] when (pkg == compiler) $ need =<< ghcLibDeps stage iplace @@ -253,14 +262,6 @@ copyConf rs context@Context {..} conf = do stdOutToPkgIds :: String -> [String] stdOutToPkgIds = drop 1 . concatMap words . lines -getPackageNameFromConfFile :: FilePath -> Action String -getPackageNameFromConfFile conf - | takeBaseName conf == "rts" = return "rts" - | otherwise = case parseCabalName (takeBaseName conf) of - Left err -> error $ "getPackageNameFromConfFile: Couldn't parse " ++ - takeBaseName conf ++ ": " ++ err - Right (name, _) -> return name - -- | Parse a cabal-like name parseCabalName :: String -> Either String (String, Version) -- Try to parse a name with a hash, but otherwise parse a name without one. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4d2272c884f89059fceba9129c061789... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4d2272c884f89059fceba9129c061789... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Zubin (@wz1000)