diff options
author | Andrey Mokhov <andrey.mokhov@gmail.com> | 2019-02-14 14:29:50 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-02-20 09:59:16 -0500 |
commit | 1dad4fc27ea128a11ba0077f459494c2a1ca0d5c (patch) | |
tree | c5b569c56435e699c03fca5ad08cf03cb8b21b80 /hadrian/src/Packages.hs | |
parent | 908b4b8659713f0b7a1704ce33c7fa30e3e0ffc3 (diff) | |
download | haskell-1dad4fc27ea128a11ba0077f459494c2a1ca0d5c.tar.gz |
Hadrian: Fix untracked dependencies
This is a preparation for #16295: https://ghc.haskell.org/trac/ghc/ticket/16295
This commit mostly focuses on getting rid of untracked dependencies,
which prevent Shake's new `--shared` feature from appropriately caching
build rules.
There are three different solutions to untracked dependencies:
* Track them! This is the obvious and the best approach, but in some
situations we cannot use it, for example, because a build rule creates
files whose names are not known statically and hence cannot be
specified as the rule's outputs.
* Use Shake's `produces` to record outputs dynamically, within the rule.
* Use Shake's `historyDisable` to disable caching for a particular build
rule. We currently use this approach only for `ghc-pkg` which mutates
the package database and the file `package.cache`.
These two tickets are fixed as the result:
Ticket #16271: https://ghc.haskell.org/trac/ghc/ticket/16271
Ticket #16272: https://ghc.haskell.org/trac/ghc/ticket/16272 (this one
is fixed only partially: we correctly record the dependency, but we
still copy files into the RTS build tree).
Diffstat (limited to 'hadrian/src/Packages.hs')
-rw-r--r-- | hadrian/src/Packages.hs | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/hadrian/src/Packages.hs b/hadrian/src/Packages.hs index 02dc134387..8d2aef1c7b 100644 --- a/hadrian/src/Packages.hs +++ b/hadrian/src/Packages.hs @@ -12,7 +12,8 @@ module Packages ( -- * Package information programName, nonHsMainPackage, autogenPath, programPath, timeoutPath, - rtsContext, rtsBuildPath, libffiContext, libffiBuildPath, libffiLibraryName + rtsContext, rtsBuildPath, libffiContext, libffiBuildPath, libffiLibraryName, + generatedGhcDependencies, ensureConfigured ) where import Hadrian.Package @@ -145,7 +146,7 @@ programName Context {..} = do (Profiling, "-prof"), (Dynamic, "-dyn") ]] - _ -> pkgName package + _ -> pkgName package -- | The 'FilePath' to a program executable in a given 'Context'. programPath :: Context -> Action FilePath @@ -170,8 +171,8 @@ timeoutPath = "testsuite/timeout/install-inplace/bin/timeout" <.> exe nonHsMainPackage :: Package -> Bool nonHsMainPackage = (`elem` [ghc, hp2ps, iserv, touchy, unlit]) --- TODO: Can we extract this information from Cabal files? --- | Path to the @autogen@ directory generated when configuring a package. +-- TODO: Combine this with 'programName'. +-- | Path to the @autogen@ directory generated by 'buildAutogenFiles'. autogenPath :: Context -> Action FilePath autogenPath context@Context {..} | isLibrary package = autogen "build" @@ -181,6 +182,16 @@ autogenPath context@Context {..} where autogen dir = contextPath context <&> (-/- dir -/- "autogen") +-- | Make sure a given context has already been fully configured. The +-- implementation simply calls 'need' on the context's @autogen/cabal_macros.h@ +-- file, which triggers 'configurePackage' and 'buildAutogenFiles'. Why this +-- indirection? Going via @autogen/cabal_macros.h@ allows us to cache the +-- configuration steps, i.e. not to repeat them if they have already been done. +ensureConfigured :: Context -> Action () +ensureConfigured context = do + autogen <- autogenPath context + need [autogen -/- "cabal_macros.h"] + -- | RTS is considered a Stage1 package. This determines RTS build directory. rtsContext :: Stage -> Context rtsContext stage = vanillaContext stage rts @@ -189,9 +200,8 @@ rtsContext stage = vanillaContext stage rts rtsBuildPath :: Stage -> Action FilePath rtsBuildPath stage = buildPath (rtsContext stage) --- | Build directory for libffi --- This probably doesn't need to be stage dependent but it is for --- consistency for now. +-- | Build directory for @libffi@. This probably doesn't need to be stage +-- dependent but it is for consistency for now. libffiContext :: Stage -> Context libffiContext stage = vanillaContext stage libffi @@ -208,3 +218,12 @@ libffiLibraryName = do (True , False) -> "ffi" (False, False) -> "Cffi" (_ , True ) -> "Cffi-6" + +-- | Generated header files required by GHC in runtime. +generatedGhcDependencies :: Stage -> Action [FilePath] +generatedGhcDependencies stage = do + let context = vanillaContext stage compiler + bh <- buildPath context <&> (-/- "ghc_boot_platform.h") + ch <- contextPath context <&> (-/- "ghc_boot_platform.h") + is <- includesDependencies + return $ is ++ [bh, ch] |