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

Binary crates, toolchain management and use #775

Merged
merged 20 commits into from Aug 18, 2021
Merged

Conversation

mosteo
Copy link
Member

@mosteo mosteo commented Jul 26, 2021

This PR implements a variety of changes to support the use of binary compilers packaged through Alire:

  • New binary crates.
  • provides property to allow mixed gnat/gnat_xxx dependencies.
    • Changes in the solver and related types to use this property properly.
    • Changes in the solver to prefer locally installed binary crates to remote available ones.
  • alr toolchain to inspect/[un]install/select toolchains.

Still missing:

  • Passing existing tests.
  • New tests.
  • Scrub the code for leftover comments / self-review.

Documentation might be a bit sparse yet, and require some tweaking.

@Fabien-Chouteau , now the toolchain selection assistant is run the first time a valid alire folder is required. We might disable this entirely, or run it only if there is no gnat/gprbuild in the PATH, or something else if you see fit.

mosteo and others added 11 commits July 22, 2021 19:16
Essentially, we have a second location for dependencies at ${ALR_CONFIG}/cache.
In following PRs the releases therein will be available during dependency
resolution, to be reused.

`alr install` for manual crate installation

Installed crates are used by the solver

Autodiscover installed releases

Show differences due to changed install status

Install: implement release removal
Menu for choosing among multiple options

Show actual compiler versions to the user

Install and remember the user choice

User_Input: Take a possible Ctrl-D into account
New, more flexible provides type

WIP: going back to provides as list of deps

All but loading of "provides"

Loading of provides

Installed provides are used during solving

They're not yet used for regular dependencies

Display provider in the `alr with` variants

Prevent solving of conflicting dependencies

If two releases provide the same crate, they cannot be simultaneously in a
solution.

solver tweaks for provides + externals

Improvements to solution space by reusing releases

When adding a release to a solution, check whether other dependencies can be
satisfied by this same release. Not a big deal, could be disabled if too costly
in the future.
Insert explicit dependency on the configured gnat

Do not explicitly insert dependency on toolchain

Instead, we simply coerce when given a generic gnat dependency into the
configured one. This is less intrusive as the user does not see unexpected
dependencies on the compiler in the solution (unless explicitly requested).

Extra info in `alr install` list

Generalized assistant for all tools in toolchain
For now this is restricted to a single alternate crate name. By necessity, the
equivalence has to be to the same version, whereas provides for regular
releases are more general as they can rely on precise versions which are known
in advance.
This is logical because these are always available in all configurations. But
the important benefit is that the solver can use them in preference to a remote
native compiler.
src/alire/alire-utils-user_input.adb Outdated Show resolved Hide resolved
doc/catalog-format-spec.md Outdated Show resolved Hide resolved
@mosteo mosteo force-pushed the feat/toolchains branch 2 times, most recently from d27e2b5 to 4eb06cb Compare July 27, 2021 08:28
@mosteo mosteo force-pushed the feat/toolchains branch 5 times, most recently from ff45b3f to 3f4db3e Compare July 27, 2021 11:34
@mosteo mosteo force-pushed the feat/toolchains branch 2 times, most recently from 655e4f9 to d10355d Compare July 28, 2021 16:50
@mosteo mosteo force-pushed the feat/toolchains branch 2 times, most recently from 5b084c1 to 8462f71 Compare July 29, 2021 12:42
@mosteo mosteo force-pushed the feat/toolchains branch 3 times, most recently from 8353758 to 56639f5 Compare July 29, 2021 16:38
@mosteo
Copy link
Member Author

mosteo commented Jul 29, 2021

Hi @Fabien-Chouteau . I still have to see what's going on with Windows, but this one is ready for review. I apologize in advance because on top of being a large PR in itself, I had to do a couple of refactors towards the end to break circularities that mud things even more. I'll try to compartmentalize things better next time 😓

@mosteo mosteo marked this pull request as ready for review July 29, 2021 16:41
@mosteo mosteo force-pushed the feat/toolchains branch 4 times, most recently from 57ed3a5 to 78c87fb Compare July 30, 2021 10:20
1. A cross-compiler from the index, that will be deployed with the rest of dependencies.

