Skip to content
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

Build with -Werror=unused-packages #9853

Closed
philderbeast opened this issue Mar 29, 2024 · 0 comments · Fixed by #9855
Closed

Build with -Werror=unused-packages #9853

philderbeast opened this issue Mar 29, 2024 · 0 comments · Fixed by #9855

Comments

@philderbeast
Copy link
Collaborator

Describe the bug
With ghc-9.2.* (I tested with ghc-9.2.8 and ghc-9.2.2) bringing up the REPL for the solver fails. The problem is not there with ghc-9.8.2.

For ghc-9.2.8, -Wunused-packages is included in -Wall (see ghc-9.2.8 users guide) but that is not the case for some later GHC versions.

In more recent versions of GHC, the warning is disabled in the REPL (I couldn't find which GHC version this was changed in by searching the release notes for "unused-packages":

This warning interacts poorly with GHCi because most invocations will pass a large number of -package arguments on the initial load. Therefore if you modify the targets using :load or :cd then the warning will be silently disabled if it’s enabled (see #21110).
SOURCE: ghc-9.11 users guide.

To Reproduce
Steps to reproduce the behavior:

$ git rev-parse HEAD
1c1230ca228cc03a9ee68166243af358ab3992fc

$ cabal repl cabal-install-solver
Warning: this is a debug build of cabal-install with assertions enabled.
Build profile: -w ghc-9.2.8 -O1
...

<no location info>: warning: [-Wunused-packages]
    The following packages were specified via -package or -package-id flags,
    but were not needed for compilation:
      - transformers-0.5.6.2
      - text-1.2.5.0
      - pretty-1.1.3.6
      - mtl-2.2.2
      - filepath-1.4.300.1-8ae0da84425ec5d8ceb59ec73faa10c8162e2f69a0f580fb091b23a255242573
      - edit-distance-0.2.2.1-01cf97582d93de9a835816245e39c539f3169eb72ab6f37e68fcc1a685fb9a6b
      - containers-0.6.5.1
      - bytestring-0.11.4.0
      - base-4.16.4.0
      - array-0.5.4.0
      - Cabal-syntax-3.11.0.0-inplace
      - Cabal-3.11.0.0-inplace
[ 1 of 50] Compiling Distribution.Client.Utils.Assertion
...
[50 of 50] Compiling Distribution.Solver.Modular
Ok, 50 modules loaded.
ghci> 

The behaviour is a bit different with the changes from #9565.

$ git rev-parse HEAD
7e085faf42a0cdb3ba19e3756590bc1f952de05b

$ cabal repl cabal-install-solver
Warning: this is a debug build of cabal-install with assertions enabled.
Resolving dependencies...
Build profile: -w ghc-9.2.8 -O1
...
but were not needed for compilation:
  - transformers-0.5.6.2
  - text-1.2.5.0
  - pretty-1.1.3.6
  - mtl-2.2.2
  - filepath-1.4.300.1-8ae0da84425ec5d8ceb59ec73faa10c8162e2f69a0f580fb091b23a255242573
  - edit-distance-0.2.2.1-01cf97582d93de9a835816245e39c539f3169eb72ab6f37e68fcc1a685fb9a6b
  - containers-0.6.5.1
  - bytestring-0.11.4.0
  - base-4.16.4.0
  - array-0.5.4.0
  - Cabal-syntax-3.11.0.0-inplace
  - Cabal-3.11.0.0-inplace

ghci> 

Expected behavior
I would expect that all our packages build with `--ghc-options="-Werror=unused-packages".

$ cabal build --enable-tests cabal-install-solver --ghc-options="-Werror=unused-packages"
Warning: this is a debug build of cabal-install with assertions enabled.
Build profile: -w ghc-9.8.2 -O1
In order, the following will be built (use -v for more details):
 - cabal-install-solver-3.11.0.0 (test:unit-tests) 
Warning: this is a debug build of cabal-install with assertions enabled.
Preprocessing test suite 'unit-tests' for cabal-install-solver-3.11.0.0...
Building test suite 'unit-tests' for cabal-install-solver-3.11.0.0...

<no location info>: error: [GHC-42258] [-Wunused-packages, Werror=unused-packages]
    The following packages were specified via -package or -package-id flags,
    but were not needed for compilation:
      - Cabal-3.11.0.0 (exposed by flag -package-id Cabal-3.11.0.0-inplace)
Error: [Cabal-7125]
Failed to build test:unit-tests from cabal-install-solver-3.11.0.0.

System information
Ubuntu 23.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant