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

Cabal confused with sublibrary when same-named remote package exists #9122

Closed
merijn opened this issue Jul 13, 2023 · 13 comments · Fixed by #9132
Closed

Cabal confused with sublibrary when same-named remote package exists #9122

merijn opened this issue Jul 13, 2023 · 13 comments · Fixed by #9132

Comments

@merijn
Copy link
Collaborator

merijn commented Jul 13, 2023

Describe the bug
According to the documentation, the correct way to refer to the (unnamed) main library of a package foo is foo:foo, however specifying bounds on foo:foo when a local library named foo exists, gets interpreted as a bound on the local library. As a result it's impossible to have a package with local library foo:conduit that depends on conduit or conduit:conduit, as any bounds get interpreted as bounds on foo:conduit.

To Reproduce
Steps to reproduce the behavior:

Create a package with a local library whose name matches an existing package, and try to add a bound on the existing package.

$ cabal build ...

Expected behavior
Any bounds on conduit:conduit apply to the conduit package/library, not the local library named conduit.

System information

  • cabal version 3.10

Additional context
Add any other context about the problem here.

@ulysses4ever ulysses4ever changed the title Cabal not correctly resolving packages when a public library of the same name exists Solver confused with sublibrary when same-named remote package exists Jul 13, 2023
@phadej
Copy link
Collaborator

phadej commented Jul 13, 2023

@merijn which cabal-version you are using. How foo:foo is treated has changed in cabal-version: 3.4 exactly to avoid name shadowing issues.

From https://cabal.readthedocs.io/en/stable/file-format-changelog.html#cabal-version-3-4

Dependencies to sublibraries must be specified explicitly, even for current package. For example: build-depends: mypackage:internal-lib This way you can have an internal library with the same name as some external dependency.

Please provide a reproducer.

@merijn
Copy link
Collaborator Author

merijn commented Jul 14, 2023

Originally this was cabal-version: 3.0 with cabal-install 3.10. I was just trying cabal-version: 3.4, but the linked change requiring that internal packages are fully qualified does not seem to properly work either, i.e. both using conduit or conduit:conduit as dependency still gets interpreted as a dependency on the internal library.

This is rather "in progress" code, so I will try to shrink it to a reproducer.

@merijn
Copy link
Collaborator Author

merijn commented Jul 14, 2023

I created a reproducer here: https://github.com/merijn/cabal-repro

You can try as-is, or trying changing the conduit dependency to conduit:conduit, either will result in the same error:

Error: cabal: The package has an impossible version range for a dependency on
an internal library: conduit ^>=1.3.5. This version range does not include the
current package, and must be removed as the current package's library will
always be used.

If I understand the docs linked by phadej, only repro:conduit should ever refer to the local component in 3.4 and later.

@merijn
Copy link
Collaborator Author

merijn commented Jul 14, 2023

This seems to imply that the 3.4 change never actually worked as intended, behaviour is identical to cabal-version 3.0, only the error has slightly changed.

@Kleidukos
Copy link
Member

I can reproduce this on the 3.6 provided by ghcup and 3.11

@phadej
Copy link
Collaborator

phadej commented Jul 14, 2023

I cannot reproduce.

[polinukli] /codetmp/cabal-repro master % cabal --version
cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal library 
[polinukli] /codetmp/cabal-repro master % cabal build --dry-run
Build profile: -w ghc-8.6.5 -O1
In order, the following would be built (use -v for more details):
 - conduit-1.3.5 (lib) (requires build)
 - repro-0.1.0 (lib) (first run)
 - repro-0.1.0 (lib:conduit) (first run)

cabal-plan prints

% cabal-plan
using '/codetmp/cabal-repro' as project root

Tree
~~~~

repro-0.1.0
 └─ base-4.12.0.0
     ├─ ghc-prim-0.5.3
     │   └─ rts-1.0
     ├─ integer-gmp-1.0.2.0
     │   └─ ghc-prim-0.5.3 ┄┄
     └─ rts-1.0 ┄┄
repro-0.1.0
 [repro-0.1.0:lib:"conduit"]
 ├─ base-4.12.0.0 ┄┄
 └─ conduit-1.3.5

as expected.

Cannot reproduce with cabal-install-3.10.1.0 either:

[polinukli] /codetmp/cabal-repro master % ~/.ghcup/bin/cabal-3.10.1.0 --version      
cabal-install version 3.10.1.0
compiled using version 3.10.1.0 of the Cabal library 
[polinukli] /codetmp/cabal-repro master % ~/.ghcup/bin/cabal-3.10.1.0 build --dry-run
Build profile: -w ghc-8.6.5 -O1
In order, the following would be built (use -v for more details):
 - conduit-1.3.5 (lib) (requires build)
 - repro-0.1.0 (lib) (first run)
 - repro-0.1.0 (lib:conduit) (first run)

@phadej
Copy link
Collaborator

phadej commented Jul 14, 2023

I see. When you actually try to build the package, something in Cabal building code fails. I.e. the important bit is

cabal: Failed to build repro-0.1.0. The failure occurred during the configure
step.

cabal-install's solver and Cabal-syntax parser work correctly. It's latter stages which seem to fail, i.e. actually executing the build plan.


EDIT: compare with cabal-version: 3.0 behavior:

% cabal build --dry-run 
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] next goal: repro (user goal)
[__0] rejecting: repro-0.1.0 (conflict: repro==0.1.0, repro => repro (lib
conduit)^>=1.3.5)
[__0] fail (backjumping, conflict set: repro)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: repro

There the solving fails as name shadowing occurs.

fgaz added a commit to fgaz/cabal that referenced this issue Jul 16, 2023
@fgaz fgaz changed the title Solver confused with sublibrary when same-named remote package exists Cabal confused with sublibrary when same-named remote package exists Jul 18, 2023
fgaz added a commit to fgaz/cabal that referenced this issue Jul 18, 2023
fgaz added a commit to fgaz/cabal that referenced this issue Jul 24, 2023
@mergify mergify bot closed this as completed in #9132 Jul 24, 2023
mergify bot pushed a commit that referenced this issue Jul 24, 2023
Fixes #9122

(cherry picked from commit 4aa5f88)

# Conflicts:
#	Cabal/src/Distribution/PackageDescription/Check.hs
ffaf1 added a commit to ffaf1/cabal that referenced this issue Jul 25, 2023
When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See haskell#9132.
@merijn
Copy link
Collaborator Author

merijn commented Jul 25, 2023

This probably means the next cabal-install should include a bumped cabal-version, else there is no way to exclude older versions from attempting to build packages that rely on this behaviour, leading to errors for users.

@phadej
Copy link
Collaborator

phadej commented Jul 25, 2023

else there is no way to exclude older versions from attempting to build packages that rely on this behaviour, leading to errors for users.

No need to complicate things. Spec didn't change.

If people use newer cabal-install (which bundles newer Cabal library) the stuff will just work. So if user of old cabal install runs into this bug, they should upgrade cabal-install (e.g. to a minor release with a bugfix). If there are build-type: Custom packages involved (so bundled Cabal is not used), they can specify constraints or move away from using build-type: Custom (as using build-type: Custom is asking for troubles)

@merijn
Copy link
Collaborator Author

merijn commented Jul 25, 2023

I mean, the documented/specced behavirour of hasn't changed since cabal-version 3.4, but it's also never actually worked With Cabal, but the user has no indication that this is an issue with Cabal, and they should upgrade. Instead they just get a failing build and assume the package is broken.

I dunno what versions of cabal-install are in use "in the wild", but I'm gonna assume that "the next 3.10 minor release" will be a vast, vast minority. Leading to packages cryptically breaking on the vast majority of cabal-install's out there...

I can already hear the sound of tens of issues reporting build being broken...

@fgaz
Copy link
Member

fgaz commented Jul 25, 2023

@merijn are you suggesting that the fix shouldn't be backported? Distros, even stable ones, will update to patch releases, so I don't think there will be any major divide. The fix is also mentioned in the changelog, so it's not like it isn't documented

@merijn
Copy link
Collaborator Author

merijn commented Jul 25, 2023

