Skip to content

Commit 3e31042

Browse files
committed
Add a flag to allow depending on private libraries
This is intended to be used by tools like cabal-install so they can add multilibs-compatibility even to older ghcs
1 parent f14d4a2 commit 3e31042

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

Cabal/Distribution/Simple/Configure.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ configure (pkg_descr0, pbi) cfg = do
477477
(dependencySatisfiable
478478
use_external_internal_deps
479479
(fromFlagOrDefault False (configExactConfiguration cfg))
480+
(fromFlagOrDefault False (configAllowDependingOnPrivateLibs cfg))
480481
(packageName pkg_descr0)
481482
installedPackageSet
482483
internalPackageSet
@@ -882,6 +883,7 @@ getInternalPackages pkg_descr0 =
882883
dependencySatisfiable
883884
:: Bool -- ^ use external internal deps?
884885
-> Bool -- ^ exact configuration?
886+
-> Bool -- ^ allow depending on private libs?
885887
-> PackageName
886888
-> InstalledPackageIndex -- ^ installed set
887889
-> Map PackageName (Maybe UnqualComponentName) -- ^ internal set
@@ -890,7 +892,9 @@ dependencySatisfiable
890892
-> (Dependency -> Bool)
891893
dependencySatisfiable
892894
use_external_internal_deps
893-
exact_config pn installedPackageSet internalPackageSet requiredDepsMap
895+
exact_config
896+
allow_private_deps
897+
pn installedPackageSet internalPackageSet requiredDepsMap
894898
(Dependency depName vr sublibs)
895899

896900
| exact_config
@@ -951,6 +955,9 @@ dependencySatisfiable
951955
visible lib = maybe
952956
False -- Does not even exist (wasn't in the depsMap)
953957
(\ipi -> Installed.libVisibility ipi == LibraryVisibilityPublic
958+
-- If the override is enabled, the visibility does
959+
-- not matter (it's handled externally)
960+
|| allow_private_deps
954961
-- If it's a library of the same package then it's
955962
-- always visible.
956963
-- This is only triggered when passing a component

Cabal/Distribution/Simple/Setup.hs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,13 @@ data ConfigFlags = ConfigFlags {
273273
-- ^Halt and show an error message indicating an error in flag assignment
274274
configRelocatable :: Flag Bool, -- ^ Enable relocatable package built
275275
configDebugInfo :: Flag DebugInfoLevel, -- ^ Emit debug info.
276-
configUseResponseFiles :: Flag Bool
276+
configUseResponseFiles :: Flag Bool,
277277
-- ^ Whether to use response files at all. They're used for such tools
278278
-- as haddock, or or ld.
279+
configAllowDependingOnPrivateLibs :: Flag Bool
280+
-- ^ Allow depending on private sublibraries. This is used by external
281+
-- tools (like cabal-install) so they can add multiple-public-libraries
282+
-- compatibility to older ghcs by checking visibility externally.
279283
}
280284
deriving (Generic, Read, Show)
281285

@@ -703,6 +707,13 @@ configureOptions showOrParseArgs =
703707
configUseResponseFiles
704708
(\v flags -> flags { configUseResponseFiles = v })
705709
(boolOpt' ([], ["disable-response-files"]) ([], []))
710+
711+
,option "" ["allow-depending-on-private-libs"]
712+
( "Allow depending on private libraries. "
713+
++ "If set, the library visibility check MUST be done externally." )
714+
configAllowDependingOnPrivateLibs
715+
(\v flags -> flags { configAllowDependingOnPrivateLibs = v })
716+
trueArg
706717
]
707718
where
708719
liftInstallDirs =

cabal-install/Distribution/Client/Config.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ instance Semigroup SavedConfig where
413413
configExactConfiguration = combine configExactConfiguration,
414414
configFlagError = combine configFlagError,
415415
configRelocatable = combine configRelocatable,
416-
configUseResponseFiles = combine configUseResponseFiles
416+
configUseResponseFiles = combine configUseResponseFiles,
417+
configAllowDependingOnPrivateLibs = combine configAllowDependingOnPrivateLibs
417418
}
418419
where
419420
combine = combine' savedConfigureFlags

cabal-install/Distribution/Client/ProjectConfig/Legacy.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,8 @@ convertToLegacyAllPackageConfig
687687
configFlagError = mempty, --TODO: ???
688688
configRelocatable = mempty,
689689
configDebugInfo = mempty,
690-
configUseResponseFiles = mempty
690+
configUseResponseFiles = mempty,
691+
configAllowDependingOnPrivateLibs = mempty
691692
}
692693

693694
haddockFlags = mempty {
@@ -757,7 +758,8 @@ convertToLegacyPerPackageConfig PackageConfig {..} =
757758
configFlagError = mempty, --TODO: ???
758759
configRelocatable = packageConfigRelocatable,
759760
configDebugInfo = packageConfigDebugInfo,
760-
configUseResponseFiles = mempty
761+
configUseResponseFiles = mempty,
762+
configAllowDependingOnPrivateLibs = mempty
761763
}
762764

763765
installFlags = mempty {

cabal-install/Distribution/Client/ProjectPlanning.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3390,6 +3390,9 @@ setupHsConfigureFlags (ReadyPackage elab@ElaboratedConfiguredPackage{..})
33903390
configUserInstall = mempty -- don't rely on defaults
33913391
configPrograms_ = mempty -- never use, shouldn't exist
33923392
configUseResponseFiles = mempty
3393+
-- TODO set to true when the solver can prevent private-library-deps by itself
3394+
-- (issue #6039)
3395+
configAllowDependingOnPrivateLibs = mempty
33933396

33943397
setupHsConfigureArgs :: ElaboratedConfiguredPackage
33953398
-> [String]

0 commit comments

Comments
 (0)