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

chore: Replace references to internal libraries with sublibraries #9576

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions Cabal-syntax/src/Distribution/PackageDescription/Parsec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ goSections specVer = traverse_ process
when (isJust prev) $
lift $
parseFailure pos $
"Multiple main libraries; have you forgotten to specify a name for an internal library?"
"Multiple main libraries; have you forgotten to specify a name for a sublibrary?"

commonStanzas <- use stateCommonStanzas
let name'' = LMainLibName
Expand Down Expand Up @@ -764,7 +764,7 @@ checkForUndefinedCustomSetup gpd = do
-- This is solution to https://github.com/haskell/cabal/issues/6083
--
-- Before 'cabal-version: 3.0' we didn't have a syntax specially
-- for referring to internal libraries. Internal library names
-- for referring to sublibraries. Sublibrary names
-- shadowed the outside ones.
--
-- Since 'cabal-version: 3.0' we have ability to write
Expand All @@ -782,10 +782,10 @@ checkForUndefinedCustomSetup gpd = do
-- pkg-name:pkg-name | may refer to sublib | always refers to external pkg |
--
-- In pre-3.4 case, if a package 'this-pkg' has a sublibrary 'pkg-name',
-- all dependency definitions will refer to that sublirary.
-- all dependency definitions will refer to that sublibrary.
--
-- In 3.4 and after case, 'pkg-name' will always refer to external package,
-- and to use internal library you have to say 'this-pkg:pkg-name'.
-- and to use sublibrary you have to say 'this-pkg:pkg-name'.
--
-- In summary, In 3.4 and after, the internal names don't shadow,
-- as there is an explicit syntax to refer to them,
Expand Down
2 changes: 1 addition & 1 deletion Cabal-syntax/src/Distribution/Types/Dependency.hs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ versionGuardMultilibs = do
unwords
[ "Sublibrary dependency syntax used."
, "To use this syntax the package needs to specify at least 'cabal-version: 3.0'."
, "Alternatively, if you are depending on an internal library, you can write"
, "Alternatively, if you are depending on a sublibrary, you can write"
, "directly the library name as it were a package."
]

Expand Down
2 changes: 1 addition & 1 deletion Cabal-syntax/src/Distribution/Types/LibraryVisibility.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import qualified Text.PrettyPrint as Disp
data LibraryVisibility
= -- | Can be used as a dependency for other packages
LibraryVisibilityPublic
| -- | Internal library, default
| -- | Sublibrary, default
LibraryVisibilityPrivate
deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)

