Skip to content

Unused Package Warning for `system-cxx-std-lib` Dependency

Summary

When building a package depending on system-cxx-std-lib while using -Wunused-packages, the package system-cxx-std-lib is reported as unused.

Steps to reproduce

I have a library specification that looks like this:

library
  default-language:    GHC2021
  ghc-options:         -Wall -Wno-name-shadowing -Wunused-packages
  build-depends:       base, system-cxx-std-lib
  hs-source-dirs:      source
  exposed-modules:     RTAudio.Audio
  cxx-options:         -Wall
  cxx-sources:         rtaudio/rtaudio_c.cpp rtaudio/RtAudio.cpp

When compiled, this produces the following warning:

<no location info>: warning: [GHC-42258] [-Wunused-packages]
    The following packages were specified via -package or -package-id flags,
    but were not needed for compilation:
      - system-cxx-std-lib-1.0 (exposed by flag -package-id system-cxx-std-lib-1.0)

Expected behavior

The package system-cxx-std-lib is actually used. The compilation fails with undefined references to C++ standard library symbols when it is not mentioned in build-depends. Thus, the package should not be reported as "not needed for compilation".

Environment

  • GHC version used: 9.6.3

Optional:

  • Operating System: Arch Linux
  • System Architecture: x64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information