Skip to content

Handle Backpack signature files in component discovery#6940

Draft
philippedev101 wants to merge 1 commit into
commercialhaskell:masterfrom
philippedev101:re6937-backpack-signatures
Draft

Handle Backpack signature files in component discovery#6940
philippedev101 wants to merge 1 commit into
commercialhaskell:masterfrom
philippedev101:re6937-backpack-signatures

Conversation

@philippedev101

Copy link
Copy Markdown
Contributor

Addresses #6937.

@mpilgrem I don't think .hsig should go through the custom-preprocessor path. A .hsig file is already the source file for a Backpack signature, not an input that should produce a .hs file.

The main user-visible change is that a normal Backpack package should stop getting a warning that suggests adding .hsig to custom-preprocessor-extensions. That warning sends people in the wrong direction: the project is not missing preprocessor configuration, Stack just needs to recognize the declared signature file as part of the package.

There are now three cases. If the module is listed in signatures, Stack treats the .hsig as expected and stays quiet. If there is a local .hsig file but the module is not listed in signatures, Stack gives a Backpack-specific hint pointing at the missing field. If the file really is some other unknown extension, Stack still gives the existing custom-preprocessor warning.

The declared .hsig files are also tracked for rebuilds, so changing a signature is treated like changing another source file that matters to the component.

Tests cover the valid Backpack case, .hsig rebuild tracking, the undeclared-signature warning, and the unchanged custom-preprocessor warning path.

Treat declared .hsig files as Backpack signatures instead of unknown custom-preprocessor candidates. Track declared signature files for rebuilds, keep signature modules out of ordinary module resolution, and emit a Backpack-specific warning when a local .hsig file is not listed in the component's signatures field.

Keep the existing custom-preprocessor warning for other unknown extensions.
@philippedev101 philippedev101 force-pushed the re6937-backpack-signatures branch from 6e2b86b to 40fc51b Compare July 3, 2026 08:15
@mpilgrem mpilgrem marked this pull request as draft July 4, 2026 13:13
@mpilgrem

mpilgrem commented Jul 4, 2026

Copy link
Copy Markdown
Member

@philippedev101, I've set the pull request to draft while the integration tests are failing.

In the case of backpack-x-pkg-transitive, the test expects stack build to work if the Logger.hsig has been changed (to add loggerName :: String). In fact, it fails with:

> stack build
Warning: Found Backpack signature file for Cabal entry Str, but that module is not listed in the component's signatures field:
         * Str.hsig

         If this file is meant to be a Backpack signature, add Str to the signatures field in the package description.

Warning: Backpack: no dependency exposes module Str needed to instantiate str-sig. Ensure the implementing package is listed in build-depends.
consumer-pkg-0.0.0: unregistering (missing dependencies: logger-sig)
logger-sig-0.0.0: unregistering (local file changes: src\Logger.hsig)
logger-sig-0.0.0: unregistering (local file changes: src\Logger.hsig)
str-sig-0.0.0: unregistering
str-sig-0.0.0: unregistering
logger-sig  > build (lib) with ghc-9.10.3
logger-sig  > Preprocessing library for logger-sig-0.0.0...
logger-sig  > Building library instantiated with
logger-sig  >   Logger = <Logger>
logger-sig  >   Str = <Str>
logger-sig  > for logger-sig-0.0.0...
logger-sig  > <command line>: cannot satisfy -package-id str-sig-0.0.0-HPF0111dNK1KIRtIq2ktMM[Str=<Str>]
logger-sig  >     (use -v for more information)
str-sig     > configure (lib)
str-sig     > Configuring str-sig-0.0.0...
str-sig     > Error: [Cabal-5000]
str-sig     > The following package dependencies were requested
str-sig     >     --dependency='str-sig=str-sig-0.0.0-HPF0111dNK1KIRtIq2ktMM'
str-sig     > however the given installed package instance does not exist.
str-sig     >

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.

2 participants