Expand Down
11 changes: 5 additions & 6 deletions Cabal-syntax/src/Distribution/Types/MungedPackageName.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,21 @@ instance NFData MungedPackageName where rnf = genericRnf
-- | Computes the package name for a library. If this is the public
-- library, it will just be the original package name; otherwise,
-- it will be a munged package name recording the original package
-- name as well as the name of the internal library.
-- name as well as the name of the sublibrary.
--
-- A lot of tooling in the Haskell ecosystem assumes that if something
-- is installed to the package database with the package name 'foo',
-- then it actually is an entry for the (only public) library in package
-- 'foo'. With internal packages, this is not necessarily true:
-- a public library as well as arbitrarily many internal libraries may
-- a public library as well as arbitrarily many sublibraries may
-- come from the same package. To prevent tools from getting confused
-- in this case, the package name of these internal libraries is munged
-- in this case, the package name of these sublibraries is munged
-- so that they do not conflict the public library proper. A particular
-- case where this matters is ghc-pkg: if we don't munge the package
-- name, the inplace registration will OVERRIDE a different internal
-- library.
-- name, the inplace registration will OVERRIDE a different sublibrary.
--
-- We munge into a reserved namespace, "z-", and encode both the
-- component name and the package name of an internal library using the
-- component name and the package name of a sublibrary using the
-- following format:
--
-- compat-pkg-name ::= "z-" package-name "-z-" library-name
Expand Down
2 changes: 1 addition & 1 deletion Cabal-syntax/src/Distribution/Types/UnqualComponentName.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ instance NFData UnqualComponentName where
-- component, if one is defined with that name.
--
-- 2018-12-21: These "legacy" situations are not legacy.
-- We can @build-depends@ on the internal library. However
-- We can @build-depends@ on the sublibrary. However
-- Now dependency contains @Set LibraryName@, and we should use that.
--
-- @since 2.0.0.2
Expand Down
2 changes: 1 addition & 1 deletion Cabal-tests/tests/ParserTests/errors/multiple-libs.errors
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION: Just (mkVersion [1,20])
multiple-libs.cabal:12:1: Multiple main libraries; have you forgotten to specify a name for an internal library?
multiple-libs.cabal:12:1: Multiple main libraries; have you forgotten to specify a name for a sublibrary?
2 changes: 1 addition & 1 deletion Cabal-tests/tests/custom-setup/CabalDoctestSetup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ generateBuildModule testSuiteName flags pkg lbi = do
#if MIN_VERSION_Cabal(3,0,0)
mbLibraryName = NameLib . fmap unUnqualComponentName . libraryNameString . libName
#elif MIN_VERSION_Cabal(2,0,0)
-- Cabal-2.0 introduced internal libraries, which are named.
-- Cabal-2.0 introduced sublibraries, which are named.
mbLibraryName = NameLib . fmap unUnqualComponentName . libName
#else
-- Before that, there was only ever at most one library per
Expand Down
10 changes: 5 additions & 5 deletions Cabal/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
scripts to backwards-incompatible changes in this release:
https://github.com/haskell/cabal/wiki/3.0-migration-guide.
* Due to [#5119](https://github.com/haskell/cabal/issues/5119), the
`cabal check` warning for bounds on internal libraries has been
`cabal check` warning for bounds on sublibraries has been
disabled.
* Introduce set notation for `^>=` and `==` operators
([#5906](https://github.com/haskell/cabal/pull/5906)).
Expand Down Expand Up @@ -148,7 +148,7 @@

# 2.4.0.0 [Mikhail Glushenkov](mailto:mikhail.glushenkov@gmail.com) September 2018
* Due to [#5119](https://github.com/haskell/cabal/issues/5119), the
`cabal check` warning for bounds on internal libraries has been
`cabal check` warning for bounds on sublibraries has been
disabled.
* `Distribution.Simple.Haddock` now checks to ensure that it
does not erroneously call Haddock with no target modules.
Expand Down Expand Up @@ -341,9 +341,9 @@
* Dropped support for versions of GHC earlier than 6.12 (#3111).
* GHC compatibility window for the Cabal library has been extended
to five years (#3838).
* Convenience/internal libraries are now supported (#269).
An internal library is declared using the stanza `library
'libname'`. Packages which use internal libraries can
* Convenience/sublibraries are now supported (#269).
A sublibrary is declared using the stanza `library
'libname'`. Packages which use sublibraries can
result in multiple registrations; thus `--gen-pkg-config`
can now output a directory of registration scripts rather than
a single file.
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Backpack/Id.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ computeComponentId deterministic mb_ipid mb_cid pid cname mb_details =
--
-- * We use the *compatibility* package name and version. For
-- public libraries this is just the package identifier; for
-- internal libraries, it's something like "z-pkgname-z-libname-0.1".
-- sublibraries, it's something like "z-pkgname-z-libname-0.1".
-- See 'computeCompatPackageName' for more details.
--
-- The mapping for GHC 7.10:
Expand Down
12 changes: 6 additions & 6 deletions Cabal/src/Distribution/PackageDescription/Check/Warning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,18 @@ ppExplanation NoVersionField = "No 'version' field."
ppExplanation NoTarget =
"No executables, libraries, tests, or benchmarks found. Nothing to do."
ppExplanation UnnamedInternal =
"Found one or more unnamed internal libraries. Only the non-internal"
++ " library can have the same name as the package."
"Found one or more unnamed sublibraries. Only the non-sublibrary"
++ " can have the same name as the package."
ppExplanation (DuplicateSections duplicateNames) =
"Duplicate sections: "
++ commaSep (map unUnqualComponentName duplicateNames)
++ ". The name of every library, executable, test suite,"
++ " and benchmark section in the package must be unique."
ppExplanation (IllegalLibraryName pname) =
"Illegal internal library name "
"Illegal sublibrary name "
++ prettyShow pname
++ ". Internal libraries cannot have the same name as the package."
++ " Maybe you wanted a non-internal library?"
++ ". Sublibraries cannot have the same name as the package."
++ " Maybe you wanted a non-sublibrary?"
++ " If so, rewrite the section stanza"
++ " from 'library: '"
++ prettyShow pname
Expand Down Expand Up @@ -455,7 +455,7 @@ ppExplanation (InvalidTestWith testedWithImpossibleRanges) =
++ "'tested-with: GHC==6.10.4 && ==6.12.3'."
ppExplanation (ImpossibleInternalDep depInternalLibWithImpossibleVersion) =
"The package has an impossible version range for a dependency on an "
++ "internal library: "
++ "sublibrary: "
++ commaSep (map prettyShow depInternalLibWithImpossibleVersion)
++ ". This version range does not include the current package, and must "
++ "be removed as the current package's library will always be used."
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ testSuiteLibV09AsLibAndExe
-- This is, like, the one place where we use a CTestName for a library.
-- Should NOT use library name, since that could conflict!
PackageIdentifier pkg_name pkg_ver = package pkg_descr
-- Note: we do make internal library from the test!
-- Note: we do make sublibrary from the test!
compat_name = MungedPackageName pkg_name (LSubLibName (testName test))
compat_key = computeCompatPackageKey (compiler lbi) compat_name pkg_ver (componentUnitId clbi)
libClbi =
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/Build/Macros.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
-- /package/ in use is @>= A.B.C@, using the normal ordering on version
-- numbers.
--
-- TODO Figure out what to do about backpack and internal libraries. It is very
-- TODO Figure out what to do about backpack and sublibraries. It is very
-- suspicious that this stuff works with munged package identifiers
module Distribution.Simple.Build.Macros
( generateCabalMacrosHeader
Expand Down
6 changes: 3 additions & 3 deletions Cabal/src/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ selectDependency
-- Executable my-exec
-- build-depends: MyLibrary
--
-- We want "build-depends: MyLibrary" always to match the internal library
-- We want "build-depends: MyLibrary" always to match the sublibrary
-- even if there is a newer installed library "MyLibrary-0.2".
if dep_pkgname == pn
then
Expand All @@ -1618,7 +1618,7 @@ selectDependency
where
pn = packageName pkgid

-- It's an internal library, and we're not per-component build
-- It's a sublibrary, and we're not per-component build
do_internal lib
| Set.member lib internalIndex =
Right $ InternalDependency $ PackageIdentifier dep_pkgname $ packageVersion pkgid
Expand Down Expand Up @@ -1649,7 +1649,7 @@ selectDependency
-- If we know the exact pkg to use, then use it.
Just pkginstance -> Right pkginstance
Nothing -> case pickLastIPI $ PackageIndex.lookupInternalDependency installedIndex pn vr lib of
-- It's an internal library, being looked up externally
-- It's a sublibrary, being looked up externally
Nothing -> Left (DependencyMissingInternal dep_pkgname lib)
Just pkg -> Right pkg
return $ ExternalDependency $ ipiToPreExistingComponent ipi
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/Install.hs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ copyComponent verbosity pkg_descr lbi (CLib lib) clbi copydest = do

case libName lib of
LMainLibName -> noticeNoWrap verbosity ("Installing library in " ++ libPref)
LSubLibName n -> noticeNoWrap verbosity ("Installing internal library " ++ prettyShow n ++ " in " ++ libPref)
LSubLibName n -> noticeNoWrap verbosity ("Installing sublibrary " ++ prettyShow n ++ " in " ++ libPref)

-- install include files for all compilers - they may be needed to compile
-- haskell files (using the CPP extension)
Expand Down
8 changes: 4 additions & 4 deletions Cabal/src/Distribution/Simple/LocalBuildInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ depLibraryPaths inplace relative lbi clbi = do

-- Why do we go through all the trouble of a hand-crafting
-- internalLibs, when 'installedPkgs' actually contains the
-- internal libraries? The trouble is that 'installedPkgs'
-- sublibraries? The trouble is that 'installedPkgs'
-- may contain *inplace* entries, which we must NOT use for
-- not inplace 'depLibraryPaths' (e.g., for RPATH calculation).
-- See #4025 for more details. This is all horrible but it
-- is a moot point if you are using a per-component build,
-- because you never have any internal libraries in this case;
-- because you never have any sublibraries in this case;
-- they're all external.
let external_ipkgs = filter is_external (allPackages (installedPkgs lbi))
is_external ipkg = not (installedUnitId ipkg `elem` internalDeps)
Expand Down Expand Up @@ -365,9 +365,9 @@ absoluteInstallCommandDirs pkg lbi uid copydest =
-- one hand, the easiest to understand Haddock documentation
-- path is pkgname-0.1, which means it's per-package (not
-- per-component). But this means that it's impossible to
-- install Haddock documentation for internal libraries. We'll
-- install Haddock documentation for sublibraries. We'll
-- keep this constraint for now; this means you can't use
-- Cabal to Haddock internal libraries. This does not seem
-- Cabal to Haddock sublibraries. This does not seem
-- like a big problem.
docdir = docdir dirs'
, htmldir = htmldir dirs'
Expand Down
10 changes: 5 additions & 5 deletions Cabal/src/Distribution/Simple/PackageIndex.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
-- An index of packages whose primary key is 'UnitId'. Public libraries
-- are additionally indexed by 'PackageName' and 'Version'.
-- Technically, these are an index of *units* (so we should eventually
-- rename it to 'UnitIndex'); but in the absence of internal libraries
-- rename it to 'UnitIndex'); but in the absence of sublibraries
-- or Backpack each unit is equivalent to a package.
--
-- While 'PackageIndex' is parametric over what it actually records,
Expand Down Expand Up @@ -344,7 +344,7 @@ deleteSourcePackageId pkgid original@(PackageIndex pids pnames) =

-- | Removes all packages with this (case-sensitive) name from the index.
--
-- NB: Does NOT delete internal libraries from this package.
-- NB: Does NOT delete sublibraries from this package.
deletePackageName
:: PackageName
-> InstalledPackageIndex
Expand Down Expand Up @@ -409,7 +409,7 @@ allPackagesBySourcePackageId index =
--
-- They are grouped by source package id and library name.
--
-- This DOES include internal libraries.
-- This DOES include sublibraries.
allPackagesBySourcePackageIdAndLibName
:: HasUnitId a
=> PackageIndex a
Expand Down Expand Up @@ -452,7 +452,7 @@ lookupComponentId index cid =
-- preference, with the most preferred first.
lookupSourcePackageId :: PackageIndex a -> PackageId -> [a]
lookupSourcePackageId index pkgid =
-- Do not lookup internal libraries
-- Do not lookup sublibraries
case Map.lookup (packageName pkgid, LMainLibName) (packageIdIndex index) of
Nothing -> []
Just pvers -> case Map.lookup (packageVersion pkgid) pvers of
Expand All @@ -473,7 +473,7 @@ lookupPackageName
-> PackageName
-> [(Version, [a])]
lookupPackageName index name =
-- Do not match internal libraries
-- Do not match sublibraries
case Map.lookup (name, LMainLibName) (packageIdIndex index) of
Nothing -> []
Just pvers -> Map.toList pvers
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/Program/HcPkg.hs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ mungePackagePaths pkgroot pkginfo =

-- Older installed package info files did not have the installedUnitId
-- field, so if it is missing then we fill it as the source package ID.
-- NB: Internal libraries not supported.
-- NB: Sublibraries not supported.
setUnitId :: InstalledPackageInfo -> InstalledPackageInfo
setUnitId
pkginfo@InstalledPackageInfo
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/Register.hs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ register
register pkg_descr lbi0 flags =
-- Duncan originally asked for us to not register/install files
-- when there was no public library. But with per-component
-- configure, we legitimately need to install internal libraries
-- configure, we legitimately need to install sublibraries
-- so that we can get them. So just unconditionally install.
doRegister
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ convIPI' (ShadowPkgs sip) idx =
-- apply shadowing whenever there are multiple installed packages with
-- the same version
[ maybeShadow (convIP idx pkg)
-- IMPORTANT to get internal libraries. See
-- Note [Index conversion with internal libraries]
-- IMPORTANT to get sublibraries. See
-- Note [Index conversion with sublibraries]
| (_, pkgs) <- SI.allPackagesBySourcePackageIdAndLibName idx
, (maybeShadow, pkg) <- zip (id : repeat shadow) pkgs ]
where
Expand All @@ -83,7 +83,7 @@ convIPI' (ShadowPkgs sip) idx =
convId :: IPI.InstalledPackageInfo -> (PN, I)
convId ipi = (pn, I ver $ Inst $ IPI.installedUnitId ipi)
where MungedPackageId mpn ver = mungedId ipi
-- HACK. See Note [Index conversion with internal libraries]
-- HACK. See Note [Index conversion with sublibraries]
pn = encodeCompatPackageName mpn

-- | Convert a single installed package into the solver-specific format.
Expand All @@ -93,7 +93,7 @@ convIP idx ipi =
Left u -> (pn, i, PInfo [] M.empty M.empty (Just (Broken u)))
Right fds -> (pn, i, PInfo fds components M.empty Nothing)
where
-- TODO: Handle sub-libraries and visibility.
-- TODO: Handle sublibraries and visibility.
components =
M.singleton (ExposedLib LMainLibName)
ComponentInfo {
Expand All @@ -108,11 +108,11 @@ convIP idx ipi =
comp = componentNameToComponent $ CLibName $ IPI.sourceLibName ipi
-- TODO: Installed packages should also store their encapsulations!

-- Note [Index conversion with internal libraries]
-- Note [Index conversion with sublibraries]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Something very interesting happens when we have internal libraries
-- Something very interesting happens when we have sublibraries
-- in our index. In this case, we maybe have p-0.1, which itself
-- depends on the internal library p-internal ALSO from p-0.1.
-- depends on the sublibrary p-internal ALSO from p-0.1.
-- Here's the danger:
--
-- - If we treat both of these packages as having PN "p",
Expand Down Expand Up @@ -146,7 +146,7 @@ convIPId dr comp idx ipid =
case SI.lookupUnitId idx ipid of
Nothing -> Left ipid
Just ipi -> let (pn, i) = convId ipi
name = ExposedLib LMainLibName -- TODO: Handle sub-libraries.
name = ExposedLib LMainLibName -- TODO: Handle sublibraries.
in Right (D.Simple (LDep dr (Dep (PkgComponent pn name) (Fixed i))) comp)
-- NB: something we pick up from the
-- InstalledPackageIndex is NEVER an executable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ nonSetupDeps :: Monoid a => ComponentDeps a -> a
nonSetupDeps = select (/= ComponentSetup)

-- | Library dependencies proper only. (Includes dependencies
-- of internal libraries.)
-- of sublibraries.)
libraryDeps :: Monoid a => ComponentDeps a -> a
libraryDeps = select (\c -> case c of ComponentSubLib _ -> True
ComponentLib -> True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ instance Structured InstSolverPackage

instance Package InstSolverPackage where
packageId i =
-- HACK! See Note [Index conversion with internal libraries]
-- HACK! See Note [Index conversion with sublibraries]
let MungedPackageId mpn v = mungedId i
in PackageIdentifier (encodeCompatPackageName mpn) v

Expand Down
2 changes: 1 addition & 1 deletion cabal-install/bash-completion/cabal
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function _cabal_list_packages ()
# - ‹test-suite› for test suites
# - ‹benchmark› for benchmarks
# - ‹executable› for executables
# - ‹library› for internal libraries
# - ‹library› for sublibraries
# - ‹foreign-library› for foreign libraries
# - nothing for all components.
#
Expand Down
Loading
Loading