@fgaz I'm not saying it shouldn't be backported (it wouldn't break anything that works currently).

I was more saying that if I want to publish something to hackage that relies on this behaviour, there is no way to prevent older (broken) Cabal's from attempting to build it. Like, if I finish updating my packages to use multiple public libraries, there is no way for me to indicate that the build is broken on cabal 3.4 through to some versions if 3.10, because the latest cabal-version is 3.8.

If the next cabal release (3.12?) includes a cabal-version bump, then that means I could use that cabal-version in my package to avoid people attempting to build it with broken versions of cabal-install. Because it seems inevitable that otherwise anyone relying on the specified behaviour will get a bunch of issues of "hey, this package is broken" from people with out of date cabal-install.

@phadej
Copy link
Collaborator

phadej commented Jul 25, 2023

@merijn, there is no way to prevent someone building broken stuff with old cabal-install. Old spec versions cannot be changed, old cabal-install interpreter them in the best way they know.

You can try to convince Hackage maintainers to make a change so Hackage would reject packages with internal libraries and cabal-version between 3.4 and next one. I.e. prevent distribution.

I don't know if there is next cabal-version coming up with some other features. I would not make an empty Cabal spec version just to have a "bug fix" marker.

if I finish updating my packages to use multiple public libraries, there is no way for me to indicate that the build is broken on cabal 3.4 through to some versions if 3.10,

That's life. Sometimes software is buggy. cabal-version tells the version of the spec, not the needed Cabal or cabal-install version to work with them. (They are related for convenience, different choice from e.g. GHC2021 language implemented first in GHC version I cannot remember without looking up).

EDIT addition: With Cabal-syntax and Cabal split, syntactical features are all contained in Cabal-syntax. The name shadowing change was purely syntactical. (I guess the previous Cabals are also buggy, they just cannot observe the bug).
Having cabal-version to indicate the lower bound of spec, Cabal-syntax, Cabal (and cabal-install or worse also stack) is just not scalable.

It's almost viable (but plenty of work) to build .cabal packages without using Cabal library, just Cabal-syntax. (Some cabal-version guarded stuff -- like how cabal_macros.h is generated -- are unfortunately in Cabal. I think these bits should be moved, but I have no word in how Cabal is developed anymore). You parse the package file and figure out how to call GHC to make/build a package. Someone somewhere might do that: hadrian for example.

ffaf1 added a commit to ffaf1/cabal that referenced this issue Aug 24, 2023
When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See haskell#9132.
fgaz added a commit that referenced this issue Sep 5, 2023
fgaz added a commit that referenced this issue Sep 5, 2023
fgaz added a commit that referenced this issue Sep 5, 2023
fgaz added a commit that referenced this issue Sep 6, 2023
fgaz added a commit that referenced this issue Sep 6, 2023
ffaf1 added a commit to ffaf1/cabal that referenced this issue Sep 6, 2023
When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See haskell#9132.
ffaf1 added a commit to ffaf1/cabal that referenced this issue Sep 19, 2023
When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See haskell#9132.
ffaf1 added a commit to ffaf1/cabal that referenced this issue Oct 3, 2023
When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See haskell#9132.
ffaf1 added a commit to ffaf1/cabal that referenced this issue Oct 3, 2023
When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See haskell#9132.
ffaf1 added a commit to ffaf1/cabal that referenced this issue Oct 5, 2023
When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See haskell#9132.
ffaf1 added a commit to ffaf1/cabal that referenced this issue Oct 24, 2023
When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See haskell#9132.
ffaf1 added a commit to ffaf1/cabal that referenced this issue Nov 9, 2023
When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See haskell#9132.
ffaf1 added a commit to ffaf1/cabal that referenced this issue Nov 9, 2023
When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See haskell#9132.
ffaf1 added a commit to ffaf1/cabal that referenced this issue Nov 11, 2023
When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See haskell#9132.
mergify bot added a commit that referenced this issue Nov 13, 2023
* Fix Semigroup target instance

When two target names are the same, `mappend`ing them should not
error but just pick the first name.

* Add `desugarBuildToolSimple`

* Reimplement cabal check

* Reorder test output

* Fix autogen modules tests .cabal files

* Add a number of tests

* Add test for #7423

i.e. Do not warn on -O2 if under off-by-default package configuration
flag conditional.

* Add a regression for:

    * Add another -WErrr test
        This is to make sure we do *not* report it if it is under
        a user, off-by-default flag.
    * Add test for non manual user flags.
    * Add “absolute path in extra-lib-dirs” test
    * Add if/else test
    * Add “dircheck on abspath” check
    * Add Package version internal test
    * Add PackageVersionsStraddle test

* Add changelog for #8427

* Integrate various reviews

* Integrate Artem’s review

(review) Clarify `combineNames` documentation

By explaining the way it operates (working if the two names are equal
or one is empty) and renaming the function from `combineName` to
`combineNames`.

(review) Use guards instead of if/then/else

(review) Match inside argument list

(review) Replace “white” with “allow”

(review) Fix typo in comment

(review) Fix typo in Check module documentation

(review) Harmonise indentation for `data` decls

First field goes in a new line than the data constructor, so we
have more space.

(review) Rename `Prim` module to `Types`

(review) Add checkPackageFilesGPD

`checkPackageFiles` — which works on PD — was used to perform IO. We
introduce a function that does the same thing but works on GPD (which
is more principled).

`checkPackageFiles` cannot just be removed, since it is part of the
interface of Distribution.PackageDescription.Check. Deprecation can
be planned once “new check” is up and running.

* Integrate Andreas’ review

(review) Add named section to missing upper bound check

“miss upper bound” checks will now list target type and name (“On
executable 'myexe', these packages miss upper bounds”) for easier
fixing by the user.

(review) remove `cabal gen-bounds` suggestion

Reasonable as `cabal gen-bounds` is stricter than `cabal check`, see
#8427 (comment)
Once `gen-bounds` behaves in line with `check` we can readd the
suggestion.

(review) Do not warn on shared bounds

When a target which depends on an internal library shares some
dependencies with the latter, do not warn on upper bounds.

An example is clearer

    library
     build-depends: text < 5
    ⁝
     build-depends: myPackage,        ← no warning, internal
                    text,             ← no warning, shared bound
                    monadacme         ← warning!

* Integrate Artem’s review /II

(review) Split Check.hs

Check.hs has been split in multiple file, each une sub 1000 lines:

Check              857 lines
Check.Common       147 lines
Check.Conditional  204 lines
Check.Monad        352 lines
Check.Paths        387 lines
Check.Target       765 lines
Check.Warning      865 lines

Migration guide:
- Check              GPD/PD checks plus work-tree checks.
- Check.Common       common types and functions that are
                     *not* part of monadic checking setup.
- Check.Conditional  checks on CondTree and related matter
                     (variables, duplicate modules).
- Check.Monad        Backbone of the checks, monadic inter-
                     face and related functions.
- Check.Paths        Checks on files, directories, globs.
- Check.Target       Checks on realised targets (libraries,
                     executables, benchmarks, testsuites).
- Check.Warning      Datatypes and strings for warnings
                     and severities.

(review) remove useless section header

(review) Fix typo

(review) Add warnings documentation (list)

For each warning, we document constructor/brief description
in the manual.  This might not be much useful as not but it
will come handy when introducing `--ignore=WARN` and similar
flags.

* (review Andreas) Clarify CheckExplanation comment

Whoever modifies `CheckExplanation` data constructors needs to be
aware that the documentation in  doc/cabal-commands.rst  has to be
updated too.

* Move internal Check modules to `other-modules`

No need to expose Distribution.PackageDescription.Check.*
to the world. API for checking, for cabal-install and other
tools, should be in Distribution.PackageDescription.Check.

* Make fourmolu happy

Cabal codebase has now a formatter/style standard (see #8950).

“Ravioli ravioli, give me the formuoli”

* Do not check for OptO in scripts

See #8963 for reason and clarification requests.

* Remove useless PackageId parameter

It is now in the Reader part of CheckM monad.

* Do not check PVP on internal targets

Internal: testsuite, benchmark.
See #8361.

* Make hlint happy

* Fix #9122

When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See #9132.

* Fix grammar

neither…nor, completing what done in #9162

* Integrate Brandon’s review: grammar

* Remove unnecessary `-fvia-C` check

Brandon’s review/II.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
julialongtin pushed a commit that referenced this issue Dec 2, 2023
* Fix Semigroup target instance

When two target names are the same, `mappend`ing them should not
error but just pick the first name.

* Add `desugarBuildToolSimple`

* Reimplement cabal check

* Reorder test output

* Fix autogen modules tests .cabal files

* Add a number of tests

* Add test for #7423

i.e. Do not warn on -O2 if under off-by-default package configuration
flag conditional.

* Add a regression for:

    * Add another -WErrr test
        This is to make sure we do *not* report it if it is under
        a user, off-by-default flag.
    * Add test for non manual user flags.
    * Add “absolute path in extra-lib-dirs” test
    * Add if/else test
    * Add “dircheck on abspath” check
    * Add Package version internal test
    * Add PackageVersionsStraddle test

* Add changelog for #8427

* Integrate various reviews

* Integrate Artem’s review

(review) Clarify `combineNames` documentation

By explaining the way it operates (working if the two names are equal
or one is empty) and renaming the function from `combineName` to
`combineNames`.

(review) Use guards instead of if/then/else

(review) Match inside argument list

(review) Replace “white” with “allow”

(review) Fix typo in comment

(review) Fix typo in Check module documentation

(review) Harmonise indentation for `data` decls

First field goes in a new line than the data constructor, so we
have more space.

(review) Rename `Prim` module to `Types`

(review) Add checkPackageFilesGPD

`checkPackageFiles` — which works on PD — was used to perform IO. We
introduce a function that does the same thing but works on GPD (which
is more principled).

`checkPackageFiles` cannot just be removed, since it is part of the
interface of Distribution.PackageDescription.Check. Deprecation can
be planned once “new check” is up and running.

* Integrate Andreas’ review

(review) Add named section to missing upper bound check

“miss upper bound” checks will now list target type and name (“On
executable 'myexe', these packages miss upper bounds”) for easier
fixing by the user.

(review) remove `cabal gen-bounds` suggestion

Reasonable as `cabal gen-bounds` is stricter than `cabal check`, see
#8427 (comment)
Once `gen-bounds` behaves in line with `check` we can readd the
suggestion.

(review) Do not warn on shared bounds

When a target which depends on an internal library shares some
dependencies with the latter, do not warn on upper bounds.

An example is clearer

    library
     build-depends: text < 5
    ⁝
     build-depends: myPackage,        ← no warning, internal
                    text,             ← no warning, shared bound
                    monadacme         ← warning!

* Integrate Artem’s review /II

(review) Split Check.hs

Check.hs has been split in multiple file, each une sub 1000 lines:

Check              857 lines
Check.Common       147 lines
Check.Conditional  204 lines
Check.Monad        352 lines
Check.Paths        387 lines
Check.Target       765 lines
Check.Warning      865 lines

Migration guide:
- Check              GPD/PD checks plus work-tree checks.
- Check.Common       common types and functions that are
                     *not* part of monadic checking setup.
- Check.Conditional  checks on CondTree and related matter
                     (variables, duplicate modules).
- Check.Monad        Backbone of the checks, monadic inter-
                     face and related functions.
- Check.Paths        Checks on files, directories, globs.
- Check.Target       Checks on realised targets (libraries,
                     executables, benchmarks, testsuites).
- Check.Warning      Datatypes and strings for warnings
                     and severities.

(review) remove useless section header

(review) Fix typo

(review) Add warnings documentation (list)

For each warning, we document constructor/brief description
in the manual.  This might not be much useful as not but it
will come handy when introducing `--ignore=WARN` and similar
flags.

* (review Andreas) Clarify CheckExplanation comment

Whoever modifies `CheckExplanation` data constructors needs to be
aware that the documentation in  doc/cabal-commands.rst  has to be
updated too.

* Move internal Check modules to `other-modules`

No need to expose Distribution.PackageDescription.Check.*
to the world. API for checking, for cabal-install and other
tools, should be in Distribution.PackageDescription.Check.

* Make fourmolu happy

Cabal codebase has now a formatter/style standard (see #8950).

“Ravioli ravioli, give me the formuoli”

* Do not check for OptO in scripts

See #8963 for reason and clarification requests.

* Remove useless PackageId parameter

It is now in the Reader part of CheckM monad.

* Do not check PVP on internal targets

Internal: testsuite, benchmark.
See #8361.

* Make hlint happy

* Fix #9122

When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See #9132.

* Fix grammar

neither…nor, completing what done in #9162

* Integrate Brandon’s review: grammar

* Remove unnecessary `-fvia-C` check

Brandon’s review/II.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
mergify bot added a commit that referenced this issue Dec 2, 2023
…ange only. (#9386)

* add more breadcrumbs for how to use remote packages.

* Hackage should be capitalized

* Update doc/cabal-project.rst

reword.

* Update doc/cabal-project.rst

reword.

* Update doc/cabal-project.rst

clearer.

* Update doc/cabal-project.rst

clearer!

* Update doc/cabal-project.rst

good mechanical description.

* wrap.

* Update doc/cabal-project.rst

add missing double ticks.

* clarify english, and follow a linguistic pattern better.

* Update doc/cabal-project.rst

* doc: render math with HTML to make it selectable (fix #8453) (#9361)

* doc: render math with HTML to make it selectable (fix #8453)

* Update doc/conf.py

Co-authored-by: Bryan Richter <[email protected]>

---------

Co-authored-by: Bryan Richter <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Avoid double space in "Executing install plan ..."

* Add a change log entry for double space avoidance

* Ignore CmmSourcesExe Demo

Ignore because it warns about missing MachDeps.h

* [cabal-7825] Implement external command system

Fix #2349 and #7825

* Bump to latest dependencies for GHC 9.8.1

* cabal.project: clean out obsolete `allow-newer`s

* update GH validate workflow to ghc 9.2.8, 9.4.7, 9.6.3

* Revert #3639 (Don't pass -package-db and -package flags to --abi-hash) (#9384)

* Revert #3639 (Don't pass -package-db and -package flags to --abi-hash)

With ghc>=9.6 `ghc --abi-hash` initialises the plugins so it will fail
if a cabal file specifies `ghc-options: -fplugin=Foo`.

Closes: #9375

* Also revert in GHC.hs

---------

Co-authored-by: Hamish Mackenzie <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Use the newer haskell-actions organisation

* Restructure Cabal documentation top-level parts

The goal is for users to easier find pages for typical problems through search engines and page navigation.
- The top-level layout is based on the popular documentation structure by https://documentation.divio.com/ to give a
   clear structure to users and future documentation contributors:
  * Guides: Present a solution to a single, atomic, typical user problem.
  * Reference: Describe user API (CLI fields, syntax etc) with technical rigour and completeness.
  * Explanation: Discuss background information, scope, design decisions etc.
- Move existing documentation roughly into these categories with minimal editing as the basis for further editing.
- Rename guide titles to mention how-to for improving SEO.
- Rename some files to improve SEO since that name becomes part of the URL (often called slug).
  Important page keywords should appear in the slug as well to make pages rank higher in search engines.

* Rename master_doc to root_doc (changed in version 4.0 of Sphynx)

* Add instance Ord for Field, FieldLine, SectionArg and Name

* Do not run CI for documentation changes

The github workflows are not run if the
changes are completely contained within
the doc/ subdirectory. The only exception
is the users-guide.yml github action.

* Move Backpack section to user guides

* Remove TBW virtual modules section

* Add reinstall test to LinkerOptions/NonignoredConfigs

* Record install options

* Reject index-states after last known index-state (#8944)

Co-authored-by: Javier Sagredo <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>

* Note how to do "not equal" with constraints

* Use comma with then

Co-authored-by: Artem Pelenitsyn <[email protected]>

* Use narrow rather than upset

* Say something about hackage deprecations

* Fix AutogenModulesToggling test

By converting this to a setupTest we use the in-tree Cabal library
rather than relying on a proxy of the GHC version to provide the right
Cabal library version.

Supersedes #9398

* Require version 3,11 of Cabal to support --semaphore flag

Fixes #9197

* Add dependencies used by `PackageTests` to exe:cabal-tests

The runner allows the tests to use extra dependencies and the custom Prelude
from 'cabal-testsuite'.
However, if the tests use a dependency, say 'directory', and there are two
packages with the same unit id available in the store, the test fails since
it doesn't know which one to pick.
By including an extra dependency to directory, we force the test runner to
use a specific version directory, fixing the test failure.

* Use Paths_cabal_install for cabal-install version number (#9421)

* Use PackageInfo for cabal-install version number

* Use Paths_cabal_install instead

* Adjust documentation

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Document --profiling-detail in setup-commands.

Fixes #9182

* Add test requirement to PR template

Adding test becomes a checkmark instead of “bonus points”.

* A 'cabal path' command. (#8879)

* Add a 'cabal path' command.

* Formatting fix.

* Another formatting fix.

* Categorise "cabal path" as global command.

* Allow individual paths to be printed.

* Less duplication.

* Add config-file to "cabal path".

* Use sum type instead of strings.

* cabal path: support --installdir.

* Add documentation.

* Better text.

* Formatting.

* Add some tests.

* Improve tests.

* Add changelog entry.

* Mention "cabal path" in directory documentation.

---------

Co-authored-by: Artem Pelenitsyn <[email protected]>

* Reimplement `cabal check` (#8427)

* Fix Semigroup target instance

When two target names are the same, `mappend`ing them should not
error but just pick the first name.

* Add `desugarBuildToolSimple`

* Reimplement cabal check

* Reorder test output

* Fix autogen modules tests .cabal files

* Add a number of tests

* Add test for #7423

i.e. Do not warn on -O2 if under off-by-default package configuration
flag conditional.

* Add a regression for:

    * Add another -WErrr test
        This is to make sure we do *not* report it if it is under
        a user, off-by-default flag.
    * Add test for non manual user flags.
    * Add “absolute path in extra-lib-dirs” test
    * Add if/else test
    * Add “dircheck on abspath” check
    * Add Package version internal test
    * Add PackageVersionsStraddle test

* Add changelog for #8427

* Integrate various reviews

* Integrate Artem’s review

(review) Clarify `combineNames` documentation

By explaining the way it operates (working if the two names are equal
or one is empty) and renaming the function from `combineName` to
`combineNames`.

(review) Use guards instead of if/then/else

(review) Match inside argument list

(review) Replace “white” with “allow”

(review) Fix typo in comment

(review) Fix typo in Check module documentation

(review) Harmonise indentation for `data` decls

First field goes in a new line than the data constructor, so we
have more space.

(review) Rename `Prim` module to `Types`

(review) Add checkPackageFilesGPD

`checkPackageFiles` — which works on PD — was used to perform IO. We
introduce a function that does the same thing but works on GPD (which
is more principled).

`checkPackageFiles` cannot just be removed, since it is part of the
interface of Distribution.PackageDescription.Check. Deprecation can
be planned once “new check” is up and running.

* Integrate Andreas’ review

(review) Add named section to missing upper bound check

“miss upper bound” checks will now list target type and name (“On
executable 'myexe', these packages miss upper bounds”) for easier
fixing by the user.

(review) remove `cabal gen-bounds` suggestion

Reasonable as `cabal gen-bounds` is stricter than `cabal check`, see
#8427 (comment)
Once `gen-bounds` behaves in line with `check` we can readd the
suggestion.

(review) Do not warn on shared bounds

When a target which depends on an internal library shares some
dependencies with the latter, do not warn on upper bounds.

An example is clearer

    library
     build-depends: text < 5
    ⁝
     build-depends: myPackage,        ← no warning, internal
                    text,             ← no warning, shared bound
                    monadacme         ← warning!

* Integrate Artem’s review /II

(review) Split Check.hs

Check.hs has been split in multiple file, each une sub 1000 lines:

Check              857 lines
Check.Common       147 lines
Check.Conditional  204 lines
Check.Monad        352 lines
Check.Paths        387 lines
Check.Target       765 lines
Check.Warning      865 lines

Migration guide:
- Check              GPD/PD checks plus work-tree checks.
- Check.Common       common types and functions that are
                     *not* part of monadic checking setup.
- Check.Conditional  checks on CondTree and related matter
                     (variables, duplicate modules).
- Check.Monad        Backbone of the checks, monadic inter-
                     face and related functions.
- Check.Paths        Checks on files, directories, globs.
- Check.Target       Checks on realised targets (libraries,
                     executables, benchmarks, testsuites).
- Check.Warning      Datatypes and strings for warnings
                     and severities.

(review) remove useless section header

(review) Fix typo

(review) Add warnings documentation (list)

For each warning, we document constructor/brief description
in the manual.  This might not be much useful as not but it
will come handy when introducing `--ignore=WARN` and similar
flags.

* (review Andreas) Clarify CheckExplanation comment

Whoever modifies `CheckExplanation` data constructors needs to be
aware that the documentation in  doc/cabal-commands.rst  has to be
updated too.

* Move internal Check modules to `other-modules`

No need to expose Distribution.PackageDescription.Check.*
to the world. API for checking, for cabal-install and other
tools, should be in Distribution.PackageDescription.Check.

* Make fourmolu happy

Cabal codebase has now a formatter/style standard (see #8950).

“Ravioli ravioli, give me the formuoli”

* Do not check for OptO in scripts

See #8963 for reason and clarification requests.

* Remove useless PackageId parameter

It is now in the Reader part of CheckM monad.

* Do not check PVP on internal targets

Internal: testsuite, benchmark.
See #8361.

* Make hlint happy

* Fix #9122

When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See #9132.

* Fix grammar

neither…nor, completing what done in #9162

* Integrate Brandon’s review: grammar

* Remove unnecessary `-fvia-C` check

Brandon’s review/II.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* ci: Enable windows tests for 9.6.3

There were two failing tests:

1. CCompilerOverride, was attempting to use gcc.exe rather than
   clang.exe without also overriding the C options which led to
   incorrect options being passed to gcc.exe. The fix is to override to
   clang.exe on ghc-9.4 or newer.
2. ForeignLibs exposes a bug in GHC
   (https://gitlab.haskell.org/ghc/ghc/-/issues/24185) and hence is
   skipped for GHCs newer than 9.4 where it was first introduced.

Towards fixing #8451, we just need to fix the shared library issue now.

* testsuite: Be explicit about runtime test dependencies

Issue #8356 reports occasional errors from running the testsuite about
multiple package versions available. This stems from the invokation of
`runghc` not being explicit about all dependencies of the testsuite.

The solution is provide a component in the cabal file which is explicit
about which packages the tests can depend on. This component has a
build-depends section which lists all the dependencies that the tests
require.

It would be better if this component was a library component but we
can't do this with a Custom setup because of limitations to do with
per-component builds.

Then we also enable `-hide-all-packages`, so the dependency will not be
available if it is not explicitly listed as a dependency.

You could also imagine a future where the Setup.hs script found the test
files and compiled a single executable which would run all the tests,
rather than invoking runghc on each one individually.

Fixes #8356

* hurd: Enable using $ORIGIN in RPATH

GNU/Hurd fully supports RPATH and the $ORIGIN development, and we indeed
want to use it for relocatable installations shipped in Debian GNU/Hurd.

* Fix the platform string for GNU/Hurd

Since version 9.4.7-1, ghc fails to build on the GNU/Hurd port of Debian,
see

https://buildd.debian.org/status/fetch.php?pkg=ghc&arch=hurd-i386&ver=9.4.7-1&stamp=1697717885&raw=0

Error, rule finished running but did not produce file:
  _build/stage0/lib/i386-gnu-ghc-9.4.6/ghc-boot-th-9.4.7/libHSghc-boot-th-9.4.7.a

and indeed, what did get produce was rather
_build/stage0/lib/i386-hurd-ghc-9.4.6/ghc-boot-th-9.4.7/libHSghc-boot-th-9.4.7.a
(i386-hurd instead of i386-gnu).

This is due to confusion between hurd and gnu in various places.  Apparently
previous versions of ghc were using gnu for the GNU/Hurd port, and thus
putting libraries etc. in i386-gnu. So we have to follow the existing
practice.

* Fix configuation of ldProgram

Standard GNU `ld` ues `--relocatable` while `ld.gold` uses a `-relocatable`
flag (with a single `-`). Code will now detect both versions.

* Chain configuration of ldProgram

`ldProgram` gets configured in two places, a seemingly default and
a GHC specific version. The later needs to be updated so that it
first calls the default configuration and then the new GHC version.

* Use linker capability detection to improve linker use

The function `comperSupportsGhciLibs` has been renamed to
`linkerSupportsGhciLibs` because its about the linker not the compiler.

The function `comperSupportsGhciLibs` was using the compiler version
as a proxy for whether the linker supports relocatable objects. Now
support for relocatable objects is detected by running the linker.

* add `merge+no rebase`

and a few typos while reviewing

* Add support for 64-bit SPARC as a separate architecture

Previously, sparc64 was defined as an alias for the 32-bit SPARC
architecture which was true while SPARC mainland was mostly 32
bits. More recently, 64-bit SPARC has become a port of its own,
so it needs to be treated as a separate architecture.

* Remove debug-conflict-sets flag from solver package

Fixes #8937.

The debug-conflict-sets build flag probably hasn't been used for a long time,
and it isn't currently tested. This commit removes the flag, converts the
ConflictSet type back to a newtype, and removes an unnecessary instance.

* Finish improvements to the CI configuration for documentation changes (#9460)

* Add bootstrap postjob to CI config

Add a new job to the bootstrap.yml GitHub action config.
This job succeeds if, and only if, all the other bootstrap
jobs succeed.

* Do not run bootstrap CI jobs for documentation changes

The approach was already introduced in #9355 for the validate jobs.
This commit introduces the same change also for the bootstrap jobs.

* Also ignore CONTRIBUTING.md and README.md in CI

We do not run the entire CI suite for documentation changes.
Previously, only changes which were restricted to the 'docs/'
subdirectory were considered to be documentation changes.
With this commit we also recognize changes to README.md and
CONTRIBUTING.md as documentation changes.

* Document improved CI for documentation in CONTRIBUTING.md

The CONTRIBUTING.md file now mentions that documentation changes
do not waste expensive CI resources.

* Recognize all README.md in subdirs as documentation

Expensive CI jobs should not run on changes which affect only
README.md files.

* formatting: Add style-commit makefile target

This target allows you to format a range of commits, for example:

```
make style-commit COMMIT=HEAD~1
> Last commit is formatted
make style-commit COMMIT=abcde
> Commits between HEAD and abcde are formatted
```

* Fix assertion failure when combining build-tool-depends and --enable-documentation

The `setDocumentation` function was modifying the elaborated package
after the hash was computed. This led to the assertion failing as the
computed hash was different to what was computed in the initial install
plan.

Therefore in order to fix this we either needed to:

1. Set elabBuildHaddocks = False at the point where the hash is
   initially computed.
2. Verify that elabBuildHaddocks = True will not lead to unexpected
   results.

The latter has been implemented.

The elabBuildHaddocks option is only consulted in
`hasValidHaddockTargets`, at which point documentation building the
executable component is disabled because elabHaddockExecutables is
False.

In the added test we ensure this by checking that we didn't build
documentation for the executable which is built because of
build-tool-depends.

Fixes #6006 #8313

* testsuite: Improve error message in findDependencyInStore

* Only move code to Simple/GHC/Build*

* CPP mingw32_HOST_OS for more imports

* cabal-install-solver: fix pkgconf 1.9 --modversion regression

Check that the numbers of *versions* output is equal to the number of pkgconf's

fixes #8923

The pkgconf behavior was reverted upstream in 2.0

(this should cover the case too of checking that equal pkgList lines are output also)

* External commands: Add tests for #9402 #9403 #9404

This adds 4 tests which test the new external commands feature:

* ExternalCommand - Tests the expected usage of external command invoked
  via cabal-install
* ExternalCommandSetup - Tests that the ./Setup interface does not
  support external commands (#9403)
* ExternalCommandEnv - Tests that environment variables are set and
  preserved appropiately  (#9402)
* ExternalCommandHelp - Test that `cabal help <cmd>` is interpreted appropiately (#9404)

* Finish off the external commands feature

* Remove 'CommandDelegate' in favour of abstracting the fallback in
  'commandsRun', there is a new variant 'commdandRunWithFallback' which
  takes a continuation
  - This restores the modularity between the `Cabal` library and
    `cabal-install` as now `Cabal` doesn't need to know anything about
    the external command interface.
  - Fixes #9403
* Set the $CABAL environment variable to the current executable path
  - This allows external commands to be implemented by calling $CABAL,
    which is strongly preferred to linking against the Cabal library as
    there is no easy way to guantee your tool and `cabal-install` link
    against the same `Cabal` library.
  - Fixes #9402
* Pass the name of the argument
  - This allows external commands to be implemented as symlinks to an
    executable, and multiple commands can be interpreted by the same
    executable.
  - Fixes #9405
* `cabal help <cmd>` is interpreted as `cabal-<cmd> --help` for external
  commands.
  - This allows the `help` command to also work for external
  commands and hence they are better integrated into cabal-install.
  - Fixes #9404

The tests are updated to test all these additions.

These features bring the external command interface up to par with the
cargo external command interface.

* Use Base16 hash for script path.

Issue #9334 shows that `%` characters on Windows result in invalid
paths, also `/` characters on Linux create invalid paths.

This changes from using base64 to using base16 with the same length
we use for unit-ids.

* Migrate to haskell-actions/setup

As of 2023-09-09, haskell/action/setup is no longer maintained.

The comment

  # latest is mandatory for cabal-testsuite, see #8133

is removed; as the validate job was already fixing a version of cabal-install.

* testsuite: Introduce Cabal-tests library for common testsuite functions

I noticed that Distribution.Utils.TempTestDir was only used in the
testsuite but defined in the Cabal library. Rather than expose this in
the public interface of the `Cabal` library, it is cleaner to refactor
it into a separate library (`Cabal-tests`) which can be used by any
testsuite component.

Also, in future it gives a clearer place to put utility functions which
need to be shared across the testsuite but not exposed in Cabal.
Cabal-tests can also freely add dependencies (such as exceptions) which
we might want to avoid adding to the Cabal library.

Fixes #9453

* GHC 9.8 compat: pacify -Wx-partial

* GHC 9.8 compat: update hashes of data structures as computed by Structured

It seems, GHC 9.8 changed something in the code generation for data types.
Structured class is supposed to catch such cases.

* GHC 9.8 compat: bump base, update Unknown GHC

And bump Cabal's "supported version" of GHC

* CI: GHC 9.8

* merge master

* Hackage should be capitalized

---------

Co-authored-by: Artem Pelenitsyn <[email protected]>
Co-authored-by: Bryan Richter <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Phil de Joux <[email protected]>
Co-authored-by: Yvan Sraka <[email protected]>
Co-authored-by: Andreas Abel <[email protected]>
Co-authored-by: Jens Petersen <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>
Co-authored-by: Hamish Mackenzie <[email protected]>
Co-authored-by: Malte Neuss <[email protected]>
Co-authored-by: Bodigrim <[email protected]>
Co-authored-by: David Binder <[email protected]>
Co-authored-by: David Binder <[email protected]>
Co-authored-by: Javier Sagredo <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>
Co-authored-by: Matthew Pickering <[email protected]>
Co-authored-by: Fendor <[email protected]>
Co-authored-by: Hécate Moonlight <[email protected]>
Co-authored-by: Andreas Klebinger <[email protected]>
Co-authored-by: Francesco Ariis <[email protected]>
Co-authored-by: Troels Henriksen <[email protected]>
Co-authored-by: Samuel Thibault <[email protected]>
Co-authored-by: Erik de Castro Lopo <[email protected]>
Co-authored-by: brandon s allbery kf8nh <[email protected]>
Co-authored-by: John Paul Adrian Glaubitz <[email protected]>
Co-authored-by: Kristen Kozak <[email protected]>
Co-authored-by: Javier Sagredo <[email protected]>
alt-romes pushed a commit to alt-romes/cabal that referenced this issue Dec 4, 2023
…ange only. (haskell#9386)

* add more breadcrumbs for how to use remote packages.

* Hackage should be capitalized

* Update doc/cabal-project.rst

reword.

* Update doc/cabal-project.rst

reword.

* Update doc/cabal-project.rst

clearer.

* Update doc/cabal-project.rst

clearer!

* Update doc/cabal-project.rst

good mechanical description.

* wrap.

* Update doc/cabal-project.rst

add missing double ticks.

* clarify english, and follow a linguistic pattern better.

* Update doc/cabal-project.rst

* doc: render math with HTML to make it selectable (fix haskell#8453) (haskell#9361)

* doc: render math with HTML to make it selectable (fix haskell#8453)

* Update doc/conf.py

Co-authored-by: Bryan Richter <[email protected]>

---------

Co-authored-by: Bryan Richter <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Avoid double space in "Executing install plan ..."

* Add a change log entry for double space avoidance

* Ignore CmmSourcesExe Demo

Ignore because it warns about missing MachDeps.h

* [cabal-7825] Implement external command system

Fix haskell#2349 and haskell#7825

* Bump to latest dependencies for GHC 9.8.1

* cabal.project: clean out obsolete `allow-newer`s

* update GH validate workflow to ghc 9.2.8, 9.4.7, 9.6.3

* Revert haskell#3639 (Don't pass -package-db and -package flags to --abi-hash) (haskell#9384)

* Revert haskell#3639 (Don't pass -package-db and -package flags to --abi-hash)

With ghc>=9.6 `ghc --abi-hash` initialises the plugins so it will fail
if a cabal file specifies `ghc-options: -fplugin=Foo`.

Closes: haskell#9375

* Also revert in GHC.hs

---------

Co-authored-by: Hamish Mackenzie <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Use the newer haskell-actions organisation

* Restructure Cabal documentation top-level parts

The goal is for users to easier find pages for typical problems through search engines and page navigation.
- The top-level layout is based on the popular documentation structure by https://documentation.divio.com/ to give a
   clear structure to users and future documentation contributors:
  * Guides: Present a solution to a single, atomic, typical user problem.
  * Reference: Describe user API (CLI fields, syntax etc) with technical rigour and completeness.
  * Explanation: Discuss background information, scope, design decisions etc.
- Move existing documentation roughly into these categories with minimal editing as the basis for further editing.
- Rename guide titles to mention how-to for improving SEO.
- Rename some files to improve SEO since that name becomes part of the URL (often called slug).
  Important page keywords should appear in the slug as well to make pages rank higher in search engines.

* Rename master_doc to root_doc (changed in version 4.0 of Sphynx)

* Add instance Ord for Field, FieldLine, SectionArg and Name

* Do not run CI for documentation changes

The github workflows are not run if the
changes are completely contained within
the doc/ subdirectory. The only exception
is the users-guide.yml github action.

* Move Backpack section to user guides

* Remove TBW virtual modules section

* Add reinstall test to LinkerOptions/NonignoredConfigs

* Record install options

* Reject index-states after last known index-state (haskell#8944)

Co-authored-by: Javier Sagredo <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>

* Note how to do "not equal" with constraints

* Use comma with then

Co-authored-by: Artem Pelenitsyn <[email protected]>

* Use narrow rather than upset

* Say something about hackage deprecations

* Fix AutogenModulesToggling test

By converting this to a setupTest we use the in-tree Cabal library
rather than relying on a proxy of the GHC version to provide the right
Cabal library version.

Supersedes haskell#9398

* Require version 3,11 of Cabal to support --semaphore flag

Fixes haskell#9197

* Add dependencies used by `PackageTests` to exe:cabal-tests

The runner allows the tests to use extra dependencies and the custom Prelude
from 'cabal-testsuite'.
However, if the tests use a dependency, say 'directory', and there are two
packages with the same unit id available in the store, the test fails since
it doesn't know which one to pick.
By including an extra dependency to directory, we force the test runner to
use a specific version directory, fixing the test failure.

* Use Paths_cabal_install for cabal-install version number (haskell#9421)

* Use PackageInfo for cabal-install version number

* Use Paths_cabal_install instead

* Adjust documentation

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Document --profiling-detail in setup-commands.

Fixes haskell#9182

* Add test requirement to PR template

Adding test becomes a checkmark instead of “bonus points”.

* A 'cabal path' command. (haskell#8879)

* Add a 'cabal path' command.

* Formatting fix.

* Another formatting fix.

* Categorise "cabal path" as global command.

* Allow individual paths to be printed.

* Less duplication.

* Add config-file to "cabal path".

* Use sum type instead of strings.

* cabal path: support --installdir.

* Add documentation.

* Better text.

* Formatting.

* Add some tests.

* Improve tests.

* Add changelog entry.

* Mention "cabal path" in directory documentation.

---------

Co-authored-by: Artem Pelenitsyn <[email protected]>

* Reimplement `cabal check` (haskell#8427)

* Fix Semigroup target instance

When two target names are the same, `mappend`ing them should not
error but just pick the first name.

* Add `desugarBuildToolSimple`

* Reimplement cabal check

* Reorder test output

* Fix autogen modules tests .cabal files

* Add a number of tests

* Add test for haskell#7423

i.e. Do not warn on -O2 if under off-by-default package configuration
flag conditional.

* Add a regression for:

    * Add another -WErrr test
        This is to make sure we do *not* report it if it is under
        a user, off-by-default flag.
    * Add test for non manual user flags.
    * Add “absolute path in extra-lib-dirs” test
    * Add if/else test
    * Add “dircheck on abspath” check
    * Add Package version internal test
    * Add PackageVersionsStraddle test

* Add changelog for haskell#8427

* Integrate various reviews

* Integrate Artem’s review

(review) Clarify `combineNames` documentation

By explaining the way it operates (working if the two names are equal
or one is empty) and renaming the function from `combineName` to
`combineNames`.

(review) Use guards instead of if/then/else

(review) Match inside argument list

(review) Replace “white” with “allow”

(review) Fix typo in comment

(review) Fix typo in Check module documentation

(review) Harmonise indentation for `data` decls

First field goes in a new line than the data constructor, so we
have more space.

(review) Rename `Prim` module to `Types`

(review) Add checkPackageFilesGPD

`checkPackageFiles` — which works on PD — was used to perform IO. We
introduce a function that does the same thing but works on GPD (which
is more principled).

`checkPackageFiles` cannot just be removed, since it is part of the
interface of Distribution.PackageDescription.Check. Deprecation can
be planned once “new check” is up and running.

* Integrate Andreas’ review

(review) Add named section to missing upper bound check

“miss upper bound” checks will now list target type and name (“On
executable 'myexe', these packages miss upper bounds”) for easier
fixing by the user.

(review) remove `cabal gen-bounds` suggestion

Reasonable as `cabal gen-bounds` is stricter than `cabal check`, see
haskell#8427 (comment)
Once `gen-bounds` behaves in line with `check` we can readd the
suggestion.

(review) Do not warn on shared bounds

When a target which depends on an internal library shares some
dependencies with the latter, do not warn on upper bounds.

An example is clearer

    library
     build-depends: text < 5
    ⁝
     build-depends: myPackage,        ← no warning, internal
                    text,             ← no warning, shared bound
                    monadacme         ← warning!

* Integrate Artem’s review /II

(review) Split Check.hs

Check.hs has been split in multiple file, each une sub 1000 lines:

Check              857 lines
Check.Common       147 lines
Check.Conditional  204 lines
Check.Monad        352 lines
Check.Paths        387 lines
Check.Target       765 lines
Check.Warning      865 lines

Migration guide:
- Check              GPD/PD checks plus work-tree checks.
- Check.Common       common types and functions that are
                     *not* part of monadic checking setup.
- Check.Conditional  checks on CondTree and related matter
                     (variables, duplicate modules).
- Check.Monad        Backbone of the checks, monadic inter-
                     face and related functions.
- Check.Paths        Checks on files, directories, globs.
- Check.Target       Checks on realised targets (libraries,
                     executables, benchmarks, testsuites).
- Check.Warning      Datatypes and strings for warnings
                     and severities.

(review) remove useless section header

(review) Fix typo

(review) Add warnings documentation (list)

For each warning, we document constructor/brief description
in the manual.  This might not be much useful as not but it
will come handy when introducing `--ignore=WARN` and similar
flags.

* (review Andreas) Clarify CheckExplanation comment

Whoever modifies `CheckExplanation` data constructors needs to be
aware that the documentation in  doc/cabal-commands.rst  has to be
updated too.

* Move internal Check modules to `other-modules`

No need to expose Distribution.PackageDescription.Check.*
to the world. API for checking, for cabal-install and other
tools, should be in Distribution.PackageDescription.Check.

* Make fourmolu happy

Cabal codebase has now a formatter/style standard (see haskell#8950).

“Ravioli ravioli, give me the formuoli”

* Do not check for OptO in scripts

See haskell#8963 for reason and clarification requests.

* Remove useless PackageId parameter

It is now in the Reader part of CheckM monad.

* Do not check PVP on internal targets

Internal: testsuite, benchmark.
See haskell#8361.

* Make hlint happy

* Fix haskell#9122

When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See haskell#9132.

* Fix grammar

neither…nor, completing what done in haskell#9162

* Integrate Brandon’s review: grammar

* Remove unnecessary `-fvia-C` check

Brandon’s review/II.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* ci: Enable windows tests for 9.6.3

There were two failing tests:

1. CCompilerOverride, was attempting to use gcc.exe rather than
   clang.exe without also overriding the C options which led to
   incorrect options being passed to gcc.exe. The fix is to override to
   clang.exe on ghc-9.4 or newer.
2. ForeignLibs exposes a bug in GHC
   (https://gitlab.haskell.org/ghc/ghc/-/issues/24185) and hence is
   skipped for GHCs newer than 9.4 where it was first introduced.

Towards fixing haskell#8451, we just need to fix the shared library issue now.

* testsuite: Be explicit about runtime test dependencies

Issue haskell#8356 reports occasional errors from running the testsuite about
multiple package versions available. This stems from the invokation of
`runghc` not being explicit about all dependencies of the testsuite.

The solution is provide a component in the cabal file which is explicit
about which packages the tests can depend on. This component has a
build-depends section which lists all the dependencies that the tests
require.

It would be better if this component was a library component but we
can't do this with a Custom setup because of limitations to do with
per-component builds.

Then we also enable `-hide-all-packages`, so the dependency will not be
available if it is not explicitly listed as a dependency.

You could also imagine a future where the Setup.hs script found the test
files and compiled a single executable which would run all the tests,
rather than invoking runghc on each one individually.

Fixes haskell#8356

* hurd: Enable using $ORIGIN in RPATH

GNU/Hurd fully supports RPATH and the $ORIGIN development, and we indeed
want to use it for relocatable installations shipped in Debian GNU/Hurd.

* Fix the platform string for GNU/Hurd

Since version 9.4.7-1, ghc fails to build on the GNU/Hurd port of Debian,
see

https://buildd.debian.org/status/fetch.php?pkg=ghc&arch=hurd-i386&ver=9.4.7-1&stamp=1697717885&raw=0

Error, rule finished running but did not produce file:
  _build/stage0/lib/i386-gnu-ghc-9.4.6/ghc-boot-th-9.4.7/libHSghc-boot-th-9.4.7.a

and indeed, what did get produce was rather
_build/stage0/lib/i386-hurd-ghc-9.4.6/ghc-boot-th-9.4.7/libHSghc-boot-th-9.4.7.a
(i386-hurd instead of i386-gnu).

This is due to confusion between hurd and gnu in various places.  Apparently
previous versions of ghc were using gnu for the GNU/Hurd port, and thus
putting libraries etc. in i386-gnu. So we have to follow the existing
practice.

* Fix configuation of ldProgram

Standard GNU `ld` ues `--relocatable` while `ld.gold` uses a `-relocatable`
flag (with a single `-`). Code will now detect both versions.

* Chain configuration of ldProgram

`ldProgram` gets configured in two places, a seemingly default and
a GHC specific version. The later needs to be updated so that it
first calls the default configuration and then the new GHC version.

* Use linker capability detection to improve linker use

The function `comperSupportsGhciLibs` has been renamed to
`linkerSupportsGhciLibs` because its about the linker not the compiler.

The function `comperSupportsGhciLibs` was using the compiler version
as a proxy for whether the linker supports relocatable objects. Now
support for relocatable objects is detected by running the linker.

* add `merge+no rebase`

and a few typos while reviewing

* Add support for 64-bit SPARC as a separate architecture

Previously, sparc64 was defined as an alias for the 32-bit SPARC
architecture which was true while SPARC mainland was mostly 32
bits. More recently, 64-bit SPARC has become a port of its own,
so it needs to be treated as a separate architecture.

* Remove debug-conflict-sets flag from solver package

Fixes haskell#8937.

The debug-conflict-sets build flag probably hasn't been used for a long time,
and it isn't currently tested. This commit removes the flag, converts the
ConflictSet type back to a newtype, and removes an unnecessary instance.

* Finish improvements to the CI configuration for documentation changes (haskell#9460)

* Add bootstrap postjob to CI config

Add a new job to the bootstrap.yml GitHub action config.
This job succeeds if, and only if, all the other bootstrap
jobs succeed.

* Do not run bootstrap CI jobs for documentation changes

The approach was already introduced in haskell#9355 for the validate jobs.
This commit introduces the same change also for the bootstrap jobs.

* Also ignore CONTRIBUTING.md and README.md in CI

We do not run the entire CI suite for documentation changes.
Previously, only changes which were restricted to the 'docs/'
subdirectory were considered to be documentation changes.
With this commit we also recognize changes to README.md and
CONTRIBUTING.md as documentation changes.

* Document improved CI for documentation in CONTRIBUTING.md

The CONTRIBUTING.md file now mentions that documentation changes
do not waste expensive CI resources.

* Recognize all README.md in subdirs as documentation

Expensive CI jobs should not run on changes which affect only
README.md files.

* formatting: Add style-commit makefile target

This target allows you to format a range of commits, for example:

```
make style-commit COMMIT=HEAD~1
> Last commit is formatted
make style-commit COMMIT=abcde
> Commits between HEAD and abcde are formatted
```

* Fix assertion failure when combining build-tool-depends and --enable-documentation

The `setDocumentation` function was modifying the elaborated package
after the hash was computed. This led to the assertion failing as the
computed hash was different to what was computed in the initial install
plan.

Therefore in order to fix this we either needed to:

1. Set elabBuildHaddocks = False at the point where the hash is
   initially computed.
2. Verify that elabBuildHaddocks = True will not lead to unexpected
   results.

The latter has been implemented.

The elabBuildHaddocks option is only consulted in
`hasValidHaddockTargets`, at which point documentation building the
executable component is disabled because elabHaddockExecutables is
False.

In the added test we ensure this by checking that we didn't build
documentation for the executable which is built because of
build-tool-depends.

Fixes haskell#6006 haskell#8313

* testsuite: Improve error message in findDependencyInStore

* Only move code to Simple/GHC/Build*

* CPP mingw32_HOST_OS for more imports

* cabal-install-solver: fix pkgconf 1.9 --modversion regression

Check that the numbers of *versions* output is equal to the number of pkgconf's

fixes haskell#8923

The pkgconf behavior was reverted upstream in 2.0

(this should cover the case too of checking that equal pkgList lines are output also)

* External commands: Add tests for haskell#9402 haskell#9403 haskell#9404

This adds 4 tests which test the new external commands feature:

* ExternalCommand - Tests the expected usage of external command invoked
  via cabal-install
* ExternalCommandSetup - Tests that the ./Setup interface does not
  support external commands (haskell#9403)
* ExternalCommandEnv - Tests that environment variables are set and
  preserved appropiately  (haskell#9402)
* ExternalCommandHelp - Test that `cabal help <cmd>` is interpreted appropiately (haskell#9404)

* Finish off the external commands feature

* Remove 'CommandDelegate' in favour of abstracting the fallback in
  'commandsRun', there is a new variant 'commdandRunWithFallback' which
  takes a continuation
  - This restores the modularity between the `Cabal` library and
    `cabal-install` as now `Cabal` doesn't need to know anything about
    the external command interface.
  - Fixes haskell#9403
* Set the $CABAL environment variable to the current executable path
  - This allows external commands to be implemented by calling $CABAL,
    which is strongly preferred to linking against the Cabal library as
    there is no easy way to guantee your tool and `cabal-install` link
    against the same `Cabal` library.
  - Fixes haskell#9402
* Pass the name of the argument
  - This allows external commands to be implemented as symlinks to an
    executable, and multiple commands can be interpreted by the same
    executable.
  - Fixes haskell#9405
* `cabal help <cmd>` is interpreted as `cabal-<cmd> --help` for external
  commands.
  - This allows the `help` command to also work for external
  commands and hence they are better integrated into cabal-install.
  - Fixes haskell#9404

The tests are updated to test all these additions.

These features bring the external command interface up to par with the
cargo external command interface.

* Use Base16 hash for script path.

Issue haskell#9334 shows that `%` characters on Windows result in invalid
paths, also `/` characters on Linux create invalid paths.

This changes from using base64 to using base16 with the same length
we use for unit-ids.

* Migrate to haskell-actions/setup

As of 2023-09-09, haskell/action/setup is no longer maintained.

The comment

  # latest is mandatory for cabal-testsuite, see haskell#8133

is removed; as the validate job was already fixing a version of cabal-install.

* testsuite: Introduce Cabal-tests library for common testsuite functions

I noticed that Distribution.Utils.TempTestDir was only used in the
testsuite but defined in the Cabal library. Rather than expose this in
the public interface of the `Cabal` library, it is cleaner to refactor
it into a separate library (`Cabal-tests`) which can be used by any
testsuite component.

Also, in future it gives a clearer place to put utility functions which
need to be shared across the testsuite but not exposed in Cabal.
Cabal-tests can also freely add dependencies (such as exceptions) which
we might want to avoid adding to the Cabal library.

Fixes haskell#9453

* GHC 9.8 compat: pacify -Wx-partial

* GHC 9.8 compat: update hashes of data structures as computed by Structured

It seems, GHC 9.8 changed something in the code generation for data types.
Structured class is supposed to catch such cases.

* GHC 9.8 compat: bump base, update Unknown GHC

And bump Cabal's "supported version" of GHC

* CI: GHC 9.8

* merge master

* Hackage should be capitalized

---------

Co-authored-by: Artem Pelenitsyn <[email protected]>
Co-authored-by: Bryan Richter <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Phil de Joux <[email protected]>
Co-authored-by: Yvan Sraka <[email protected]>
Co-authored-by: Andreas Abel <[email protected]>
Co-authored-by: Jens Petersen <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>
Co-authored-by: Hamish Mackenzie <[email protected]>
Co-authored-by: Malte Neuss <[email protected]>
Co-authored-by: Bodigrim <[email protected]>
Co-authored-by: David Binder <[email protected]>
Co-authored-by: David Binder <[email protected]>
Co-authored-by: Javier Sagredo <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>
Co-authored-by: Matthew Pickering <[email protected]>
Co-authored-by: Fendor <[email protected]>
Co-authored-by: Hécate Moonlight <[email protected]>
Co-authored-by: Andreas Klebinger <[email protected]>
Co-authored-by: Francesco Ariis <[email protected]>
Co-authored-by: Troels Henriksen <[email protected]>
Co-authored-by: Samuel Thibault <[email protected]>
Co-authored-by: Erik de Castro Lopo <[email protected]>
Co-authored-by: brandon s allbery kf8nh <[email protected]>
Co-authored-by: John Paul Adrian Glaubitz <[email protected]>
Co-authored-by: Kristen Kozak <[email protected]>
Co-authored-by: Javier Sagredo <[email protected]>
alt-romes pushed a commit to alt-romes/cabal that referenced this issue Dec 4, 2023
…ange only. (haskell#9386)

* add more breadcrumbs for how to use remote packages.

* Hackage should be capitalized

* Update doc/cabal-project.rst

reword.

* Update doc/cabal-project.rst

reword.

* Update doc/cabal-project.rst

clearer.

* Update doc/cabal-project.rst

clearer!

* Update doc/cabal-project.rst

good mechanical description.

* wrap.

* Update doc/cabal-project.rst

add missing double ticks.

* clarify english, and follow a linguistic pattern better.

* Update doc/cabal-project.rst

* doc: render math with HTML to make it selectable (fix haskell#8453) (haskell#9361)

* doc: render math with HTML to make it selectable (fix haskell#8453)

* Update doc/conf.py

Co-authored-by: Bryan Richter <[email protected]>

---------

Co-authored-by: Bryan Richter <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Avoid double space in "Executing install plan ..."

* Add a change log entry for double space avoidance

* Ignore CmmSourcesExe Demo

Ignore because it warns about missing MachDeps.h

* [cabal-7825] Implement external command system

Fix haskell#2349 and haskell#7825

* Bump to latest dependencies for GHC 9.8.1

* cabal.project: clean out obsolete `allow-newer`s

* update GH validate workflow to ghc 9.2.8, 9.4.7, 9.6.3

* Revert haskell#3639 (Don't pass -package-db and -package flags to --abi-hash) (haskell#9384)

* Revert haskell#3639 (Don't pass -package-db and -package flags to --abi-hash)

With ghc>=9.6 `ghc --abi-hash` initialises the plugins so it will fail
if a cabal file specifies `ghc-options: -fplugin=Foo`.

Closes: haskell#9375

* Also revert in GHC.hs

---------

Co-authored-by: Hamish Mackenzie <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Use the newer haskell-actions organisation

* Restructure Cabal documentation top-level parts

The goal is for users to easier find pages for typical problems through search engines and page navigation.
- The top-level layout is based on the popular documentation structure by https://documentation.divio.com/ to give a
   clear structure to users and future documentation contributors:
  * Guides: Present a solution to a single, atomic, typical user problem.
  * Reference: Describe user API (CLI fields, syntax etc) with technical rigour and completeness.
  * Explanation: Discuss background information, scope, design decisions etc.
- Move existing documentation roughly into these categories with minimal editing as the basis for further editing.
- Rename guide titles to mention how-to for improving SEO.
- Rename some files to improve SEO since that name becomes part of the URL (often called slug).
  Important page keywords should appear in the slug as well to make pages rank higher in search engines.

* Rename master_doc to root_doc (changed in version 4.0 of Sphynx)

* Add instance Ord for Field, FieldLine, SectionArg and Name

* Do not run CI for documentation changes

The github workflows are not run if the
changes are completely contained within
the doc/ subdirectory. The only exception
is the users-guide.yml github action.

* Move Backpack section to user guides

* Remove TBW virtual modules section

* Add reinstall test to LinkerOptions/NonignoredConfigs

* Record install options

* Reject index-states after last known index-state (haskell#8944)

Co-authored-by: Javier Sagredo <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>

* Note how to do "not equal" with constraints

* Use comma with then

Co-authored-by: Artem Pelenitsyn <[email protected]>

* Use narrow rather than upset

* Say something about hackage deprecations

* Fix AutogenModulesToggling test

By converting this to a setupTest we use the in-tree Cabal library
rather than relying on a proxy of the GHC version to provide the right
Cabal library version.

Supersedes haskell#9398

* Require version 3,11 of Cabal to support --semaphore flag

Fixes haskell#9197

* Add dependencies used by `PackageTests` to exe:cabal-tests

The runner allows the tests to use extra dependencies and the custom Prelude
from 'cabal-testsuite'.
However, if the tests use a dependency, say 'directory', and there are two
packages with the same unit id available in the store, the test fails since
it doesn't know which one to pick.
By including an extra dependency to directory, we force the test runner to
use a specific version directory, fixing the test failure.

* Use Paths_cabal_install for cabal-install version number (haskell#9421)

* Use PackageInfo for cabal-install version number

* Use Paths_cabal_install instead

* Adjust documentation

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Document --profiling-detail in setup-commands.

Fixes haskell#9182

* Add test requirement to PR template

Adding test becomes a checkmark instead of “bonus points”.

* A 'cabal path' command. (haskell#8879)

* Add a 'cabal path' command.

* Formatting fix.

* Another formatting fix.

* Categorise "cabal path" as global command.

* Allow individual paths to be printed.

* Less duplication.

* Add config-file to "cabal path".

* Use sum type instead of strings.

* cabal path: support --installdir.

* Add documentation.

* Better text.

* Formatting.

* Add some tests.

* Improve tests.

* Add changelog entry.

* Mention "cabal path" in directory documentation.

---------

Co-authored-by: Artem Pelenitsyn <[email protected]>

* Reimplement `cabal check` (haskell#8427)

* Fix Semigroup target instance

When two target names are the same, `mappend`ing them should not
error but just pick the first name.

* Add `desugarBuildToolSimple`

* Reimplement cabal check

* Reorder test output

* Fix autogen modules tests .cabal files

* Add a number of tests

* Add test for haskell#7423

i.e. Do not warn on -O2 if under off-by-default package configuration
flag conditional.

* Add a regression for:

    * Add another -WErrr test
        This is to make sure we do *not* report it if it is under
        a user, off-by-default flag.
    * Add test for non manual user flags.
    * Add “absolute path in extra-lib-dirs” test
    * Add if/else test
    * Add “dircheck on abspath” check
    * Add Package version internal test
    * Add PackageVersionsStraddle test

* Add changelog for haskell#8427

* Integrate various reviews

* Integrate Artem’s review

(review) Clarify `combineNames` documentation

By explaining the way it operates (working if the two names are equal
or one is empty) and renaming the function from `combineName` to
`combineNames`.

(review) Use guards instead of if/then/else

(review) Match inside argument list

(review) Replace “white” with “allow”

(review) Fix typo in comment

(review) Fix typo in Check module documentation

(review) Harmonise indentation for `data` decls

First field goes in a new line than the data constructor, so we
have more space.

(review) Rename `Prim` module to `Types`

(review) Add checkPackageFilesGPD

`checkPackageFiles` — which works on PD — was used to perform IO. We
introduce a function that does the same thing but works on GPD (which
is more principled).

`checkPackageFiles` cannot just be removed, since it is part of the
interface of Distribution.PackageDescription.Check. Deprecation can
be planned once “new check” is up and running.

* Integrate Andreas’ review

(review) Add named section to missing upper bound check

“miss upper bound” checks will now list target type and name (“On
executable 'myexe', these packages miss upper bounds”) for easier
fixing by the user.

(review) remove `cabal gen-bounds` suggestion

Reasonable as `cabal gen-bounds` is stricter than `cabal check`, see
haskell#8427 (comment)
Once `gen-bounds` behaves in line with `check` we can readd the
suggestion.

(review) Do not warn on shared bounds

When a target which depends on an internal library shares some
dependencies with the latter, do not warn on upper bounds.

An example is clearer

    library
     build-depends: text < 5
    ⁝
     build-depends: myPackage,        ← no warning, internal
                    text,             ← no warning, shared bound
                    monadacme         ← warning!

* Integrate Artem’s review /II

(review) Split Check.hs

Check.hs has been split in multiple file, each une sub 1000 lines:

Check              857 lines
Check.Common       147 lines
Check.Conditional  204 lines
Check.Monad        352 lines
Check.Paths        387 lines
Check.Target       765 lines
Check.Warning      865 lines

Migration guide:
- Check              GPD/PD checks plus work-tree checks.
- Check.Common       common types and functions that are
                     *not* part of monadic checking setup.
- Check.Conditional  checks on CondTree and related matter
                     (variables, duplicate modules).
- Check.Monad        Backbone of the checks, monadic inter-
                     face and related functions.
- Check.Paths        Checks on files, directories, globs.
- Check.Target       Checks on realised targets (libraries,
                     executables, benchmarks, testsuites).
- Check.Warning      Datatypes and strings for warnings
                     and severities.

(review) remove useless section header

(review) Fix typo

(review) Add warnings documentation (list)

For each warning, we document constructor/brief description
in the manual.  This might not be much useful as not but it
will come handy when introducing `--ignore=WARN` and similar
flags.

* (review Andreas) Clarify CheckExplanation comment

Whoever modifies `CheckExplanation` data constructors needs to be
aware that the documentation in  doc/cabal-commands.rst  has to be
updated too.

* Move internal Check modules to `other-modules`

No need to expose Distribution.PackageDescription.Check.*
to the world. API for checking, for cabal-install and other
tools, should be in Distribution.PackageDescription.Check.

* Make fourmolu happy

Cabal codebase has now a formatter/style standard (see haskell#8950).

“Ravioli ravioli, give me the formuoli”

* Do not check for OptO in scripts

See haskell#8963 for reason and clarification requests.

* Remove useless PackageId parameter

It is now in the Reader part of CheckM monad.

* Do not check PVP on internal targets

Internal: testsuite, benchmark.
See haskell#8361.

* Make hlint happy

* Fix haskell#9122

When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See haskell#9132.

* Fix grammar

neither…nor, completing what done in haskell#9162

* Integrate Brandon’s review: grammar

* Remove unnecessary `-fvia-C` check

Brandon’s review/II.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* ci: Enable windows tests for 9.6.3

There were two failing tests:

1. CCompilerOverride, was attempting to use gcc.exe rather than
   clang.exe without also overriding the C options which led to
   incorrect options being passed to gcc.exe. The fix is to override to
   clang.exe on ghc-9.4 or newer.
2. ForeignLibs exposes a bug in GHC
   (https://gitlab.haskell.org/ghc/ghc/-/issues/24185) and hence is
   skipped for GHCs newer than 9.4 where it was first introduced.

Towards fixing haskell#8451, we just need to fix the shared library issue now.

* testsuite: Be explicit about runtime test dependencies

Issue haskell#8356 reports occasional errors from running the testsuite about
multiple package versions available. This stems from the invokation of
`runghc` not being explicit about all dependencies of the testsuite.

The solution is provide a component in the cabal file which is explicit
about which packages the tests can depend on. This component has a
build-depends section which lists all the dependencies that the tests
require.

It would be better if this component was a library component but we
can't do this with a Custom setup because of limitations to do with
per-component builds.

Then we also enable `-hide-all-packages`, so the dependency will not be
available if it is not explicitly listed as a dependency.

You could also imagine a future where the Setup.hs script found the test
files and compiled a single executable which would run all the tests,
rather than invoking runghc on each one individually.

Fixes haskell#8356

* hurd: Enable using $ORIGIN in RPATH

GNU/Hurd fully supports RPATH and the $ORIGIN development, and we indeed
want to use it for relocatable installations shipped in Debian GNU/Hurd.

* Fix the platform string for GNU/Hurd

Since version 9.4.7-1, ghc fails to build on the GNU/Hurd port of Debian,
see

https://buildd.debian.org/status/fetch.php?pkg=ghc&arch=hurd-i386&ver=9.4.7-1&stamp=1697717885&raw=0

Error, rule finished running but did not produce file:
  _build/stage0/lib/i386-gnu-ghc-9.4.6/ghc-boot-th-9.4.7/libHSghc-boot-th-9.4.7.a

and indeed, what did get produce was rather
_build/stage0/lib/i386-hurd-ghc-9.4.6/ghc-boot-th-9.4.7/libHSghc-boot-th-9.4.7.a
(i386-hurd instead of i386-gnu).

This is due to confusion between hurd and gnu in various places.  Apparently
previous versions of ghc were using gnu for the GNU/Hurd port, and thus
putting libraries etc. in i386-gnu. So we have to follow the existing
practice.

* Fix configuation of ldProgram

Standard GNU `ld` ues `--relocatable` while `ld.gold` uses a `-relocatable`
flag (with a single `-`). Code will now detect both versions.

* Chain configuration of ldProgram

`ldProgram` gets configured in two places, a seemingly default and
a GHC specific version. The later needs to be updated so that it
first calls the default configuration and then the new GHC version.

* Use linker capability detection to improve linker use

The function `comperSupportsGhciLibs` has been renamed to
`linkerSupportsGhciLibs` because its about the linker not the compiler.

The function `comperSupportsGhciLibs` was using the compiler version
as a proxy for whether the linker supports relocatable objects. Now
support for relocatable objects is detected by running the linker.

* add `merge+no rebase`

and a few typos while reviewing

* Add support for 64-bit SPARC as a separate architecture

Previously, sparc64 was defined as an alias for the 32-bit SPARC
architecture which was true while SPARC mainland was mostly 32
bits. More recently, 64-bit SPARC has become a port of its own,
so it needs to be treated as a separate architecture.

* Remove debug-conflict-sets flag from solver package

Fixes haskell#8937.

The debug-conflict-sets build flag probably hasn't been used for a long time,
and it isn't currently tested. This commit removes the flag, converts the
ConflictSet type back to a newtype, and removes an unnecessary instance.

* Finish improvements to the CI configuration for documentation changes (haskell#9460)

* Add bootstrap postjob to CI config

Add a new job to the bootstrap.yml GitHub action config.
This job succeeds if, and only if, all the other bootstrap
jobs succeed.

* Do not run bootstrap CI jobs for documentation changes

The approach was already introduced in haskell#9355 for the validate jobs.
This commit introduces the same change also for the bootstrap jobs.

* Also ignore CONTRIBUTING.md and README.md in CI

We do not run the entire CI suite for documentation changes.
Previously, only changes which were restricted to the 'docs/'
subdirectory were considered to be documentation changes.
With this commit we also recognize changes to README.md and
CONTRIBUTING.md as documentation changes.

* Document improved CI for documentation in CONTRIBUTING.md

The CONTRIBUTING.md file now mentions that documentation changes
do not waste expensive CI resources.

* Recognize all README.md in subdirs as documentation

Expensive CI jobs should not run on changes which affect only
README.md files.

* formatting: Add style-commit makefile target

This target allows you to format a range of commits, for example:

```
make style-commit COMMIT=HEAD~1
> Last commit is formatted
make style-commit COMMIT=abcde
> Commits between HEAD and abcde are formatted
```

* Fix assertion failure when combining build-tool-depends and --enable-documentation

The `setDocumentation` function was modifying the elaborated package
after the hash was computed. This led to the assertion failing as the
computed hash was different to what was computed in the initial install
plan.

Therefore in order to fix this we either needed to:

1. Set elabBuildHaddocks = False at the point where the hash is
   initially computed.
2. Verify that elabBuildHaddocks = True will not lead to unexpected
   results.

The latter has been implemented.

The elabBuildHaddocks option is only consulted in
`hasValidHaddockTargets`, at which point documentation building the
executable component is disabled because elabHaddockExecutables is
False.

In the added test we ensure this by checking that we didn't build
documentation for the executable which is built because of
build-tool-depends.

Fixes haskell#6006 haskell#8313

* testsuite: Improve error message in findDependencyInStore

* Only move code to Simple/GHC/Build*

* CPP mingw32_HOST_OS for more imports

* cabal-install-solver: fix pkgconf 1.9 --modversion regression

Check that the numbers of *versions* output is equal to the number of pkgconf's

fixes haskell#8923

The pkgconf behavior was reverted upstream in 2.0

(this should cover the case too of checking that equal pkgList lines are output also)

* External commands: Add tests for haskell#9402 haskell#9403 haskell#9404

This adds 4 tests which test the new external commands feature:

* ExternalCommand - Tests the expected usage of external command invoked
  via cabal-install
* ExternalCommandSetup - Tests that the ./Setup interface does not
  support external commands (haskell#9403)
* ExternalCommandEnv - Tests that environment variables are set and
  preserved appropiately  (haskell#9402)
* ExternalCommandHelp - Test that `cabal help <cmd>` is interpreted appropiately (haskell#9404)

* Finish off the external commands feature

* Remove 'CommandDelegate' in favour of abstracting the fallback in
  'commandsRun', there is a new variant 'commdandRunWithFallback' which
  takes a continuation
  - This restores the modularity between the `Cabal` library and
    `cabal-install` as now `Cabal` doesn't need to know anything about
    the external command interface.
  - Fixes haskell#9403
* Set the $CABAL environment variable to the current executable path
  - This allows external commands to be implemented by calling $CABAL,
    which is strongly preferred to linking against the Cabal library as
    there is no easy way to guantee your tool and `cabal-install` link
    against the same `Cabal` library.
  - Fixes haskell#9402
* Pass the name of the argument
  - This allows external commands to be implemented as symlinks to an
    executable, and multiple commands can be interpreted by the same
    executable.
  - Fixes haskell#9405
* `cabal help <cmd>` is interpreted as `cabal-<cmd> --help` for external
  commands.
  - This allows the `help` command to also work for external
  commands and hence they are better integrated into cabal-install.
  - Fixes haskell#9404

The tests are updated to test all these additions.

These features bring the external command interface up to par with the
cargo external command interface.

* Use Base16 hash for script path.

Issue haskell#9334 shows that `%` characters on Windows result in invalid
paths, also `/` characters on Linux create invalid paths.

This changes from using base64 to using base16 with the same length
we use for unit-ids.

* Migrate to haskell-actions/setup

As of 2023-09-09, haskell/action/setup is no longer maintained.

The comment

  # latest is mandatory for cabal-testsuite, see haskell#8133

is removed; as the validate job was already fixing a version of cabal-install.

* testsuite: Introduce Cabal-tests library for common testsuite functions

I noticed that Distribution.Utils.TempTestDir was only used in the
testsuite but defined in the Cabal library. Rather than expose this in
the public interface of the `Cabal` library, it is cleaner to refactor
it into a separate library (`Cabal-tests`) which can be used by any
testsuite component.

Also, in future it gives a clearer place to put utility functions which
need to be shared across the testsuite but not exposed in Cabal.
Cabal-tests can also freely add dependencies (such as exceptions) which
we might want to avoid adding to the Cabal library.

Fixes haskell#9453

* GHC 9.8 compat: pacify -Wx-partial

* GHC 9.8 compat: update hashes of data structures as computed by Structured

It seems, GHC 9.8 changed something in the code generation for data types.
Structured class is supposed to catch such cases.

* GHC 9.8 compat: bump base, update Unknown GHC

And bump Cabal's "supported version" of GHC

* CI: GHC 9.8

* merge master

* Hackage should be capitalized

---------

Co-authored-by: Artem Pelenitsyn <[email protected]>
Co-authored-by: Bryan Richter <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Phil de Joux <[email protected]>
Co-authored-by: Yvan Sraka <[email protected]>
Co-authored-by: Andreas Abel <[email protected]>
Co-authored-by: Jens Petersen <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>
Co-authored-by: Hamish Mackenzie <[email protected]>
Co-authored-by: Malte Neuss <[email protected]>
Co-authored-by: Bodigrim <[email protected]>
Co-authored-by: David Binder <[email protected]>
Co-authored-by: David Binder <[email protected]>
Co-authored-by: Javier Sagredo <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>
Co-authored-by: Matthew Pickering <[email protected]>
Co-authored-by: Fendor <[email protected]>
Co-authored-by: Hécate Moonlight <[email protected]>
Co-authored-by: Andreas Klebinger <[email protected]>
Co-authored-by: Francesco Ariis <[email protected]>
Co-authored-by: Troels Henriksen <[email protected]>
Co-authored-by: Samuel Thibault <[email protected]>
Co-authored-by: Erik de Castro Lopo <[email protected]>
Co-authored-by: brandon s allbery kf8nh <[email protected]>
Co-authored-by: John Paul Adrian Glaubitz <[email protected]>
Co-authored-by: Kristen Kozak <[email protected]>
Co-authored-by: Javier Sagredo <[email protected]>
erikd added a commit to erikd/cabal that referenced this issue Apr 22, 2024
…ange only. (haskell#9386)

* add more breadcrumbs for how to use remote packages.

* Hackage should be capitalized

* Update doc/cabal-project.rst

reword.

* Update doc/cabal-project.rst

reword.

* Update doc/cabal-project.rst

clearer.

* Update doc/cabal-project.rst

clearer!

* Update doc/cabal-project.rst

good mechanical description.

* wrap.

* Update doc/cabal-project.rst

add missing double ticks.

* clarify english, and follow a linguistic pattern better.

* Update doc/cabal-project.rst

* doc: render math with HTML to make it selectable (fix haskell#8453) (haskell#9361)

* doc: render math with HTML to make it selectable (fix haskell#8453)

* Update doc/conf.py

Co-authored-by: Bryan Richter <[email protected]>

---------

Co-authored-by: Bryan Richter <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Avoid double space in "Executing install plan ..."

* Add a change log entry for double space avoidance

* Ignore CmmSourcesExe Demo

Ignore because it warns about missing MachDeps.h

* [cabal-7825] Implement external command system

Fix haskell#2349 and haskell#7825

* Bump to latest dependencies for GHC 9.8.1

* cabal.project: clean out obsolete `allow-newer`s

* update GH validate workflow to ghc 9.2.8, 9.4.7, 9.6.3

* Revert haskell#3639 (Don't pass -package-db and -package flags to --abi-hash) (haskell#9384)

* Revert haskell#3639 (Don't pass -package-db and -package flags to --abi-hash)

With ghc>=9.6 `ghc --abi-hash` initialises the plugins so it will fail
if a cabal file specifies `ghc-options: -fplugin=Foo`.

Closes: haskell#9375

* Also revert in GHC.hs

---------

Co-authored-by: Hamish Mackenzie <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Use the newer haskell-actions organisation

* Restructure Cabal documentation top-level parts

The goal is for users to easier find pages for typical problems through search engines and page navigation.
- The top-level layout is based on the popular documentation structure by https://documentation.divio.com/ to give a
   clear structure to users and future documentation contributors:
  * Guides: Present a solution to a single, atomic, typical user problem.
  * Reference: Describe user API (CLI fields, syntax etc) with technical rigour and completeness.
  * Explanation: Discuss background information, scope, design decisions etc.
- Move existing documentation roughly into these categories with minimal editing as the basis for further editing.
- Rename guide titles to mention how-to for improving SEO.
- Rename some files to improve SEO since that name becomes part of the URL (often called slug).
  Important page keywords should appear in the slug as well to make pages rank higher in search engines.

* Rename master_doc to root_doc (changed in version 4.0 of Sphynx)

* Add instance Ord for Field, FieldLine, SectionArg and Name

* Do not run CI for documentation changes

The github workflows are not run if the
changes are completely contained within
the doc/ subdirectory. The only exception
is the users-guide.yml github action.

* Move Backpack section to user guides

* Remove TBW virtual modules section

* Add reinstall test to LinkerOptions/NonignoredConfigs

* Record install options

* Reject index-states after last known index-state (haskell#8944)

Co-authored-by: Javier Sagredo <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>

* Note how to do "not equal" with constraints

* Use comma with then

Co-authored-by: Artem Pelenitsyn <[email protected]>

* Use narrow rather than upset

* Say something about hackage deprecations

* Fix AutogenModulesToggling test

By converting this to a setupTest we use the in-tree Cabal library
rather than relying on a proxy of the GHC version to provide the right
Cabal library version.

Supersedes haskell#9398

* Require version 3,11 of Cabal to support --semaphore flag

Fixes haskell#9197

* Add dependencies used by `PackageTests` to exe:cabal-tests

The runner allows the tests to use extra dependencies and the custom Prelude
from 'cabal-testsuite'.
However, if the tests use a dependency, say 'directory', and there are two
packages with the same unit id available in the store, the test fails since
it doesn't know which one to pick.
By including an extra dependency to directory, we force the test runner to
use a specific version directory, fixing the test failure.

* Use Paths_cabal_install for cabal-install version number (haskell#9421)

* Use PackageInfo for cabal-install version number

* Use Paths_cabal_install instead

* Adjust documentation

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Document --profiling-detail in setup-commands.

Fixes haskell#9182

* Add test requirement to PR template

Adding test becomes a checkmark instead of “bonus points”.

* A 'cabal path' command. (haskell#8879)

* Add a 'cabal path' command.

* Formatting fix.

* Another formatting fix.

* Categorise "cabal path" as global command.

* Allow individual paths to be printed.

* Less duplication.

* Add config-file to "cabal path".

* Use sum type instead of strings.

* cabal path: support --installdir.

* Add documentation.

* Better text.

* Formatting.

* Add some tests.

* Improve tests.

* Add changelog entry.

* Mention "cabal path" in directory documentation.

---------

Co-authored-by: Artem Pelenitsyn <[email protected]>

* Reimplement `cabal check` (haskell#8427)

* Fix Semigroup target instance

When two target names are the same, `mappend`ing them should not
error but just pick the first name.

* Add `desugarBuildToolSimple`

* Reimplement cabal check

* Reorder test output

* Fix autogen modules tests .cabal files

* Add a number of tests

* Add test for haskell#7423

i.e. Do not warn on -O2 if under off-by-default package configuration
flag conditional.

* Add a regression for:

    * Add another -WErrr test
        This is to make sure we do *not* report it if it is under
        a user, off-by-default flag.
    * Add test for non manual user flags.
    * Add “absolute path in extra-lib-dirs” test
    * Add if/else test
    * Add “dircheck on abspath” check
    * Add Package version internal test
    * Add PackageVersionsStraddle test

* Add changelog for haskell#8427

* Integrate various reviews

* Integrate Artem’s review

(review) Clarify `combineNames` documentation

By explaining the way it operates (working if the two names are equal
or one is empty) and renaming the function from `combineName` to
`combineNames`.

(review) Use guards instead of if/then/else

(review) Match inside argument list

(review) Replace “white” with “allow”

(review) Fix typo in comment

(review) Fix typo in Check module documentation

(review) Harmonise indentation for `data` decls

First field goes in a new line than the data constructor, so we
have more space.

(review) Rename `Prim` module to `Types`

(review) Add checkPackageFilesGPD

`checkPackageFiles` — which works on PD — was used to perform IO. We
introduce a function that does the same thing but works on GPD (which
is more principled).

`checkPackageFiles` cannot just be removed, since it is part of the
interface of Distribution.PackageDescription.Check. Deprecation can
be planned once “new check” is up and running.

* Integrate Andreas’ review

(review) Add named section to missing upper bound check

“miss upper bound” checks will now list target type and name (“On
executable 'myexe', these packages miss upper bounds”) for easier
fixing by the user.

(review) remove `cabal gen-bounds` suggestion

Reasonable as `cabal gen-bounds` is stricter than `cabal check`, see
haskell#8427 (comment)
Once `gen-bounds` behaves in line with `check` we can readd the
suggestion.

(review) Do not warn on shared bounds

When a target which depends on an internal library shares some
dependencies with the latter, do not warn on upper bounds.

An example is clearer

    library
     build-depends: text < 5
    ⁝
     build-depends: myPackage,        ← no warning, internal
                    text,             ← no warning, shared bound
                    monadacme         ← warning!

* Integrate Artem’s review /II

(review) Split Check.hs

Check.hs has been split in multiple file, each une sub 1000 lines:

Check              857 lines
Check.Common       147 lines
Check.Conditional  204 lines
Check.Monad        352 lines
Check.Paths        387 lines
Check.Target       765 lines
Check.Warning      865 lines

Migration guide:
- Check              GPD/PD checks plus work-tree checks.
- Check.Common       common types and functions that are
                     *not* part of monadic checking setup.
- Check.Conditional  checks on CondTree and related matter
                     (variables, duplicate modules).
- Check.Monad        Backbone of the checks, monadic inter-
                     face and related functions.
- Check.Paths        Checks on files, directories, globs.
- Check.Target       Checks on realised targets (libraries,
                     executables, benchmarks, testsuites).
- Check.Warning      Datatypes and strings for warnings
                     and severities.

(review) remove useless section header

(review) Fix typo

(review) Add warnings documentation (list)

For each warning, we document constructor/brief description
in the manual.  This might not be much useful as not but it
will come handy when introducing `--ignore=WARN` and similar
flags.

* (review Andreas) Clarify CheckExplanation comment

Whoever modifies `CheckExplanation` data constructors needs to be
aware that the documentation in  doc/cabal-commands.rst  has to be
updated too.

* Move internal Check modules to `other-modules`

No need to expose Distribution.PackageDescription.Check.*
to the world. API for checking, for cabal-install and other
tools, should be in Distribution.PackageDescription.Check.

* Make fourmolu happy

Cabal codebase has now a formatter/style standard (see haskell#8950).

“Ravioli ravioli, give me the formuoli”

* Do not check for OptO in scripts

See haskell#8963 for reason and clarification requests.

* Remove useless PackageId parameter

It is now in the Reader part of CheckM monad.

* Do not check PVP on internal targets

Internal: testsuite, benchmark.
See haskell#8361.

* Make hlint happy

* Fix haskell#9122

When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See haskell#9132.

* Fix grammar

neither…nor, completing what done in haskell#9162

* Integrate Brandon’s review: grammar

* Remove unnecessary `-fvia-C` check

Brandon’s review/II.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* ci: Enable windows tests for 9.6.3

There were two failing tests:

1. CCompilerOverride, was attempting to use gcc.exe rather than
   clang.exe without also overriding the C options which led to
   incorrect options being passed to gcc.exe. The fix is to override to
   clang.exe on ghc-9.4 or newer.
2. ForeignLibs exposes a bug in GHC
   (https://gitlab.haskell.org/ghc/ghc/-/issues/24185) and hence is
   skipped for GHCs newer than 9.4 where it was first introduced.

Towards fixing haskell#8451, we just need to fix the shared library issue now.

* testsuite: Be explicit about runtime test dependencies

Issue haskell#8356 reports occasional errors from running the testsuite about
multiple package versions available. This stems from the invokation of
`runghc` not being explicit about all dependencies of the testsuite.

The solution is provide a component in the cabal file which is explicit
about which packages the tests can depend on. This component has a
build-depends section which lists all the dependencies that the tests
require.

It would be better if this component was a library component but we
can't do this with a Custom setup because of limitations to do with
per-component builds.

Then we also enable `-hide-all-packages`, so the dependency will not be
available if it is not explicitly listed as a dependency.

You could also imagine a future where the Setup.hs script found the test
files and compiled a single executable which would run all the tests,
rather than invoking runghc on each one individually.

Fixes haskell#8356

* hurd: Enable using $ORIGIN in RPATH

GNU/Hurd fully supports RPATH and the $ORIGIN development, and we indeed
want to use it for relocatable installations shipped in Debian GNU/Hurd.

* Fix the platform string for GNU/Hurd

Since version 9.4.7-1, ghc fails to build on the GNU/Hurd port of Debian,
see

https://buildd.debian.org/status/fetch.php?pkg=ghc&arch=hurd-i386&ver=9.4.7-1&stamp=1697717885&raw=0

Error, rule finished running but did not produce file:
  _build/stage0/lib/i386-gnu-ghc-9.4.6/ghc-boot-th-9.4.7/libHSghc-boot-th-9.4.7.a

and indeed, what did get produce was rather
_build/stage0/lib/i386-hurd-ghc-9.4.6/ghc-boot-th-9.4.7/libHSghc-boot-th-9.4.7.a
(i386-hurd instead of i386-gnu).

This is due to confusion between hurd and gnu in various places.  Apparently
previous versions of ghc were using gnu for the GNU/Hurd port, and thus
putting libraries etc. in i386-gnu. So we have to follow the existing
practice.

* Fix configuation of ldProgram

Standard GNU `ld` ues `--relocatable` while `ld.gold` uses a `-relocatable`
flag (with a single `-`). Code will now detect both versions.

* Chain configuration of ldProgram

`ldProgram` gets configured in two places, a seemingly default and
a GHC specific version. The later needs to be updated so that it
first calls the default configuration and then the new GHC version.

* Use linker capability detection to improve linker use

The function `comperSupportsGhciLibs` has been renamed to
`linkerSupportsGhciLibs` because its about the linker not the compiler.

The function `comperSupportsGhciLibs` was using the compiler version
as a proxy for whether the linker supports relocatable objects. Now
support for relocatable objects is detected by running the linker.

* add `merge+no rebase`

and a few typos while reviewing

* Add support for 64-bit SPARC as a separate architecture

Previously, sparc64 was defined as an alias for the 32-bit SPARC
architecture which was true while SPARC mainland was mostly 32
bits. More recently, 64-bit SPARC has become a port of its own,
so it needs to be treated as a separate architecture.

* Remove debug-conflict-sets flag from solver package

Fixes haskell#8937.

The debug-conflict-sets build flag probably hasn't been used for a long time,
and it isn't currently tested. This commit removes the flag, converts the
ConflictSet type back to a newtype, and removes an unnecessary instance.

* Finish improvements to the CI configuration for documentation changes (haskell#9460)

* Add bootstrap postjob to CI config

Add a new job to the bootstrap.yml GitHub action config.
This job succeeds if, and only if, all the other bootstrap
jobs succeed.

* Do not run bootstrap CI jobs for documentation changes

The approach was already introduced in haskell#9355 for the validate jobs.
This commit introduces the same change also for the bootstrap jobs.

* Also ignore CONTRIBUTING.md and README.md in CI

We do not run the entire CI suite for documentation changes.
Previously, only changes which were restricted to the 'docs/'
subdirectory were considered to be documentation changes.
With this commit we also recognize changes to README.md and
CONTRIBUTING.md as documentation changes.

* Document improved CI for documentation in CONTRIBUTING.md

The CONTRIBUTING.md file now mentions that documentation changes
do not waste expensive CI resources.

* Recognize all README.md in subdirs as documentation

Expensive CI jobs should not run on changes which affect only
README.md files.

* formatting: Add style-commit makefile target

This target allows you to format a range of commits, for example:

```
make style-commit COMMIT=HEAD~1
> Last commit is formatted
make style-commit COMMIT=abcde
> Commits between HEAD and abcde are formatted
```

* Fix assertion failure when combining build-tool-depends and --enable-documentation

The `setDocumentation` function was modifying the elaborated package
after the hash was computed. This led to the assertion failing as the
computed hash was different to what was computed in the initial install
plan.

Therefore in order to fix this we either needed to:

1. Set elabBuildHaddocks = False at the point where the hash is
   initially computed.
2. Verify that elabBuildHaddocks = True will not lead to unexpected
   results.

The latter has been implemented.

The elabBuildHaddocks option is only consulted in
`hasValidHaddockTargets`, at which point documentation building the
executable component is disabled because elabHaddockExecutables is
False.

In the added test we ensure this by checking that we didn't build
documentation for the executable which is built because of
build-tool-depends.

Fixes haskell#6006 haskell#8313

* testsuite: Improve error message in findDependencyInStore

* Only move code to Simple/GHC/Build*

* CPP mingw32_HOST_OS for more imports

* cabal-install-solver: fix pkgconf 1.9 --modversion regression

Check that the numbers of *versions* output is equal to the number of pkgconf's

fixes haskell#8923

The pkgconf behavior was reverted upstream in 2.0

(this should cover the case too of checking that equal pkgList lines are output also)

* External commands: Add tests for haskell#9402 haskell#9403 haskell#9404

This adds 4 tests which test the new external commands feature:

* ExternalCommand - Tests the expected usage of external command invoked
  via cabal-install
* ExternalCommandSetup - Tests that the ./Setup interface does not
  support external commands (haskell#9403)
* ExternalCommandEnv - Tests that environment variables are set and
  preserved appropiately  (haskell#9402)
* ExternalCommandHelp - Test that `cabal help <cmd>` is interpreted appropiately (haskell#9404)

* Finish off the external commands feature

* Remove 'CommandDelegate' in favour of abstracting the fallback in
  'commandsRun', there is a new variant 'commdandRunWithFallback' which
  takes a continuation
  - This restores the modularity between the `Cabal` library and
    `cabal-install` as now `Cabal` doesn't need to know anything about
    the external command interface.
  - Fixes haskell#9403
* Set the $CABAL environment variable to the current executable path
  - This allows external commands to be implemented by calling $CABAL,
    which is strongly preferred to linking against the Cabal library as
    there is no easy way to guantee your tool and `cabal-install` link
    against the same `Cabal` library.
  - Fixes haskell#9402
* Pass the name of the argument
  - This allows external commands to be implemented as symlinks to an
    executable, and multiple commands can be interpreted by the same
    executable.
  - Fixes haskell#9405
* `cabal help <cmd>` is interpreted as `cabal-<cmd> --help` for external
  commands.
  - This allows the `help` command to also work for external
  commands and hence they are better integrated into cabal-install.
  - Fixes haskell#9404

The tests are updated to test all these additions.

These features bring the external command interface up to par with the
cargo external command interface.

* Use Base16 hash for script path.

Issue haskell#9334 shows that `%` characters on Windows result in invalid
paths, also `/` characters on Linux create invalid paths.

This changes from using base64 to using base16 with the same length
we use for unit-ids.

* Migrate to haskell-actions/setup

As of 2023-09-09, haskell/action/setup is no longer maintained.

The comment

  # latest is mandatory for cabal-testsuite, see haskell#8133

is removed; as the validate job was already fixing a version of cabal-install.

* testsuite: Introduce Cabal-tests library for common testsuite functions

I noticed that Distribution.Utils.TempTestDir was only used in the
testsuite but defined in the Cabal library. Rather than expose this in
the public interface of the `Cabal` library, it is cleaner to refactor
it into a separate library (`Cabal-tests`) which can be used by any
testsuite component.

Also, in future it gives a clearer place to put utility functions which
need to be shared across the testsuite but not exposed in Cabal.
Cabal-tests can also freely add dependencies (such as exceptions) which
we might want to avoid adding to the Cabal library.

Fixes haskell#9453

* GHC 9.8 compat: pacify -Wx-partial

* GHC 9.8 compat: update hashes of data structures as computed by Structured

It seems, GHC 9.8 changed something in the code generation for data types.
Structured class is supposed to catch such cases.

* GHC 9.8 compat: bump base, update Unknown GHC

And bump Cabal's "supported version" of GHC

* CI: GHC 9.8

* merge master

* Hackage should be capitalized

---------

Co-authored-by: Artem Pelenitsyn <[email protected]>
Co-authored-by: Bryan Richter <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Phil de Joux <[email protected]>
Co-authored-by: Yvan Sraka <[email protected]>
Co-authored-by: Andreas Abel <[email protected]>
Co-authored-by: Jens Petersen <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>
Co-authored-by: Hamish Mackenzie <[email protected]>
Co-authored-by: Malte Neuss <[email protected]>
Co-authored-by: Bodigrim <[email protected]>
Co-authored-by: David Binder <[email protected]>
Co-authored-by: David Binder <[email protected]>
Co-authored-by: Javier Sagredo <[email protected]>
Co-authored-by: Andrea Bedini <[email protected]>
Co-authored-by: Matthew Pickering <[email protected]>
Co-authored-by: Fendor <[email protected]>
Co-authored-by: Hécate Moonlight <[email protected]>
Co-authored-by: Andreas Klebinger <[email protected]>
Co-authored-by: Francesco Ariis <[email protected]>
Co-authored-by: Troels Henriksen <[email protected]>
Co-authored-by: Samuel Thibault <[email protected]>
Co-authored-by: Erik de Castro Lopo <[email protected]>
Co-authored-by: brandon s allbery kf8nh <[email protected]>
Co-authored-by: John Paul Adrian Glaubitz <[email protected]>
Co-authored-by: Kristen Kozak <[email protected]>
Co-authored-by: Javier Sagredo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants