-
Couldn't load subscription status.
- Fork 722
cabal: filtering GHC args #11259
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
base: master
Are you sure you want to change the base?
cabal: filtering GHC args #11259
Conversation
03931ce to
7ec6e5d
Compare
7ec6e5d to
22818b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
Copilot
AI
Oct 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.