Conversation
03931ce to
7ec6e5d
Compare
7ec6e5d to
22818b2
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR modifies Cabal's handling of program arguments (like GHC flags) to separate normalization for caching purposes from actual program invocation. Previously, Cabal normalized program flags for both purposes, which inadvertently filtered out valid GHC flags like -freverse-errors and -Rghc-timing. The change introduces a new field to store normalized arguments used only for hashing/caching, while preserving the original arguments for actual program execution.
Key changes:
- Introduced
elabNormalisedProgramArgsfield to store normalized program arguments for caching - Modified normalization to only affect the new field, leaving
elabProgramArgsunfiltered for execution - Updated hash computation to use normalized arguments while program invocation uses original arguments
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| changelog.d/pr-11259.md | Added changelog entry documenting the removal of program argument filtering |
| cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs | Added elabNormalisedProgramArgs field and updated normaliseConfiguredPackage to populate it instead of modifying elabProgramArgs |
| cabal-install/src/Distribution/Client/ProjectPlanning.hs | Initialized elabNormalisedProgramArgs during plan elaboration and updated hash computation to use normalized args |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| elabNormalisedProgramArgs = | ||
| Map.unionWith | ||
| (++) | ||
| ( Map.fromList | ||
| [ (programId prog, args) | ||
| | prog <- configuredPrograms compilerprogdb | ||
| , let args = programOverrideArgs $ addHaddockIfDocumentationEnabled prog | ||
| , not (null args) | ||
| ] | ||
| ) | ||
| (perPkgOptionMapMappend pkgid packageConfigProgramArgs) |
There was a problem hiding this comment.
The elabNormalisedProgramArgs field is being initialized with the same logic as elabProgramArgs (lines 2382-2392), but it should be initialized with the result of normaliseConfiguredPackage applied to the original args. Currently, both fields contain identical unfiltered arguments at initialization, meaning normalization isn't actually happening. The normalized version should be computed after creating the package record by applying the lookupFilter logic from normaliseConfiguredPackage.
This PR changes how cabal is normalising program flags. Instead of
normalising them for program invocation, it normalises them just for caching
purposes. This allows us to pass any GHC flag without cabal, surprisingly
removing it. This allows one to pass things like
-freverse-errors,-Rghc-timing, and many others.I am not deeply familiar with cabal's codebase, so please excuse if I am doing something silly.
Include the following checklist in your PR:
significance: significantin the changelog file.