- Solution with dependencies on a target-specific GNAT (`gnat_native`, `gnat_ricv_elf`,
etc.): The `alr` solver will provide one compiler in the environment, applying the
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to have both an explicit dependency on gnat_native and gnat_riscv64_elf? It should be.

Copy link
Member Author

Choose a reason for hiding this comment

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

Simultaneously in a crate? How's that supposed to work?

Copy link
Member

Choose a reason for hiding this comment

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

I have one video game crate (shoot_n_loot) that builds both the embedded version of the game and a native simulator to play it on the computer. But maybe that's a very bad idea ^^

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually was worried about this use case but I guess I didn't traslate it properly in our talks. This is the one where I saw your idea on conditional dependencies on something provided via command line/dependent crate configuration could be useful:

alr build target:=native  # arbitrary name, not predefined (or defined in the configuration section of the crate)

and then we can have in the toml:

[[depends-on."case(crate.target)".native]]
gnat_native = "*"
[[depends-on."case(crate.target)".riscv]]
gnat_riscv_elf = "*"

There should be a default somehow for automated builds though.

For a later date obviously...

Otherwise, I guess we can do an exception about the gnat crate not being conflicting among compilers. But something nags me at that being unkind to people not interested in all targets.

Copy link
Member

Choose a reason for hiding this comment

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

Let's keep it simple for now and only allow one compiler.

Copy link
Member

Choose a reason for hiding this comment

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

I have one other use case.

A cross project that uses native tools to generate code, for instance https://alire.ada.dev/crates/are.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, that is a legitimate situation that we ought to support. I'll try to come up with a solution in a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed in #780

doc/toolchains.md Show resolved Hide resolved
doc/toolchains.md Show resolved Hide resolved
function Is_Provided (This : State) return Boolean;
-- True when the release name is different from the dependency crate

function Is_Shared (This : State) return Boolean;
Copy link
Member

Choose a reason for hiding this comment

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

Should it be Is_Installed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I started using the idea of 'shared releases' internally, as these are just regular releases in a shared location. But it can be changed if confusing (likewise then for the Alire.Shared package).

Copy link
Member

Choose a reason for hiding this comment

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

It will depend on how and if we implement an alr install I guess. We can keep shared for now, up to you.

Copy link
Member Author

Choose a reason for hiding this comment

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

My current mood is to avoid install entirely. I was thinking of using alr share for non-toolchain crates shared in the configuration, and alr export for the gprinstall-in-common-prefix idea. So we convey that exported crates are something the user wants to use out of Alire. But I'm easy to sway on these naming things.

For now if you don't mind I'll leave it as is then.

Copy link
Contributor

Choose a reason for hiding this comment

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

If the user wants to make some application available system-wide, I would say the usual keyword used by package managers and build systems is install instead of export. export sounds like an action to extract data from an application.

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case we would be "extracting" binaries from the Alire ecosystem. But I see your point. alr share for shared dependencies across workspaces and alr install for deploying crates to a common prefix can also work for me.

Another possibility is to have it under get, e.g., alr get --install. The operation in itself is essentially an alr get + alr build + gprinstall.

In particular, the avoidance of downloading a compiler for a generic gnat
dependency. This is tested in testsuite/tests/solver/compiler-installed
@mosteo
Copy link
Member Author

mosteo commented Aug 17, 2021

Hi @Fabien-Chouteau , with #780 and #781 in the pipeline I think we are ready feature-wise for this one. There is the matter of whether to disable sha256, and the reworded explanation in toolchains.md. I can take another stab at it if you want, unless you're already on it.

@Fabien-Chouteau
Copy link
Member

Thanks @mosteo

I can take another stab at it if you want, unless you're already on it.
Unfortunately no, I didn't take the time to work on this.

Maybe we can do a release candidate and ask for feedback. Based on the feedback we could be able to improve the doc...

@mosteo
Copy link
Member Author

mosteo commented Aug 18, 2021

OK then, in fact I should update the doc in #780 at least to match the current situation.

@mosteo mosteo changed the base branch from master to merging/toolchains August 18, 2021 10:28
@mosteo mosteo merged commit d6ea245 into merging/toolchains Aug 18, 2021
@mosteo mosteo deleted the feat/toolchains branch August 18, 2021 10:28
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.

None yet

3 participants