Skip to content

Commit

Permalink
Override Cabal's library visibility check on GHC <8.8
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fgaz committed May 22, 2020
1 parent 03dd11a commit fa9e5fc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
10 changes: 10 additions & 0 deletions Cabal/Distribution/Simple/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module Distribution.Simple.Compiler (
backpackSupported,
arResponseFilesSupported,
libraryDynDirSupported,
libraryVisibilitySupported,

-- * Support for profiling detail levels
ProfDetailLevel(..),
Expand Down Expand Up @@ -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 =
Expand Down
4 changes: 1 addition & 3 deletions cabal-install/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
@@ -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"

Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit fa9e5fc

Please sign in to comment.