diff options
author | romes <rodrigo.m.mesquita@gmail.com> | 2023-03-20 19:46:19 +0000 |
---|---|---|
committer | romes <rodrigo.m.mesquita@gmail.com> | 2023-03-21 14:37:07 +0000 |
commit | e38453bbd6fe6d27ef3c6abf799d9aa12114abe8 (patch) | |
tree | 901cfabcc27a30f806161e0914c300e7a1860bf8 | |
parent | ae627b1385c85ba95a569b5720be591b554889a5 (diff) | |
download | haskell-wip/romes/hardwire-ghc-unit-id-hadrian-hash.tar.gz |
-rw-r--r-- | hadrian/src/Hadrian/BuildPath.hs | 7 | ||||
-rw-r--r-- | hadrian/src/Hadrian/Haskell/Cabal/Parse.hs | 9 | ||||
-rw-r--r-- | hadrian/src/Hadrian/Haskell/Hash.hs | 17 | ||||
-rw-r--r-- | hadrian/src/Rules/BinaryDist.hs | 4 | ||||
-rw-r--r-- | hadrian/src/Rules/CabalReinstall.hs | 4 | ||||
-rw-r--r-- | hadrian/src/Settings/Builders/Cabal.hs | 2 |
6 files changed, 27 insertions, 16 deletions
diff --git a/hadrian/src/Hadrian/BuildPath.hs b/hadrian/src/Hadrian/BuildPath.hs index 2b8a1bdd1c..4f2d21ba4e 100644 --- a/hadrian/src/Hadrian/BuildPath.hs +++ b/hadrian/src/Hadrian/BuildPath.hs @@ -113,7 +113,7 @@ parseWayUnit = Parsec.choice -- | Parse a @"pkgname-pkgversion"@ string into the package name and the -- integers that make up the package version. parsePkgId :: Parsec.Parsec String () (String, [Integer], String) -parsePkgId = parsePkgId' "" Parsec.<?> "package identifier (<name>-<version>)" +parsePkgId = parseRTS <|> (parsePkgId' "" Parsec.<?> "package identifier (<name>-<version>-<hash>)") where parsePkgId' currName = do s <- Parsec.many1 Parsec.alphaNum @@ -122,6 +122,11 @@ parsePkgId = parsePkgId' "" Parsec.<?> "package identifier (<name>-<version>)" Parsec.choice [ (,,) newName <$> parsePkgVersion <*> (Parsec.char '-' *> parsePkgHash) , parsePkgId' newName ] + parseRTS = do + _ <- Parsec.string "rts" <* Parsec.char '-' + v <- parsePkgVersion + pure ("rts", v, "") + parsePkgHash :: Parsec.Parsec String () String parsePkgHash = Parsec.many1 Parsec.alphaNum diff --git a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs index 775ff28782..139d237fec 100644 --- a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs +++ b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs @@ -357,12 +357,12 @@ registerPackage rs context = do -- This is copied and simplified from Cabal, because we want to install the package -- into a different package database to the one it was configured against. register :: FilePath - -> FilePath + -> String -- ^ Package Identifier -> FilePath -> C.PackageDescription -> LocalBuildInfo -> IO () -register pkg_db conf_file build_dir pd lbi +register pkg_db pid build_dir pd lbi = withLibLBI pd lbi $ \lib clbi -> do absPackageDBs <- C.absolutePackageDBPaths packageDbs @@ -370,16 +370,17 @@ register pkg_db conf_file build_dir pd lbi C.silent pd lib lbi clbi False reloc build_dir (C.registrationPackageDB absPackageDBs) + liftIO $ putStrLn ("REGFILE: " <> regFile) writeRegistrationFile installedPkgInfo where - regFile = conf_file + regFile = pkg_db </> pid <.> "conf" reloc = relocatable lbi -- Using a specific package db here is why we have to copy the function from Cabal. packageDbs = [C.SpecificPackageDB pkg_db] writeRegistrationFile installedPkgInfo = do - writeUTF8File (pkg_db </> regFile <.> "conf") (CP.showInstalledPackageInfo installedPkgInfo) + writeUTF8File regFile (CP.showInstalledPackageInfo installedPkgInfo) -- | Build autogenerated files @autogen/cabal_macros.h@ and @autogen/Paths_*.hs@. diff --git a/hadrian/src/Hadrian/Haskell/Hash.hs b/hadrian/src/Hadrian/Haskell/Hash.hs index f4918db941..58ebc09297 100644 --- a/hadrian/src/Hadrian/Haskell/Hash.hs +++ b/hadrian/src/Hadrian/Haskell/Hash.hs @@ -40,12 +40,17 @@ pkgUnitId ctx' pkg = do let ctx = ctx'{package = pkg} pid <- pkgSimpleIdentifier (package ctx) phash <- pkgHash ctx - -- Other boot packages still hardcode their unit-id to just <name>, but we - -- can have hadrian generate a different unit-id for them just as cabal does - -- because the boot packages unit-ids are overriden by setting -this-unit-id - -- in the cabal file - liftIO $ print $ pid <> "-" <> truncateHash 4 phash - pure $ pid <> "-" <> truncateHash 4 phash + if pkgName pkg == "rts" + -- The Unit-id will change depending on the way... rTS BReaks. At some + -- point it's not even clear which way we're building + then pure pid + else do + -- Other boot packages still hardcode their unit-id to just <name>, but we + -- can have hadrian generate a different unit-id for them just as cabal does + -- because the boot packages unit-ids are overriden by setting -this-unit-id + -- in the cabal file + liftIO $ print $ pid <> "-" <> truncateHash 4 phash + pure $ pid <> "-" <> truncateHash 4 phash where truncateHash :: Int -> String -> String diff --git a/hadrian/src/Rules/BinaryDist.hs b/hadrian/src/Rules/BinaryDist.hs index 34d165836b..3dc683dff7 100644 --- a/hadrian/src/Rules/BinaryDist.hs +++ b/hadrian/src/Rules/BinaryDist.hs @@ -132,8 +132,8 @@ bindistRules = do version <- setting ProjectVersion targetPlatform <- setting TargetPlatformFull distDir <- Context.distDir Stage1 - -- rtsDir <- pkgUnitId (vanillaContext Stage1 rts) rts - let rtsDir = "rts" + rtsDir <- pkgUnitId (vanillaContext Stage1 rts) rts + -- let rtsDir = "rts" let ghcBuildDir = root -/- stageString Stage1 bindistFilesDir = root -/- "bindist" -/- ghcVersionPretty diff --git a/hadrian/src/Rules/CabalReinstall.hs b/hadrian/src/Rules/CabalReinstall.hs index 55051e6c36..061e27dc0f 100644 --- a/hadrian/src/Rules/CabalReinstall.hs +++ b/hadrian/src/Rules/CabalReinstall.hs @@ -54,8 +54,8 @@ cabalBuildRules = do need (lib_targets ++ (map (\(_, p) -> p) (bin_targets ++ iserv_targets))) distDir <- Context.distDir Stage1 - -- rtsDir <- pkgUnitId (vanillaContext Stage1 rts) rts - let rtsDir = "rts" + rtsDir <- pkgUnitId (vanillaContext Stage1 rts) rts + -- let rtsDir = "rts" let ghcBuildDir = root -/- stageString Stage1 rtsIncludeDir = ghcBuildDir -/- "lib" -/- distDir -/- rtsDir diff --git a/hadrian/src/Settings/Builders/Cabal.hs b/hadrian/src/Settings/Builders/Cabal.hs index ef64994542..4b6497cac7 100644 --- a/hadrian/src/Settings/Builders/Cabal.hs +++ b/hadrian/src/Settings/Builders/Cabal.hs @@ -102,7 +102,7 @@ commonCabalArgs stage = do , arg "--cabal-file" , arg $ pkgCabalFile pkg , arg "--ipid" - , arg "$pkg-$version" + , arg package_id , arg "--prefix" , arg prefix |