Implement recompilation checking for pre-build rules#11731
Open
sheaf wants to merge 2 commits intohaskell:masterfrom
Open
Implement recompilation checking for pre-build rules#11731sheaf wants to merge 2 commits intohaskell:masterfrom
sheaf wants to merge 2 commits intohaskell:masterfrom
Conversation
This commit adds 'Structured' instances for the 'RuleCommands' and 'RuleData' datatypes. This allows us to serialise and deserialise them, which allows us to compute which rules have changed across builds. This is necessary for recompilation checking for pre-build rules.
This commit adds recompilation logic for SetupHooks pre-build rules.
This implements the behaviour described in the SetupHooks API. That is,
a rule is considered stale if:
[N] The rule is new, or
[S1] A dependency of the rule is stale. That is, either we have
re-run another rule that this rule depends on, or one of the
file inputs to the rule is newer than the oldest output of the
rule (or the rule output doesn't exist at all), or
[S2] The rule itself has changed, e.g. the parameters stored in
RuleData have changed.
Fixes haskell#11730
geekosaur
reviewed
Apr 10, 2026
| -- Load the rule cache from the previous build. | ||
| -- Used to detect when rule definitions have changed. | ||
| oldRules <- do | ||
| cacheExists <- doesFileExist rulesCacheFile |
Collaborator
There was a problem hiding this comment.
Does this have a TOCTOU issue?
|
|
||
| mtimeIfExists :: FilePath -> IO (Maybe UTCTime) | ||
| mtimeIfExists fp = do | ||
| ex <- doesFileExist fp |
Collaborator
There was a problem hiding this comment.
Granting that it's brief, but this looks like a TOCTOU as well.
| have changed. | ||
|
|
||
| In particular, Cabal will now write per-component caches of pre-build rules | ||
| in order to compute which rules have changed across run, with file name |
Collaborator
There was a problem hiding this comment.
Suggested change
| in order to compute which rules have changed across run, with file name | |
| in order to compute which rules have changed between runs, with file name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Template Α: This PR modifies behaviour or interface
This PR adds recompilation logic for SetupHooks pre-build rules, implementing the behaviour described in the SetupHooks API. That is, a rule is considered stale if:
RuleDatahave changed.Tested in
cabal-testsuite/PackageTests/SetupHooks/SetupHooksRecompRules/setup.test.hs.