From 1dad4fc27ea128a11ba0077f459494c2a1ca0d5c Mon Sep 17 00:00:00 2001 From: Andrey Mokhov Date: Thu, 14 Feb 2019 14:29:50 +0000 Subject: Hadrian: Fix untracked dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- hadrian/src/Settings.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'hadrian/src/Settings.hs') diff --git a/hadrian/src/Settings.hs b/hadrian/src/Settings.hs index 519d1fc80c..fdbef1c359 100755 --- a/hadrian/src/Settings.hs +++ b/hadrian/src/Settings.hs @@ -1,7 +1,7 @@ module Settings ( getArgs, getLibraryWays, getRtsWays, flavour, knownPackages, - findPackageByName, isLibrary, stagePackages, programContext, - getIntegerPackage + findPackageByName, unsafeFindPackageByName, unsafeFindPackageByPath, + isLibrary, stagePackages, programContext, getIntegerPackage ) where import CommandLine @@ -66,3 +66,13 @@ knownPackages = sort $ ghcPackages ++ userPackages -- Note: this is slow but we keep it simple as there are just ~50 packages findPackageByName :: PackageName -> Maybe Package findPackageByName name = find (\pkg -> pkgName pkg == name) knownPackages + +unsafeFindPackageByName :: PackageName -> Package +unsafeFindPackageByName name = fromMaybe (error msg) $ findPackageByName name + where + msg = "unsafeFindPackageByName: No package with name " ++ name + +unsafeFindPackageByPath :: FilePath -> Package +unsafeFindPackageByPath path = err $ find (\pkg -> pkgPath pkg == path) knownPackages + where + err = fromMaybe $ error ("findPackageByPath: No package for path " ++ path) -- cgit v1.2.1