Skip to content

Commit

Permalink
Avoid spurious warnings from -with-rtsopts (fix #4255)
Browse files Browse the repository at this point in the history
  • Loading branch information
ulysses4ever committed May 31, 2022
1 parent 5cf4ab7 commit 0dd5ee6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
28 changes: 17 additions & 11 deletions Cabal/src/Distribution/PackageDescription/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -871,42 +871,43 @@ checkGhcOptions fieldName getOptions pkg =
++ "should only be used for executables."

, checkAlternatives fieldName "extensions"
[ (flag, prettyShow extension) | flag <- all_ghc_options
[ (flag, prettyShow extension) | flag <- ghc_options_no_rtsopts
, Just extension <- [ghcExtension flag] ]

, checkAlternatives fieldName "extensions"
[ (flag, extension) | flag@('-':'X':extension) <- all_ghc_options ]
[ (flag, extension) | flag@('-':'X':extension) <- ghc_options_no_rtsopts ]

, checkAlternatives fieldName "cpp-options" $
[ (flag, flag) | flag@('-':'D':_) <- all_ghc_options ]
++ [ (flag, flag) | flag@('-':'U':_) <- all_ghc_options ]
[ (flag, flag) | flag@('-':'D':_) <- ghc_options_no_rtsopts ]
++ [ (flag, flag) | flag@('-':'U':_) <- ghc_options_no_rtsopts ]

, checkAlternatives fieldName "include-dirs"
[ (flag, dir) | flag@('-':'I':dir) <- all_ghc_options ]
[ (flag, dir) | flag@('-':'I':dir) <- ghc_options_no_rtsopts ]

, checkAlternatives fieldName "extra-libraries"
[ (flag, lib) | flag@('-':'l':lib) <- all_ghc_options ]
[ (flag, lib) | flag@('-':'l':lib) <- ghc_options_no_rtsopts ]

, checkAlternatives fieldName "extra-libraries-static"
[ (flag, lib) | flag@('-':'l':lib) <- all_ghc_options ]
[ (flag, lib) | flag@('-':'l':lib) <- ghc_options_no_rtsopts ]

, checkAlternatives fieldName "extra-lib-dirs"
[ (flag, dir) | flag@('-':'L':dir) <- all_ghc_options ]
[ (flag, dir) | flag@('-':'L':dir) <- ghc_options_no_rtsopts ]

, checkAlternatives fieldName "extra-lib-dirs-static"
[ (flag, dir) | flag@('-':'L':dir) <- all_ghc_options ]
[ (flag, dir) | flag@('-':'L':dir) <- ghc_options_no_rtsopts ]

, checkAlternatives fieldName "frameworks"
[ (flag, fmwk) | (flag@"-framework", fmwk) <-
zip all_ghc_options (safeTail all_ghc_options) ]
zip ghc_options_no_rtsopts (safeTail ghc_options_no_rtsopts) ]

, checkAlternatives fieldName "extra-framework-dirs"
[ (flag, dir) | (flag@"-framework-path", dir) <-
zip all_ghc_options (safeTail all_ghc_options) ]
zip ghc_options_no_rtsopts (safeTail ghc_options_no_rtsopts) ]
]

where
all_ghc_options = concatMap getOptions (allBuildInfo pkg)
ghc_options_no_rtsopts = rmRtsOpts all_ghc_options
lib_ghc_options = concatMap (getOptions . libBuildInfo)
(allLibraries pkg)
test_ghc_options = concatMap (getOptions . testBuildInfo)
Expand Down Expand Up @@ -967,6 +968,11 @@ checkGhcOptions fieldName getOptions pkg =
enable e = Just (EnableExtension e)
disable e = Just (DisableExtension e)

rmRtsOpts :: [String] -> [String]
rmRtsOpts ("-rtsopts":_:xs) = rmRtsOpts xs
rmRtsOpts (x:xs) = x : rmRtsOpts xs
rmRtsOpts [] = []

checkCCOptions :: PackageDescription -> [PackageCheck]
checkCCOptions = checkCLikeOptions "C" "cc-options" ccOptions

Expand Down
4 changes: 4 additions & 0 deletions changelog.d/issue-4255
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
synopsis: Avoid spurious warnings from -with-rtsopts
packages: Cabal
issues: #4255
prs: #8183

0 comments on commit 0dd5ee6

Please sign in to comment.