[Git][ghc/ghc][wip/romes/hadrian-cross-stage2-rebase_SVEN_FINAL] hadrian: run haddock against the library_stage for cross builds
Sven Tennie pushed to branch wip/romes/hadrian-cross-stage2-rebase_SVEN_FINAL at Glasgow Haskell Compiler / GHC Commits: 2324c73f by Sven Tennie at 2026-06-13T12:49:53+00:00 hadrian: run haddock against the library_stage for cross builds The iface magic number is platform-dependent: - 32-bit targets (wasm32): 0x1face = 129742 - 64-bit targets (x86_64): 0x1face64 = 33214052 In a cross build, _build/stage1/lib/settings says target=wasm32, so Stage1 haddock (launched with -B_build/stage1/lib) expects magic 129742. Stage1 libraries are compiled by the native Stage0 GHC (x86_64) and have magic 33214052 → mismatch. Fix: use the library_stage from BindistConfig (Stage2 for cross builds) for doc generation instead of hardcoded Stage1. Stage2 libraries are compiled by the wasm32 cross-compiler and have magic 129742, matching what Stage1 haddock expects. Non-cross builds are unaffected because library_stage = Stage1 in that case. - - - - - 1 changed file: - hadrian/src/Rules/Documentation.hs Changes: ===================================== hadrian/src/Rules/Documentation.hs ===================================== @@ -26,6 +26,7 @@ import Utilities import qualified Data.Set as Set import qualified Text.Parsec as Parsec import Oracles.Flavour +import BindistConfig docRoot :: FilePath docRoot = "doc" @@ -242,10 +243,16 @@ buildLibraryDocumentation = do need neededDocs build $ target docContext (Haddock BuildIndex) libDocs [file] +-- | The stage whose libraries are documented. For cross builds this is +-- Stage2 (the wasm32/cross-target libraries); for native builds Stage1. +pkgDocStage :: Action Stage +pkgDocStage = library_stage <$> implicitBindistConfig + allHaddocks :: Action [FilePath] allHaddocks = do - pkgs <- stagePackages Stage1 - sequence [ pkgHaddockFile $ vanillaContext Stage1 pkg + docStage <- pkgDocStage + pkgs <- stagePackages docStage + sequence [ pkgHaddockFile $ vanillaContext docStage pkg | pkg <- pkgs, isLibrary pkg, pkgName pkg `notElem` haddockExclude ] -- Note: this build rule creates plenty of files, not just the .haddock one. @@ -257,14 +264,14 @@ buildPackageDocumentation = do -- Per-package haddocks root -/- htmlRoot -/- "libraries/*/haddock-prologue.txt" %> \file -> do - ctx <- pkgDocContext <$> getPkgDocTarget root file + ctx <- pkgDocContext =<< getPkgDocTarget root file syn <- pkgSynopsis (Context.package ctx) desc <- pkgDescription (Context.package ctx) let prologue = if null desc then syn else desc liftIO $ writeFile file prologue root -/- htmlRoot -/- "libraries/*/*.haddock" %> \file -> do - context <- pkgDocContext <$> getPkgDocTarget root file + context <- pkgDocContext =<< getPkgDocTarget root file need [ takeDirectory file -/- "haddock-prologue.txt"] haddocks <- haddockDependencies context @@ -290,8 +297,10 @@ buildPackageDocumentation = do data PkgDocTarget = DotHaddock PackageName | HaddockPrologue PackageName deriving (Eq, Show) -pkgDocContext :: PkgDocTarget -> Context -pkgDocContext target = Context Stage1 (unsafeFindPackageByName name) vanilla Final +pkgDocContext :: PkgDocTarget -> Action Context +pkgDocContext target = do + docStage <- pkgDocStage + return $ Context docStage (unsafeFindPackageByName name) vanilla Final where name = case target of DotHaddock n -> n HaddockPrologue n -> n @@ -417,5 +426,5 @@ buildManPage = do haddockDependencies :: Context -> Action [(Package, FilePath)] haddockDependencies context = do depNames <- interpretInContext context (getContextData depNames) - sequence [ (,) <$> pure depPkg <*> (pkgHaddockFile $ vanillaContext Stage1 depPkg) + sequence [ (,) <$> pure depPkg <*> (pkgHaddockFile $ vanillaContext (stage context) depPkg) | Just depPkg <- map findPackageByName depNames, (pkgName depPkg) `notElem` haddockExclude ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2324c73f7e5623ff04acea14e0702861... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2324c73f7e5623ff04acea14e0702861... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Sven Tennie (@supersven)