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

WIP: Rewrite bootstrap #6719

Closed
wants to merge 3 commits into from
Closed

Conversation

bgamari
Copy link
Contributor

@bgamari bgamari commented Apr 19, 2020

Given I've complained about this in the past, I felt compelled to pick up #6700. This currently requires a reasonably modern Python (Python 3.5 or newer) but if this is a problem we could likely relax this to Python >= 3.2.

The idea

A JSON file (generated with bootstrap.py --extract-plan) containing dependency and source information is built from plan.json. This is then used to fetch and build the bootstrapping dependencies. Since this is only to be used for bootstrapping on new architectures, we advise the users to only use the resulting cabal-install executable to build a proper cabal-install.

To-do

  • Figure out how to determine revision information; unfortunately this doesn't appear to be available from plan.json
  • Figure out story for distributing bootstrap-deps.json; should it be in the repository?
  • Document usage
  • Test in CI

@bgamari bgamari force-pushed the rewrite-bootstrap branch 2 times, most recently from a37a342 to 08cb976 Compare April 19, 2020 19:23
@bgamari bgamari mentioned this pull request Apr 19, 2020
@bgamari bgamari force-pushed the rewrite-bootstrap branch 3 times, most recently from ec42627 to 513356f Compare April 19, 2020 19:44
Copy link
Collaborator

@phadej phadej left a comment

Choose a reason for hiding this comment

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

This is good start.

At the end I'd keep generating of bootstrap-deps.json and "runner" as separate scripts, but that can be done later. (I'd also rewrite the generator later in Haskell, there is e.g .cabal-plan library etc.)

cabal-install/bootstrap.py Show resolved Hide resolved
from typing import Set, Optional, Dict, List, Tuple, \
NewType, BinaryIO, NamedTuple

ghc_path = Path('ghc')
Copy link
Collaborator

Choose a reason for hiding this comment

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

One of problems with old bootstrap was that we were somewhat sensitive to the ghc version used. We should use ghc --version info.

Or better we should parse ghc --info and find ghc-pkg using LibDir, as perfectly boostrapping ghc should be configurable (i.e. we wouldn't need to rely on PATH).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or better we should parse ghc --info and find ghc-pkg using LibDir, as perfectly boostrapping ghc should be configurable (i.e. we wouldn't need to rely on PATH).

This suggestion seems very fragile to me. The ghc-pkg wrapper in bin/ arranges to pass --global-package-db to the ghc-pkg executable in LibDir. We would need to duplicate this logic if we were to use the LibDir executable directly.

Moreover, on some platforms (e.g. NixOS) the executable in PATH is actually a distribution-provided wrapper which sets up other state. IMHO we shouldn't start poking around in LibDir. If anything we should just look for a ghc-pkg in the same directory as we found the ghc executable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It actually turns out the that the --global-package-db flag that I noted above is added by the NixOS wrapper. Nevertheless, the point stands.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm sad to learn about this.

The simple heuristics don't work:

% $(dirname $(which ghc-8.10.1))/ghc-pkg --version
GHC package manager version 8.8.3

we have better heuristics for these, but they don't work if suffix is arbitrary. I'd rather not to use heuristics, and for special (and I consider NixOS special) situations users would rather required to be explict.

NixOS probably uses wrapper because --global-package-db because they fake global installs, not actually do that. That doesn't affect bootstrap.sh because it doesn't use "extras".

cabal-install/bootstrap.py Show resolved Hide resolved
@23Skidoo
Copy link
Member

bootstrap.sh is also supposed to work when it's run from a Git checkout, I guess that this change means dropping that feature? Overall I'm +1 on making it more robust.

@bgamari
Copy link
Contributor Author

bgamari commented Apr 22, 2020

bootstrap.sh is also supposed to work when it's run from a Git checkout, I guess that this change means dropping that feature?

Not necessarily. We could decide that we want to include a bootstrap dependencies description for a couple of supported bootstrap compilers in the repository. I'll leave this decision to you and @phadej.

@phadej phadej mentioned this pull request May 6, 2020
@bgamari bgamari force-pushed the rewrite-bootstrap branch from 513356f to c2c6f8c Compare May 14, 2020 01:32
@bgamari
Copy link
Contributor Author

bgamari commented May 14, 2020

We still need to sort out if/how we want to package the build dependency sets in the tree.

@bgamari bgamari force-pushed the rewrite-bootstrap branch from ea93f10 to 0b4a20a Compare May 14, 2020 03:29
@bgamari
Copy link
Contributor Author

bgamari commented May 14, 2020

I cannot tell what the meta check is worried about.

Copy link
Collaborator

@phadej phadej left a comment

Choose a reason for hiding this comment

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

I think this is a step into right direction.

cabal-install/bootstrap.py Outdated Show resolved Hide resolved
@bgamari
Copy link
Contributor Author

bgamari commented May 18, 2020

Addressed comments.

@phadej, how would you like to handle merging this? Should I drop the bootstrap-deps.json files and then we can reintroduce them in the release branch?

bgamari added 3 commits May 20, 2020 20:43
The plan: A JSON file (generated with bootstrap.py --extract-plan)
containing dependency and source information is built from plan.json.
This is then used to fetch and build the bootstrapping dependencies.
Since this is only to be used for bootstrapping on new architectures, we
advise the users to only use the resulting cabal-install executable to
build a proper cabal-install.
@bgamari bgamari force-pushed the rewrite-bootstrap branch from f79f951 to 12ab32d Compare May 21, 2020 00:48
@bgamari
Copy link
Contributor Author

bgamari commented May 31, 2020

Ping @phadej.

@blackgnezdo
Copy link
Contributor

@phadej, I'd love to use this for building the OpenBSD port. It would be awesome to merge before 3.4.

@blackgnezdo
Copy link
Contributor

blackgnezdo commented Jun 29, 2020

Quick observation: after rebasing the boostrap*json files have to be regenerated due to new dependencies on regex-base and regex-posix at HEAD (e.g. blackgnezdo@a4daad2)

@phadej phadej self-assigned this Jul 20, 2020
@phadej
Copy link
Collaborator

phadej commented Jul 20, 2020

I'm looking at this.

  • Few notes immediately, we have to record flag selection.
  • I have different cabal dir then $HOME/.cabal, so script doesn't work.

Both are easy enough to fix, and I'll do that.

@phadej
Copy link
Collaborator

phadej commented Jul 21, 2020

Continued in #6979

@phadej phadej closed this Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants