[Git][ghc/ghc][master] compiler: Exclude units with no exposed modules from unused package check
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 5cdcfaed by Ben Gamari at 2025-11-06T09:01:36-05:00 compiler: Exclude units with no exposed modules from unused package check Such packages cannot be "used" in the Haskell sense of the word yet are nevertheless necessary as they may provide, e.g., C object code or link flags. Fixes #24120. - - - - - 3 changed files: - compiler/GHC/Driver/Make.hs - + testsuite/tests/driver/T24120.hs - testsuite/tests/driver/all.T Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -474,6 +474,10 @@ warnUnusedPackages us dflags mod_graph = ui <- lookupUnit us u -- Which are not explicitly used guard (Set.notMember (unitId ui) used_args) + -- Exclude units with no exposed modules. This covers packages which only + -- provide C object code or link flags (e.g. system-cxx-std-lib). + -- See #24120. + guard (not $ null $ unitExposedModules ui) return (unitId ui, unitPackageName ui, unitPackageVersion ui, flag) unusedArgs = sortOn (\(u,_,_,_) -> u) $ mapMaybe resolve (explicitUnits us) ===================================== testsuite/tests/driver/T24120.hs ===================================== @@ -0,0 +1,5 @@ +-- | This should not issue an @-Wunused-packages@ warning for @system-cxx-std-lib@. +module Main where + +main :: IO () +main = putStrLn "hello world" ===================================== testsuite/tests/driver/all.T ===================================== @@ -331,3 +331,4 @@ test('T24839', [unless(arch('x86_64') or arch('aarch64'), skip), extra_files(["t test('t25150', [extra_files(["t25150"])], multimod_compile, ['Main.hs', '-v0 -working-dir t25150/dir a.c']) test('T25382', normal, makefile_test, []) test('T26018', req_c, makefile_test, []) +test('T24120', normal, compile, ['-Wunused-packages -hide-all-packages -package base -package system-cxx-std-lib']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5cdcfaed0e18cae061efbb585a76df9f... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5cdcfaed0e18cae061efbb585a76df9f... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)