Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent dependency on private library #5848

Merged
merged 5 commits into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Cabal/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ configure (pkg_descr0, pbi) cfg = do
(dependencySatisfiable
use_external_internal_deps
(fromFlagOrDefault False (configExactConfiguration cfg))
(fromFlagOrDefault False (configAllowDependingOnPrivateLibs cfg))
(packageName pkg_descr0)
installedPackageSet
internalPackageSet
Expand Down Expand Up @@ -882,6 +883,7 @@ getInternalPackages pkg_descr0 =
dependencySatisfiable
:: Bool -- ^ use external internal deps?
-> Bool -- ^ exact configuration?
-> Bool -- ^ allow depending on private libs?
-> PackageName
-> InstalledPackageIndex -- ^ installed set
-> Map PackageName (Maybe UnqualComponentName) -- ^ internal set
Expand All @@ -890,7 +892,9 @@ dependencySatisfiable
-> (Dependency -> Bool)
dependencySatisfiable
use_external_internal_deps
exact_config pn installedPackageSet internalPackageSet requiredDepsMap
exact_config
allow_private_deps
pn installedPackageSet internalPackageSet requiredDepsMap
(Dependency depName vr sublibs)

| exact_config
Expand Down Expand Up @@ -951,6 +955,9 @@ dependencySatisfiable
visible lib = maybe
False -- Does not even exist (wasn't in the depsMap)
(\ipi -> Installed.libVisibility ipi == LibraryVisibilityPublic
-- If the override is enabled, the visibility does
-- not matter (it's handled externally)
|| allow_private_deps
-- If it's a library of the same package then it's
-- always visible.
-- This is only triggered when passing a component
Expand Down
13 changes: 12 additions & 1 deletion Cabal/Distribution/Simple/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,13 @@ data ConfigFlags = ConfigFlags {
-- ^Halt and show an error message indicating an error in flag assignment
configRelocatable :: Flag Bool, -- ^ Enable relocatable package built
configDebugInfo :: Flag DebugInfoLevel, -- ^ Emit debug info.
configUseResponseFiles :: Flag Bool
configUseResponseFiles :: Flag Bool,
-- ^ Whether to use response files at all. They're used for such tools
-- as haddock, or or ld.
configAllowDependingOnPrivateLibs :: Flag Bool
-- ^ Allow depending on private sublibraries. This is used by external
-- tools (like cabal-install) so they can add multiple-public-libraries
-- compatibility to older ghcs by checking visibility externally.
}
deriving (Generic, Read, Show)

Expand Down Expand Up @@ -703,6 +707,13 @@ configureOptions showOrParseArgs =
configUseResponseFiles
(\v flags -> flags { configUseResponseFiles = v })
(boolOpt' ([], ["disable-response-files"]) ([], []))

,option "" ["allow-depending-on-private-libs"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be added to filterConfigureFlags as well, though since we don't set it anywhere, it's not a blocker for merging.

( "Allow depending on private libraries. "
++ "If set, the library visibility check MUST be done externally." )
configAllowDependingOnPrivateLibs
(\v flags -> flags { configAllowDependingOnPrivateLibs = v })
trueArg
]
where
liftInstallDirs =
Expand Down
3 changes: 2 additions & 1 deletion cabal-install/Distribution/Client/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ instance Semigroup SavedConfig where
configExactConfiguration = combine configExactConfiguration,
configFlagError = combine configFlagError,
configRelocatable = combine configRelocatable,
configUseResponseFiles = combine configUseResponseFiles
configUseResponseFiles = combine configUseResponseFiles,
configAllowDependingOnPrivateLibs = combine configAllowDependingOnPrivateLibs
}
where
combine = combine' savedConfigureFlags
Expand Down
6 changes: 4 additions & 2 deletions cabal-install/Distribution/Client/ProjectConfig/Legacy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,8 @@ convertToLegacyAllPackageConfig
configFlagError = mempty, --TODO: ???
configRelocatable = mempty,
configDebugInfo = mempty,
configUseResponseFiles = mempty
configUseResponseFiles = mempty,
configAllowDependingOnPrivateLibs = mempty
}

haddockFlags = mempty {
Expand Down Expand Up @@ -757,7 +758,8 @@ convertToLegacyPerPackageConfig PackageConfig {..} =
configFlagError = mempty, --TODO: ???
configRelocatable = packageConfigRelocatable,
configDebugInfo = packageConfigDebugInfo,
configUseResponseFiles = mempty
configUseResponseFiles = mempty,
configAllowDependingOnPrivateLibs = mempty
}

installFlags = mempty {
Expand Down
3 changes: 3 additions & 0 deletions cabal-install/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3390,6 +3390,9 @@ 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

setupHsConfigureArgs :: ElaboratedConfiguredPackage
-> [String]
Expand Down