From 19f5aabd95dfe5c60d4d260387ce1b2857d4591e Mon Sep 17 00:00:00 2001 From: Francesco Gazzetta <fgaz@fgaz.me> Date: Fri, 22 May 2020 17:20:52 +0200 Subject: [PATCH] Override Cabal's library visibility check on GHC <8.8 GHC <8.8 isn't able to read the "visibility" field from the package database, since it's built against an older Cabal. For this reason, using multiple public libraries with it did not work (all sublibraries appeared as private). This patch makes cabal-install override Cabal's library visibility checks when GHC is older than 8.8, extending the multiple libraries feature compatibiliy to older GHCs. --- Cabal/Distribution/Simple/Compiler.hs | 10 ++++++++++ cabal-install/Distribution/Client/ProjectPlanning.hs | 4 +--- .../MultipleLibraries/Successful/cabal.test.hs | 5 +---- .../MultipleLibraries/T6083Pre/cabal.test.hs | 5 +---- .../MultipleLibraries/T6083PreMixin/cabal.test.hs | 5 +---- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Cabal/Distribution/Simple/Compiler.hs b/Cabal/Distribution/Simple/Compiler.hs index e2607405e3..141c33b94f 100644 --- a/Cabal/Distribution/Simple/Compiler.hs +++ b/Cabal/Distribution/Simple/Compiler.hs @@ -63,6 +63,7 @@ module Distribution.Simple.Compiler ( backpackSupported, arResponseFilesSupported, libraryDynDirSupported, + libraryVisibilitySupported, -- * Support for profiling detail levels ProfDetailLevel(..), @@ -380,6 +381,15 @@ profilingSupported comp = GHCJS -> True _ -> False +-- | Does this compiler support a package database entry with: +-- "visibility"? +libraryVisibilitySupported :: Compiler -> Bool +libraryVisibilitySupported comp = case compilerFlavor comp of + GHC -> v >= mkVersion [8,8] + _ -> False + where + v = compilerVersion comp + -- | Utility function for GHC only features ghcSupported :: String -> Compiler -> Bool ghcSupported key comp = diff --git a/cabal-install/Distribution/Client/ProjectPlanning.hs b/cabal-install/Distribution/Client/ProjectPlanning.hs index 5c3a345c43..c32b2de253 100644 --- a/cabal-install/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/Distribution/Client/ProjectPlanning.hs @@ -3412,9 +3412,7 @@ setupHsConfigureFlags (ReadyPackage elab@ElaboratedConfiguredPackage{..}) configUserInstall = mempty -- don't rely on defaults configPrograms_ = mempty -- never use, shouldn't exist configUseResponseFiles = mempty - -- TODO set to true when the solver can prevent private-library-deps by itself - -- (issue #6039) - configAllowDependingOnPrivateLibs = mempty + configAllowDependingOnPrivateLibs = Flag $ not $ libraryVisibilitySupported pkgConfigCompiler setupHsConfigureArgs :: ElaboratedConfiguredPackage -> [String] diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.test.hs b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.test.hs index 393ca17b51..8860658919 100644 --- a/cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.test.hs +++ b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.test.hs @@ -1,7 +1,4 @@ import Test.Cabal.Prelude -main = cabalTest $ do - -- https://github.com/haskell/cabal/pull/6047 should make this work for older GHCs too? - skipIf =<< ghcVersionIs (< mkVersion [8,8]) - +main = cabalTest $ cabal' "v2-run" ["pkg-abc:program"] >>= assertOutputContains "pkg-def:publib" diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.test.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.test.hs index 5819f9cb2e..1aa1889af1 100644 --- a/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.test.hs +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.test.hs @@ -2,8 +2,5 @@ import Test.Cabal.Prelude -- https://github.com/haskell/cabal/issues/6083 -- see pkg-abc.cabal -main = cabalTest $ do - -- https://github.com/haskell/cabal/pull/6047 should make this work for older GHCs too? - skipIf =<< ghcVersionIs (< mkVersion [8,8]) - +main = cabalTest $ cabal' "v2-run" ["pkg-abc:program"] >>= assertOutputContains "pkg-abc:pkg-def" diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.test.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.test.hs index 246480accf..dec445d9af 100644 --- a/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.test.hs +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.test.hs @@ -2,8 +2,5 @@ import Test.Cabal.Prelude -- This is like T6083Pre, but also goes via mixins -- -main = cabalTest $ do - -- https://github.com/haskell/cabal/pull/6047 should make this work for older GHCs too? - skipIf =<< ghcVersionIs (< mkVersion [8,8]) - +main = cabalTest $ cabal' "v2-run" ["pkg-abc:program"] >>= assertOutputContains "pkg-abc:pkg-def" -- GitLab