[Git][ghc/ghc][master] Hadrian: Add option to generate .hie files for stage1 libraries

Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 35826d8b by Matthew Pickering at 2025-06-08T22:00:41+01:00 Hadrian: Add option to generate .hie files for stage1 libraries The +hie_files flavour transformer can be enabled to produce hie files for stage1 libraries. The hie files are produced in the "extra-compilation-artifacts" folder and copied into the resulting bindist. At the moment the hie files are not produced for the release flavour, they add about 170M to the final bindist. Towards #16901 - - - - - 9 changed files: - hadrian/doc/flavours.md - hadrian/doc/user-settings.md - hadrian/src/Context.hs - hadrian/src/Context/Path.hs - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs - hadrian/src/Settings/Builders/Ghc.hs - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Flavours/Release.hs Changes: ===================================== hadrian/doc/flavours.md ===================================== @@ -334,6 +334,8 @@ The supported transformers are listed below: <td>Disable including self-recompilation information in interface files via <code>-fno-write-if-self-recomp</code>. If you are building a distribution you can enable this flag to produce more deterministic interface files.</td> <td><code>hash_unit_ids</code></td> <td>Include a package hash in the unit id of built packages</td> + <td><code>hie_files</code></td> + <td>Produce hie files for stage1 libraries</td> </tr> </table> ===================================== hadrian/doc/user-settings.md ===================================== @@ -47,7 +47,10 @@ data Flavour = Flavour { -> Bool, -- | Whether to build docs and which ones -- (haddocks, user manual, haddock manual) - ghcDocs :: Action DocTargets } + ghcDocs :: Action DocTargets, + -- | Whether to generate .hie files + ghcHieFiles :: Stage -> Bool + } ``` Hadrian provides several built-in flavours (`default`, `quick`, and a few others; see `hadrian/doc/flavours.md`), which can be activated from the command line, @@ -364,6 +367,13 @@ all of the documentation targets: You can pass several `--docs=...` flags, Hadrian will combine their effects. +### HIE files + +The `ghcHieFiles` field controls whether `.hie` files are generated +for source files built with the stage1 compiler. + +For most flavours `.hie` files wil be generated by default. + ### Split sections You can build all or just a few packages with ===================================== hadrian/src/Context.hs ===================================== @@ -3,7 +3,7 @@ module Context ( Context (..), vanillaContext, stageContext, -- * Expressions - getStage, getPackage, getWay, getBuildPath, getPackageDbLoc, getStagedTarget, + getStage, getPackage, getWay, getBuildPath, getHieBuildPath, getPackageDbLoc, getStagedTarget, -- * Paths contextDir, buildPath, buildDir, pkgInplaceConfig, pkgSetupConfigFile, pkgSetupConfigDir, ===================================== hadrian/src/Context/Path.hs ===================================== @@ -42,6 +42,10 @@ buildPath context = buildRoot <&> (-/- buildDir context) getBuildPath :: Expr Context b FilePath getBuildPath = expr . buildPath =<< getContext +-- | The output directory for hie files +getHieBuildPath :: Expr Context b FilePath +getHieBuildPath = (-/- "extra-compilation-artifacts" -/- "hie") <$> getBuildPath + -- | Path to the directory containing haddock timing files, used by -- the haddock perf tests. haddockStatsFilesDir :: Action FilePath ===================================== hadrian/src/Flavour.hs ===================================== @@ -21,6 +21,7 @@ module Flavour , enableHiCore , useNativeBignum , enableTextWithSIMDUTF + , enableHieFiles , omitPragmas , completeSetting @@ -75,6 +76,7 @@ flavourTransformers = M.fromList , "boot_nonmoving_gc" =: enableBootNonmovingGc , "dump_stg" =: enableDumpStg , "hash_unit_ids" =: enableHashUnitIds + , "hie_files" =: enableHieFiles ] where (=:) = (,) @@ -324,6 +326,9 @@ enableTextWithSIMDUTF flavour = flavour { enableHashUnitIds :: Flavour -> Flavour enableHashUnitIds flavour = flavour { hashUnitIds = True } +enableHieFiles :: Flavour -> Flavour +enableHieFiles flavour = flavour { ghcHieFiles = (>= Stage1) } + -- | Build stage2 compiler with -fomit-interface-pragmas to reduce -- recompilation. omitPragmas :: Flavour -> Flavour ===================================== hadrian/src/Flavour/Type.hs ===================================== @@ -51,7 +51,10 @@ data Flavour = Flavour { ghcDocs :: Action DocTargets, -- | Whether to uses hashes or inplace for unit ids - hashUnitIds :: Bool + hashUnitIds :: Bool, + + -- | Whether to generate .hie files + ghcHieFiles :: Stage -> Bool } ===================================== hadrian/src/Settings/Builders/Ghc.hs ===================================== @@ -35,6 +35,9 @@ compileAndLinkHs = (builder (Ghc CompileHs) ||^ builder (Ghc LinkHs)) ? do useColor <- shakeColor <$> expr getShakeOptions let hasVanilla = elem vanilla ways hasDynamic = elem dynamic ways + hieFiles <- ghcHieFiles <$> expr flavour + stage <- getStage + hie_path <- getHieBuildPath mconcat [ arg "-Wall" , arg "-Wcompat" , not useColor ? builder (Ghc CompileHs) ? @@ -49,6 +52,10 @@ compileAndLinkHs = (builder (Ghc CompileHs) ||^ builder (Ghc LinkHs)) ? do , ghcLinkArgs , defaultGhcWarningsArgs , builder (Ghc CompileHs) ? arg "-c" + , hieFiles stage ? builder (Ghc CompileHs) ? mconcat + [ arg "-fwrite-ide-info" + , arg "-hiedir", arg hie_path + ] , getInputs , arg "-o", arg =<< getOutput ] ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -283,6 +283,7 @@ defaultFlavour = Flavour , ghcDebugAssertions = const False , ghcSplitSections = False , ghcDocs = cmdDocsArgs + , ghcHieFiles = const False , hashUnitIds = False } -- | Default logic for determining whether to build ===================================== hadrian/src/Settings/Flavours/Release.hs ===================================== @@ -11,4 +11,6 @@ releaseFlavour = $ enableHaddock -- 3. Include unit id hashes $ enableHashUnitIds + -- 4. Include hie files (#16901) + -- $ enableHieFiles $ performanceFlavour { name = "release" } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/35826d8b61b7c057dc8eff4c206eabc4... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/35826d8b61b7c057dc8eff4c206eabc4... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)