Skip to content

Perform concretization of build-only deps separately - part two#4595

Closed
scheibelp wants to merge 102 commits intospack:developfrom
scheibelp:features/dependency-resolution
Closed

Perform concretization of build-only deps separately - part two#4595
scheibelp wants to merge 102 commits intospack:developfrom
scheibelp:features/dependency-resolution

Conversation

@scheibelp
Copy link
Copy Markdown
Member

@scheibelp scheibelp commented Jun 24, 2017

@luigi-calori @svenevs you seemed interested in #2548 and this is supposed to be better

This is intended as a replacement to #2548. It can handle a few cases that #2548 cannot. It is also intended to be useful to support concretization of new specs using previously-concretized specs, which will be useful for contexts (#4585).

It can currently concretize:

It is a relaxation on the current concretization model, which requires that only one instance of any particular package exists in a dependency DAG. The new (looser) constraints are:

  • The run/link dependencies of X and Y are synchronized if they are direct dependencies of some W
  • P and Q are synchronized if they are weakly connected via (run, link) dependency types

For example, given:

image

  • run/link dependencies are synchronized across X, W, and Y
  • run/link dependencies are synchronized across Y, W, and Z
  • this means that if python appears in X, Y, and Z that it is synchronized across all 3
  • But if python only appears in X and Z then it is not synchronized between the two

This is not as flexible as the deptype model in #3768 would allow, but it is a compromise between that and simplicity of implementation.

It works by

  • passing an object through the recursive normalization which is used for sharing dependencies across multiple branches
  • re-initializing this object when encountering a build-only dependency
  • Updates notion of node identity (no longer name-based)

TODOs

  • Perform concretization of build-only deps separately #2548 introduced the notion of an "include" deptype that also needs to be added here. For now, to demonstrate the concept, a few cases which should be "include" have been temporarily set as "link"
    • (7/13/17) the "include" deptype is now available in this PR. It is treated exactly the same as a link dependency. Any header-only library should be given the "include" deptype vs. the "build" deptype
  • Need to clean up references to Spec.normalize (they should now generally be Spec.normalize_top)
  • A couple tests need to be replaced
  • (EDIT) Ensure that a sensible error message is printed if a build dependency has a virtual dependency (directly or transitively)
  • (EDIT) Additional unit tests
  • (EDIT) update graph output now that some dependencies can be duplicated
  • (7/21/17) xproto dependency type has been updated for libx11 tree to 'include', but it should in fact be changed from build to include everywhere. This will affect many (~30) packages

Limitations introduced:

  • build-only dependencies cannot have virtual dependencies
  • (7/13/17) when accessing a dependency X using spec['X'], X must either be (a) a transitive run/link/include dependency or (b) a transitive run/link/include dependency of a direct build dependency. In other words, indirect build dependencies are excluded
  • (8/31/17) when a user specifies constraints on dependencies from the command line, they cannot constrain build-only dependencies (EDIT) no longer an issue
  • (internal change) Spec.normalize should no longer be called by itself (EDIT) no longer a problem

scheibelp added 30 commits June 1, 2017 18:18
…encies (2) rename variable storing all packages which should be in the path for build
…dencies they were not referring to the initialized spec)
…pdate compiler concretization test to specify compiler preferences for a non-build dep (as of now in this branch this is not supported)
… it should be an 'include' dep but for now its deptype is 'link')
…d dependency can appear multiple times in the dag
…wn version of the package (which results in a non-diamond shape)
…ackages constrain one another; dont need to maintain dependency contexts to figure out which specs have been visited.
…ified dependencies) - this fixes a couple failing tests for directory_layout
…spec included dependency constraints; they were swapped to using Spec.normalize_top
tgamblin pushed a commit that referenced this pull request Jan 29, 2018
This attempts to address one of the complaints at #5996 (comment):

> Repo currently caches package instances by Spec, and those Package instances have a Spec. 
> This is unnecessary and causes confusion. I think I thought that we'd need to cache instances 
> after loading package classes, but really just caching the classes is fine.

With this update, Repo's package cache is removed and Specs cache the package reference themselves. One consequence is that Specs which compare as equal will store separate instances of a Package class (not doing this creates issues for #4595 (comment)).

There were several references to Spec.package that could be replaced with Spec.package_class without any additional modifications. There are still a couple remaining references to Spec.package in Spec that would require adding functionality before replacing (e.g. calling Package.provides and Package.installed).

Note this makes it difficult to mock fetchers for tests which invokes code that reconstructs specs. test_packaging was one example of this where the updates caused a failure (in that case the error was avoided by not making an unnecessary call).

Details:
* Replace instances of spec.package with spec.package_class where a class method is being called
* Remove instances of Repo.get where Spec.package_class can be used in its place
* remove Repo.get caching instances of Package class for specs
* remove redundant check (which is also incorrect now that each spec stores its own copy of its package)
* avoid creating mirror with specs because it copies specs and those copies dont refer to the mocked fetcher (and it is also not required for the test)
* remove checks that are no longer necessary since repo doesn't cache specs
ch741 pushed a commit to ch741/spack that referenced this pull request Apr 20, 2018
This attempts to address one of the complaints at spack#5996 (comment):

> Repo currently caches package instances by Spec, and those Package instances have a Spec. 
> This is unnecessary and causes confusion. I think I thought that we'd need to cache instances 
> after loading package classes, but really just caching the classes is fine.

With this update, Repo's package cache is removed and Specs cache the package reference themselves. One consequence is that Specs which compare as equal will store separate instances of a Package class (not doing this creates issues for spack#4595 (comment)).

There were several references to Spec.package that could be replaced with Spec.package_class without any additional modifications. There are still a couple remaining references to Spec.package in Spec that would require adding functionality before replacing (e.g. calling Package.provides and Package.installed).

Note this makes it difficult to mock fetchers for tests which invokes code that reconstructs specs. test_packaging was one example of this where the updates caused a failure (in that case the error was avoided by not making an unnecessary call).

Details:
* Replace instances of spec.package with spec.package_class where a class method is being called
* Remove instances of Repo.get where Spec.package_class can be used in its place
* remove Repo.get caching instances of Package class for specs
* remove redundant check (which is also incorrect now that each spec stores its own copy of its package)
* avoid creating mirror with specs because it copies specs and those copies dont refer to the mocked fetcher (and it is also not required for the test)
* remove checks that are no longer necessary since repo doesn't cache specs
@cedricchevalier19
Copy link
Copy Markdown
Contributor

Are they any plan to go forward with this PR ?
We have troubles dealing with these kinds of build conflicts that can be avoided by doing independent concretizations. Is there anything we can do to help on this issue ?

@ghost
Copy link
Copy Markdown

ghost commented Aug 20, 2020

Is this still planned or ever going forward?

Packages like glib are completely broken due to python 3 build only dependencies for stuff like meson. While python 2 is going out of support many scientific libraries, opensource and paid, still depend on it.

@adamjstewart
Copy link
Copy Markdown
Member

@scheibelp is this PR still a work-in-progress or will it become obsolete with the new concretizer?

@tgamblin
Copy link
Copy Markdown
Member

Closing, as this has been superseded by PRs in this project: https://github.com/spack/spack/projects/48.

@tgamblin tgamblin closed this Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants