diff --git a/Cabal/src/Distribution/PackageDescription/Check.hs b/Cabal/src/Distribution/PackageDescription/Check.hs index 13094319151..29f158b8f08 100644 --- a/Cabal/src/Distribution/PackageDescription/Check.hs +++ b/Cabal/src/Distribution/PackageDescription/Check.hs @@ -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) @@ -967,6 +968,11 @@ checkGhcOptions fieldName getOptions pkg = enable e = Just (EnableExtension e) disable e = Just (DisableExtension e) + rmRtsOpts :: [String] -> [String] + rmRtsOpts ("-with-rtsopts":_:xs) = rmRtsOpts xs + rmRtsOpts (x:xs) = x : rmRtsOpts xs + rmRtsOpts [] = [] + checkCCOptions :: PackageDescription -> [PackageCheck] checkCCOptions = checkCLikeOptions "C" "cc-options" ccOptions diff --git a/cabal-testsuite/PackageTests/RtsOptsClean/LICENSE b/cabal-testsuite/PackageTests/RtsOptsClean/LICENSE new file mode 100644 index 00000000000..6b1d0bfabc3 --- /dev/null +++ b/cabal-testsuite/PackageTests/RtsOptsClean/LICENSE @@ -0,0 +1 @@ +LICENSE diff --git a/cabal-testsuite/PackageTests/RtsOptsClean/Main.hs b/cabal-testsuite/PackageTests/RtsOptsClean/Main.hs new file mode 100644 index 00000000000..c2e4af9606d --- /dev/null +++ b/cabal-testsuite/PackageTests/RtsOptsClean/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = undefined diff --git a/cabal-testsuite/PackageTests/RtsOptsClean/my.cabal b/cabal-testsuite/PackageTests/RtsOptsClean/my.cabal new file mode 100644 index 00000000000..a5f7ff1e905 --- /dev/null +++ b/cabal-testsuite/PackageTests/RtsOptsClean/my.cabal @@ -0,0 +1,19 @@ +name: RtsOptsClean +version: 0.1 +author: Artem Pelenitsyn +synopsis: Make sure -with-rtsopts do not produce spurious warnings (fix #4255) +category: PackageTests +build-type: Simple +cabal-version: 2.0 + +description: + Make sure -with-rtsopts do not produce spurious warnings + +Executable RtsOptsClean + default-language: Haskell2010 + build-depends: base <5.0 + main-is: + Main.hs + ghc-options: + -rtsopts + -with-rtsopts "-I0" diff --git a/cabal-testsuite/PackageTests/RtsOptsClean/setup.cabal.out b/cabal-testsuite/PackageTests/RtsOptsClean/setup.cabal.out new file mode 100644 index 00000000000..95acd6aa1eb --- /dev/null +++ b/cabal-testsuite/PackageTests/RtsOptsClean/setup.cabal.out @@ -0,0 +1,2 @@ +# Setup configure +Configuring RtsOptsClean-0.1... diff --git a/cabal-testsuite/PackageTests/RtsOptsClean/setup.out b/cabal-testsuite/PackageTests/RtsOptsClean/setup.out new file mode 100644 index 00000000000..95acd6aa1eb --- /dev/null +++ b/cabal-testsuite/PackageTests/RtsOptsClean/setup.out @@ -0,0 +1,2 @@ +# Setup configure +Configuring RtsOptsClean-0.1... diff --git a/cabal-testsuite/PackageTests/RtsOptsClean/setup.test.hs b/cabal-testsuite/PackageTests/RtsOptsClean/setup.test.hs new file mode 100644 index 00000000000..7c85bd662b3 --- /dev/null +++ b/cabal-testsuite/PackageTests/RtsOptsClean/setup.test.hs @@ -0,0 +1,6 @@ +import Test.Cabal.Prelude + +-- Test that setup shows all the 'autogen-modules' warnings. +main = setupAndCabalTest $ do + setup' "configure" [] >>= + assertOutputDoesNotContain "Warning: Instead of 'ghc-options: -I0' use 'include-dirs: 0'" diff --git a/changelog.d/issue-4255 b/changelog.d/issue-4255 new file mode 100644 index 00000000000..b1a5f199660 --- /dev/null +++ b/changelog.d/issue-4255 @@ -0,0 +1,4 @@ +synopsis: Avoid spurious warnings from -with-rtsopts +packages: Cabal +issues: #4255 +prs: #8183