Skip to content
Snippets Groups Projects
Commit 68fcd33d authored by Rodrigo Mesquita's avatar Rodrigo Mesquita :seedling: Committed by Mikolaj
Browse files

haddock: Pass --no-tmp-comp-dir by default

With "Hi Haddock", we want to re-use GHC's compilation output (in
particular, the generated interface files) to generate documentation
from. However, haddock by default will use a temporary location to build
sources, and will therefore fail to find the interface files produced by
GHC.

To avoid recompilation, we need to instruct Cabal to pass
--no-tmp-comp-dir to Haddock so as to not use a temporary directory and
thus re-use existing interface files.
parent 144383e8
No related branches found
No related tags found
No related merge requests found
......@@ -326,6 +326,7 @@ haddock_setupHooks
[] -> allTargetsInBuildOrder' pkg_descr lbi
_ -> targets
-- See Note [Hi Haddock Recompilation Avoidance]
mtmp
| version >= mkVersion [2, 28, 0] = const Nothing
| otherwise = Just
......@@ -593,6 +594,17 @@ componentGhcOptions verbosity lbi bi clbi odir =
++ "haddock only supports GHC and GHCJS"
in f verbosity lbi bi clbi odir
{-
Note [Hi Haddock Recompilation Avoidance]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Starting with Haddock 2.28, we no longer want to run Haddock's
GHC session in a temporary directory. Doing so always causes
recompilation during documentation generation, which can now be
avoided thanks to Hi Haddock.
See https://github.com/haskell/cabal/pull/9177 for discussion.
-}
mkHaddockArgs
:: Verbosity
-> Maybe (SymbolicPath Pkg (Path.Dir Tmp))
......@@ -611,11 +623,7 @@ mkHaddockArgs verbosity mtmp lbi clbi htmlTemplate inFiles bi = do
componentGhcOptions normal lbi bi clbi (buildDir lbi)
vanillaOpts =
vanillaOpts'
{ -- Starting with Haddock 2.28, we no longer want to run Haddock's
-- GHC session in a temporary directory. Doing so always causes
-- recompilation during documentation generation, which can now be
-- avoided thanks to Hi Haddock. See
-- https://github.com/haskell/cabal/pull/9177 for discussion.
{ -- See Note [Hi Haddock Recompilation Avoidance]
ghcOptObjDir = maybe (ghcOptObjDir vanillaOpts') (toFlag . coerceSymbolicPath) mtmp
, ghcOptHiDir = maybe (ghcOptHiDir vanillaOpts') (toFlag . coerceSymbolicPath) mtmp
, ghcOptStubDir = maybe (ghcOptStubDir vanillaOpts') (toFlag . coerceSymbolicPath) mtmp
......@@ -973,6 +981,10 @@ renderPureArgs version comp platform args =
]
, argTargets $ args
, maybe [] ((: []) . (resourcesDirFlag ++)) . flagToMaybe . argResourcesDir $ args
-- Do not re-direct compilation output to a temporary directory (--no-tmp-comp-dir)
-- We pass this option by default to haddock to avoid recompilation
-- See Note [Hi Haddock Recompilation Avoidance]
, [ "--no-tmp-comp-dir" | version >= mkVersion [2, 28, 0] ]
]
where
-- See Note [Symbolic paths] in Distribution.Utils.Path
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment