Skip to content

use with compiler flags in key of cached project config #8819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions cabal-install/src/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,17 @@ rebuildProjectConfig verbosity
}
cliConfig = do

progsearchpath <- liftIO $ getSystemSearchPath

let fileMonitorProjectConfig = newFileMonitor (distProjectCacheFile "config")

fileMonitorProjectConfigKey <- do
configPath <- getConfigFilePath projectConfigConfigFile
return (configPath, distProjectFile "")
return (configPath, distProjectFile "",
(projectConfigHcFlavor, projectConfigHcPath, projectConfigHcPkg),
progsearchpath,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that if I run cabal in a directory with a slightly modified PATH, then it's going to be a complete cache miss on everything? Even it doesn't change what ghc etc. gets picked? direnv users will be sad if so.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is this will only be a cache miss on parsing and evaluating the conditionals in a project file, which should be pretty low-cost. But we certainly need to give this a workout to be sure.

packageConfigProgramPaths,
packageConfigProgramPathExtra)

(projectConfig, localPackages) <-
runRebuild distProjectRootDirectory
Expand Down Expand Up @@ -359,18 +367,11 @@ rebuildProjectConfig verbosity

where

ProjectConfigShared { projectConfigConfigFile } =
projectConfigShared cliConfig

ProjectConfigShared { projectConfigIgnoreProject } =
ProjectConfigShared { projectConfigHcFlavor, projectConfigHcPath, projectConfigHcPkg, projectConfigIgnoreProject, projectConfigConfigFile } =
projectConfigShared cliConfig

fileMonitorProjectConfig ::
FileMonitor
(FilePath, FilePath)
(ProjectConfig, [PackageSpecifier UnresolvedSourcePackage])
fileMonitorProjectConfig =
newFileMonitor (distProjectCacheFile "config")
PackageConfig { packageConfigProgramPaths, packageConfigProgramPathExtra } =
projectConfigLocalPackages cliConfig

-- Read the cabal.project (or implicit config) and combine it with
-- arguments from the command line
Expand Down
9 changes: 9 additions & 0 deletions changelog.d/pr-8819
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
synopsis: Use compiler flags for caching project config
packages: cabal-install
prs: #8819

description: {

This ensures that cached project configs with conditionals re-execute the conditional logic when the compiler changes.

}