diff options
| author | Simon Marlow <marlowsd@gmail.com> | 2017-04-01 11:51:43 -0400 |
|---|---|---|
| committer | Ben Gamari <ben@smart-cactus.org> | 2017-04-01 12:31:59 -0400 |
| commit | 3b5f786c7257298657fd34b3840d8cf6da968ef6 (patch) | |
| tree | 1ee1e930874dd4fa9a61e0287fc64afe3b5e543d /compiler/main/Packages.hs | |
| parent | 83ac462449d9365ebd8b51f252f9cf81b35f119d (diff) | |
| download | haskell-3b5f786c7257298657fd34b3840d8cf6da968ef6.tar.gz | |
Optimise common cases of GHC.setProgramDynFlags
* If the package flags haven't changed, don't do initPackages (which
might take multiple seconds in extreme cases)
* Provide a way to change the log_action without invalidating the
summary cache.
Test Plan: validate
Reviewers: niteria, bgamari, austin, erikd, ezyang
Reviewed By: bgamari
Subscribers: mpickering, rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D3392
Diffstat (limited to 'compiler/main/Packages.hs')
| -rw-r--r-- | compiler/main/Packages.hs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs index f938bbbda2..5db198be4b 100644 --- a/compiler/main/Packages.hs +++ b/compiler/main/Packages.hs @@ -500,10 +500,26 @@ getPackageConfRefs dflags = do | otherwise -> map PkgConfFile (splitSearchPath path) - return $ reverse (extraPkgConfs dflags base_conf_refs) - -- later packages shadow earlier ones. extraPkgConfs - -- is in the opposite order to the flags on the - -- command line. + -- Apply the package DB-related flags from the command line to get the + -- final list of package DBs. + -- + -- Notes on ordering: + -- * The list of flags is reversed (later ones first) + -- * We work with the package DB list in "left shadows right" order + -- * and finally reverse it at the end, to get "right shadows left" + -- + return $ reverse (foldr doFlag base_conf_refs (packageDBFlags dflags)) + where + doFlag (PackageDB p) dbs = p : dbs + doFlag NoUserPackageDB dbs = filter isNotUser dbs + doFlag NoGlobalPackageDB dbs = filter isNotGlobal dbs + doFlag ClearPackageDBs _ = [] + + isNotUser UserPkgConf = False + isNotUser _ = True + + isNotGlobal GlobalPkgConf = False + isNotGlobal _ = True resolvePackageConfig :: DynFlags -> PkgConfRef -> IO (Maybe FilePath) resolvePackageConfig dflags GlobalPkgConf = return $ Just (systemPackageConfig dflags) |
