Skip to content

Conversation

@coot
Copy link
Collaborator

@coot coot commented Oct 18, 2025

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:

@coot coot force-pushed the coot/filtering-program-args branch from 03931ce to 7ec6e5d Compare October 18, 2025 17:58
@coot coot force-pushed the coot/filtering-program-args branch from 7ec6e5d to 22818b2 Compare October 19, 2025 12:34
@coot coot requested a review from Copilot October 22, 2025 17:48
Copy link

Copilot AI left a 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 elabNormalisedProgramArgs field to store normalized program arguments for caching
  • Modified normalization to only affect the new field, leaving elabProgramArgs unfiltered 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.

Comment on lines +2382 to +2392
elabNormalisedProgramArgs =
Map.unionWith
(++)
( Map.fromList
[ (programId prog, args)
| prog <- configuredPrograms compilerprogdb
, let args = programOverrideArgs $ addHaddockIfDocumentationEnabled prog
, not (null args)
]
)
(perPkgOptionMapMappend pkgid packageConfigProgramArgs)
Copy link

Copilot AI Oct 22, 2025

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant