Commit graph

4796 commits

Author SHA1 Message Date
Todd Gamblin
56acb5a0c7 bugfix: infinite loop when building a set from incomplete specs (#20649)
This code in `SpecBuilder.build_specs()` introduced in #20203, can loop
seemingly interminably for very large specs:

```python
set([spec.root for spec in self._specs.values()])
```

It's deceptive, because it seems like there must be an issue with
`spec.root`, but that works fine. It's building the set afterwards that
takes forever, at least on `r-rminer`. Currently if you try running
`spack solve r-rminer`, it loops infinitely and spins up your fan.

The issue (I think) is that the spec is not yet complete when this is
run, and something is going wrong when constructing and comparing so many
values produced by `_cmp_key()`. We can investigate the efficiency of
`_cmp_key()` separately, but for now, the fix is:

```python
roots = [spec.root for spec in self._specs.values()]
roots = dict((id(r), r) for r in roots)
```

We know the specs in `self._specs` are distinct (they just came out of
the solver), so we can just use their `id()` to unique them here. This
gets rid of the infinite loop.
2021-02-17 17:07:35 -08:00
Massimiliano Culpo
ec42016241 concretizer: generate facts for externals
Generate only facts for external specs. Substitute the
use of already grounded rules with non-grounded rules
in concretize.lp
2021-02-17 17:07:35 -08:00
Greg Becker
f7195123d4 bugfix: do not write empty default dicts/lists in envs (#20526)
Environment yaml files should not have default values written to them.

To accomplish this, we change the validator to not add the default values to yaml. We rely on the code to set defaults for all values (and use defaulting getters like dict.get(key, default)).

Includes regression test.
2021-02-17 17:07:34 -08:00
Robert Cohn
290043b72a Add Intel oneAPI packages (#20411)
This creates a set of packages which all use the same script to install
components of Intel oneAPI. This includes:

* An inheritable IntelOneApiPackage which knows how to invoke the
  installation script based on which components are requested
* For components which include headers/libraries, an inheritable
  IntelOneApiLibraryPackage is provided to locate them
* Individual packages for DAL, DNN, TBB, etc.
* A package for the Intel oneAPI compilers (icx/ifx). This also includes
  icc/ifortran but these are not currently detected in this PR
2021-02-17 17:07:33 -08:00
Todd Gamblin
1a1babe185 concretizer: refactor conditional rules to be less repetitious (#20507)
We have to repeat all the spec attributes in a number of places in
`concretize.lp`, and Spack has a fair number of spec attributes. If we
instead add some rules up front that establish equivalencies like this:

```
    node(Package) :- attr("node", Package).
    attr("node", Package) :- node(Package).

    version(Package, Version) :- attr("version", Package, Version).
    attr("version", Package, Version) :- version(Package, Version).
```

We can rewrite most of the repetitive conditions with `attr` and repeat
only for each arity (there are only 3 arities for spec attributes so far)
as opposed to each spec attribute. This makes the logic easier to read
and the rules easier to follow.

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2021-02-17 17:07:32 -08:00
Massimiliano Culpo
acd523c7f3 concretizer: optimize loop on compiler version
Similar to the optimization on platform
2021-02-17 17:07:32 -08:00
Massimiliano Culpo
4bbc6eec51 concretizer: optimized loop on node platforms
We can speed-up the computation by avoiding a
double loop in a cardinality constraint and
enforcing the rule instead as an integrity
constraint.
2021-02-17 17:07:31 -08:00
Massimiliano Culpo
cb76c5a90d concretizer: fix failing unit tests 2021-02-17 17:07:31 -08:00
Massimiliano Culpo
ab3f53d781 concretizer: emit facts for integrity constraints 2021-02-17 17:07:30 -08:00
Massimiliano Culpo
364c5b636c concretizer: emit facts for constraints on imposed dependencies 2021-02-17 17:07:30 -08:00
Massimiliano Culpo
02e0ea6105 concretizer: avoid redundant grounding on dependency types 2021-02-17 17:07:30 -08:00
Todd Gamblin
ff9ee9f243 concretizer: move conditional dependency logic into concretize.lp
Continuing to convert everything in `asp.py` into facts, make the
generation of ground rules for conditional dependencies use facts, and
move the semantics into `concretize.lp`.

This is probably the most complex logic in Spack, as dependencies can be
conditional on anything, and we need conditional ASP rules to accumulate
and map all the dependency conditions to spec attributes.

The logic looks complicated, but essentially it accumulates any
constraints associated with particular conditions into a fact associated
with the condition by id. Then, if *any* condition id's fact is True, we
trigger the dependency.

This simplifies the way `declared_dependency()` works -- the dependency
is now declared regardless of whether it is conditional, and the
conditions are handled by `dependency_condition()` facts.
2021-02-17 17:07:29 -08:00
Todd Gamblin
6c6631cfdc concretizer: spec_clauses should traverse dependencies
There are currently no places where we do not want to traverse
dependencies in `spec_clauses()`, so simplify the logic by consolidating
`spec_traverse_clauses()` with `spec_clauses()`.
2021-02-17 17:07:29 -08:00
Todd Gamblin
ea617f807f concretizer: pull _develop_specs_from_env out of main setup loop 2021-02-17 17:07:28 -08:00
Todd Gamblin
d0dfd3cb82 concretizer: add #defined statements to avoid warnings.
`version_satisfies/2` and `node_compiler_version_satisfies/3` are
generated but need `#defined` directives to avoid " info: atom does not
occur in any rule head:" warnings.
2021-02-17 17:07:28 -08:00
Massimiliano Culpo
a4066a52be asp: memoize the list of all target_specs to speed-up setup phase (#20473)
* asp: memoize the list of all target_specs to speed-up setup phase

* asp: memoize using a cache per solver object
2021-02-17 17:07:28 -08:00
Scott Wittenburg
18c5f10ae7 ci: fixes for compiler bootstrapping (#17563)
This PR addresses a number of issues related to compiler bootstrapping.

Specifically:
1. Collect compilers to be bootstrapped while queueing in installer
Compiler tasks currently have an incomplete list in their task.dependents,
making those packages fail to install as they think they have not all their
dependencies installed. This PR collects the dependents and sets them on
compiler tasks.

2. allow boostrapped compilers to back off target
Bootstrapped compilers may be built with a compiler that doesn't support
the target used by the rest of the spec.  Allow them to build with less
aggressive target optimization settings.

3. Support for target ranges
Backing off the target necessitates computing target ranges, so make Spack
handle those properly.  Notably, this adds an intersection method for target
ranges and fixes the way ranges are satisfied and constrained on Spec objects.

This PR also:
- adds testing
- improves concretizer handling of target ranges

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
Co-authored-by: Gregory Becker <becker33@llnl.gov>
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2021-02-17 17:07:27 -08:00
Massimiliano Culpo
d82d2bb2db unit-tests: ensure that installed packages can be reused (#20307)
refers #20292

Added a unit test that ensures we can reuse installed
packages even if in the repository variants have been
removed or added.
2021-02-17 17:07:27 -08:00
Greg Becker
378af922a2 Fix comparisons for abstract specs (#20341)
bug only relevant for python3
2021-02-17 17:07:27 -08:00
Todd Gamblin
12d035b225 concretizer: don't use one_of_iff for range constraints (#20383)
Currently, version range constraints, compiler version range constraints,
and target range constraints are implemented by generating ground rules
from `asp.py`, via `one_of_iff()`.  The rules look like this:

```
version_satisfies("python", "2.6:") :- 1 { version("python", "2.4"); ... } 1.
1 { version("python", "2.4"); ... } 1. :- version_satisfies("python", "2.6:").
```

So, `version_satisfies(Package, Constraint)` is true if and only if the
package is assigned a version that satisfies the constraint. We
precompute the set of known versions that satisfy the constraint, and
generate the rule in `SpackSolverSetup`.

We shouldn't need to generate already-ground rules for this. Rather, we
should leave it to the grounder to do the grounding, and generate facts
so that the constraint semantics can be defined in `concretize.lp`.

We can replace rules like the ones above with facts like this:

```
version_satisfies("python", "2.6:", "2.4")
```

And ground them in `concretize.lp` with rules like this:

```
1 { version(Package, Version) : version_satisfies(Package, Constraint, Version) } 1
  :- version_satisfies(Package, Constraint).
version_satisfies(Package, Constraint)
  :- version(Package, Version), version_satisfies(Package, Constraint, Version).
```

The top rule is the same as before. It makes conditional dependencies and
other places where version constraints are used work properly. Note that
we do not need the cardinality constraint for the second rule -- we
already have rules saying there can be only one version assigned to a
package, so we can just infer from `version/2` `version_satisfies/3`.
This form is also safe for grounding -- If we used the original form we'd
have unsafe variables like `Constraint` and `Package` -- the original
form only really worked when specified as ground to begin with.

- [x] use facts instead of generating rules for package version constraints
- [x] use facts instead of generating rules for compiler version constraints
- [x] use facts instead of generating rules for target range constraints
- [x] remove `one_of_iff()` and `iff()` as they're no longer needed
2021-02-17 17:07:26 -08:00
Massimiliano Culpo
bf3a873a42 package sanity: ensure all variant defaults are allowed values (#20373) 2021-02-17 17:07:26 -08:00
Todd Gamblin
27f6b3df92 concretizer: remove clingo command-line driver (#20362)
I was keeping the old `clingo` driver code around in case we had to run
using the command line tool instad of through the Python interface.

So far, the command line is faster than running through Python, but I'm
working on fixing that.  I found that if I do this:

```python
control = clingo.Control()
control.load("concretize.lp")
control.load("hdf5.lp")       # code from spack solve --show asp hdf5
control.load("display.lp")

control.ground([("base", [])])
control.solve(...)
```

It's just as fast as the command line tool. So we can always generate the
code and load it manually if we need to -- we don't need two drivers for
clingo. Given that the python interface is also the only way to get unsat
cores, I think we pretty much have to use it.

So, I'm removing the old command line driver and other unused code. We
can dig it up again from the history if it is needed.
2021-02-17 17:07:25 -08:00
Tamara Dahlgren
802c5bdff7 Tests: enable re-use of post-install tests in smoke tests (#20298) 2021-02-17 17:07:25 -08:00
Andrew W Elble
ab3f1b10db concretizer: try hard to obtain all needed variant_possible_value()'s (#20102)
Track all the variant values mentioned when emitting constraints, validate them
and emit a fact that allows them as possible values.

This modification ensures that open-ended variants (variants accepting any string 
or any integer) are projected to the finite set of values that are relevant for this 
concretization.
2021-02-17 17:07:24 -08:00
Massimiliano Culpo
30a9e6462f bugfix: work around issue handling packages not in any repo 2021-02-17 17:07:24 -08:00
Todd Gamblin
0e725f0ab1 concretizer: refactor handling of special variants dev_build and patches
Other parts of the concretizer code build up lists of things we can't
know without traversing all specs and packages, and they output these
list at the very end.

The code for this for variant values from spec literals was intertwined
with the code for traversing the input specs. This only covers the input
specs and misses variant values that might come from directives in
packages.

- [x] move ad-hoc value handling code into spec_clauses so we do it in
  one place for CLI and packages

- [x] move handling of `variant_possible_value`, etc. into
  `concretize.lp`, where we can automatically infer variant existence
  more concisely.

- [x] simplify/clarify some of the code for variants in `spec_clauses()`
2021-02-17 17:07:23 -08:00
Massimiliano Culpo
ecfba13d89 concretizer: each external version is allowed by definition (#20247)
Registering external versions among the lists of allowed ones
generates the correct rules for `version_satisfies`
2021-02-17 17:07:22 -08:00
Massimiliano Culpo
a6d433b937 concretizer: restrict maximizing variant values to MV variants (#20194) 2021-02-17 17:07:22 -08:00
Matthias Wolf
b4f79f3cb7 environment installs: fix reporting. (#20004)
PR #15702 changed the invocation of the report context when installing
specs, do the same when building environments.
2021-02-17 17:07:22 -08:00
Greg Becker
30290acf67 avoid circular import (#20236) 2021-02-17 17:07:21 -08:00
Andrew W Elble
92de484228 concretizer: call inject_patches_variants() on the roots of the specs (#20203)
As was done in the old concretizer. Fixes an issue where conditionally
patched dependencies did not show up in spec (gdal+jasper)
2021-02-17 17:07:21 -08:00
Massimiliano Culpo
b78cc5b43d concretizer: try hard to infer the real version of compilers (#20099)
fixes #20055

Compiler with custom versions like gcc@foo are not currently
matched to the appropriate targets. This is because the
version of spec doesn't match the "real" version of the
compiler.

This PR replicates the strategy used in the original
concretizer to deal with that and tries to detect the real
version of compilers if the version in the spec returns no
results.
2021-02-17 17:07:21 -08:00
Harmen Stoppels
571e36787b Fix hipcc once more (#20095) 2021-02-17 17:07:20 -08:00
Andrew W Elble
598c25b434 concretizer: don't optimize emitting version_satisfies() (#20128)
When all versions were allowed a version_satisfies rule was not emitted,
and this caused conditional directives to fail.
2021-02-17 17:07:19 -08:00
Massimiliano Culpo
0b7a22dea2 spec: return early from concretization if a spec is already concrete (#20196) 2021-02-17 17:07:18 -08:00
Massimiliano Culpo
1e1a6f4e30 concretizer: remove ad-hoc rule for external packages (#20193)
fixes #20040

Matching compilers among nodes has been prioritized
in #20020. Selection of default variants has been
tuned in #20182. With this setup there is no need
to have an ad-hoc rule for external packages. On
the contrary it should be removed to prefer having
default variant values over more external nodes in
the DAG.
2021-02-17 17:07:18 -08:00
Massimiliano Culpo
22d7937c50 concretizer: swap priority of selecting provider and default variant (#20182)
refers #20040

Before this PR optimization rules would have selected default
providers at a higher priority than default variants. Here we
swap this priority and we consider variants that are forced by
any means (root spec or spec in depends_on clause) the same as
if they were with a default value.

This prevents the solver from avoiding expected configurations
just because they contain directives like:

depends_on('pkg+foo')

and `+foo` is not the default variant value for pkg.
2021-02-17 17:07:18 -08:00
George Hartzell
96283867d6 Typos: add missing closing parens (#20174) 2021-02-17 17:07:17 -08:00
Massimiliano Culpo
d7ffdd76f6 concretizer: treat target ranges in directives correctly (#19988)
fixes #19981

This commit adds support for target ranges in directives,
for instance:

conflicts('+foo', when='target=x86_64:,aarch64:')

If any target in a spec body is not a known target the
following clause will be emitted:

node_target_satisfies(Package, TargetConstraint)

when traversing the spec and a definition of
the clause will then be printed at the end similarly
to what is done for package and compiler versions.
2021-02-17 17:07:17 -08:00
Massimiliano Culpo
b326d59e10 concretizer: prioritize matching compilers over newer versions (#20020)
fixes #20019

Before this modification having a newer version of a node came
at higher priority in the optimization than having matching
compilers. This could result in unexpected configurations for
packages with conflict directives on compilers of the type:

conflicts('%gcc@X.Y:', when='@:A.B')

where changing the compiler for just that node is preferred to
lower the node version to less than 'A.B'. Now the priority has
been switched so the solver will try to lower the version of the
nodes in question before changing their compiler.
2021-02-17 17:07:16 -08:00
Massimiliano Culpo
0ae49821e2 concretizer: allow a bool to be passed as argument for tests dependencies (#20082)
refers #20079

Added docstrings to 'concretize' and 'concretized' to
document the format for tests.

Added tests for the activation of test dependencies.
2021-02-17 17:07:16 -08:00
Massimiliano Culpo
8e1b5f734f concretizer: treat conditional providers correctly (#20086)
refers #20040

This modification emits rules like:

provides_virtual("netlib-lapack","blas") :- variant_value("netlib-lapack","external-blas","False").

for packages that provide virtual dependencies conditionally instead
of a fact that doesn't account for the condition.
2021-02-17 17:07:16 -08:00
Adam J. Stewart
ad84351c43 Docs: remove duplication in Command Reference (#20021) 2021-02-17 17:07:15 -08:00
Martin Aumüller
508534aad9 recognize macOS 11.1 as big sur (#20038)
Big Sur versions go 11.0, 11.0.1, 11.1 (vs. prior versions that
only used the minor component)

Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2021-02-17 17:07:15 -08:00
Greg Becker
38cf4f9fc2 fix error handling for spack test results command (#19987) 2021-02-17 17:07:14 -08:00
Danny Taller
c42ce439e4 hip support for umpire, chai, raja, camp (#19715)
* create HipPackage base class and do some refactoring

* comments and added conflict to raja for openmp with hip
2021-02-17 17:07:14 -08:00
Adam J. Stewart
d04f9a1ae3
apple-clang: add correct path to compiler wrappers (#21662)
Follow-up to #17110

### Before
```bash
CC=/Users/Adam/spack/lib/spack/env/clang/clang; export CC
SPACK_CC=/usr/bin/clang; export SPACK_CC
PATH=...:/Users/Adam/spack/lib/spack/env/apple-clang:/Users/Adam/spack/lib/spack/env/case-insensitive:/Users/Adam/spack/lib/spack/env:...; export PATH
```

### After
```bash
CC=/Users/Adam/spack/lib/spack/env/clang/clang; export CC
SPACK_CC=/usr/bin/clang; export SPACK_CC
PATH=...:/Users/Adam/spack/lib/spack/env/clang:/Users/Adam/spack/lib/spack/env/case-insensitive:/Users/Adam/spack/lib/spack/env:...; export PATH
```

`CC` and `SPACK_CC` were being set correctly, but `PATH` was using the name of the compiler `apple-clang` instead of `clang`. For most packages, since `CC` was set correctly, nothing broke. But for packages using `Makefiles` that set `CC` based on `which clang`, it was using the system compilers instead of the compiler wrappers. Discovered when working on `py-xgboost@0.90`.

An alternative fix would be to copy the symlinks in `env/clang` to `env/apple-clang`. Let me know if you think there's a better way to do this, or to test this.
2021-02-17 15:54:50 -08:00
Massimiliano Culpo
ee1b0b9fb9
Delete unused "mutable_mock_store" fixture (#21632)
The fixture was introduced in #19690 maybe accidentally.

It's not used in unit tests, and though it should be
mutable it seems an exact copy of it's immutable version.
2021-02-16 17:26:16 -08:00
Scott Wittenburg
5b0507cc65
Pipelines: Temporary buildcache storage (#21474)
Before this change, in pipeline environments where runners do not have access
to persistent shared file-system storage, the only way to pass buildcaches to
dependents in later stages was by using the "enable-artifacts-buildcache" flag
in the gitlab-ci section of the spack.yaml.  This change supports a second
mechanism, named "temporary-storage-url-prefix", which can be provided instead
of the "enable-artifacts-buildcache" feature, but the two cannot be used at the
same time.  If this prefix is provided (only "file://" and "s3://" urls are
supported), the gitlab "CI_PIPELINE_ID" will be appended to it to create a url
for a mirror where pipeline jobs will write buildcache entries for use by jobs
in subsequent stages.  If this prefix is provided, a cleanup job will be
generated to run after all the rebuild jobs have finished that will delete the
contents of the temporary mirror.  To support this behavior a new mirror
sub-command has been added: "spack mirror destroy" which can take either a
mirror name or url.

This change also fixes a bug in generation of "needs" list for each job.  Each
jobs "needs" list is supposed to only contain direct dependencies for scheduling
purposes, unless "enable-artifacts-buildcache" is specified.  Only in that case
are the needs lists supposed to contain all transitive dependencies.  This
changes fixes a bug that caused the needs lists to always contain all transitive
dependencies, regardless of whether or not "enable-artifacts-buildcache" was
specified.
2021-02-16 18:21:18 -07:00
Sergey Kosukhin
7538444a03
NAG compiler: disable forcing RPATH/RUNPATH (#21701) 2021-02-16 18:31:51 +01:00
Scott Wittenburg
428f831899
Pipelines: DAG Pruning (#20435)
Pipelines: DAG pruning

During the pipeline generation staging process we check each spec against all configured mirrors to determine whether it is up to date on any of the mirrors.  By default, and with the --prune-dag argument to "spack ci generate", any spec already up to date on at least one remote mirror is omitted from the generated pipeline.  To generate jobs for up to date specs instead of omitting them, use the --no-prune-dag argument.  To speed up the pipeline generation process, pass the --check-index-only argument.  This will cause spack to check only remote buildcache indices and avoid directly fetching any spec.yaml files from mirrors.  The drawback is that if the remote buildcache index is out of date, spec rebuild jobs may be scheduled unnecessarily.

This change removes the final-stage-rebuild-index block from gitlab-ci section of spack.yaml.  Now rebuilding the buildcache index of the mirror specified in the spack.yaml is the default, unless "rebuild-index: False" is set.  Spack assigns the generated rebuild-index job runner attributes from an optional new "service-job-attributes" block, which is also used as the source of runner attributes for another generated non-build job, a no-op job, which spack generates to avoid gitlab errors when DAG pruning results in empty pipelines.
2021-02-16 09:12:37 -07:00
Tamara Dahlgren
851490bd54
Correct the reference to the staged examples files (#21557) 2021-02-13 08:14:38 -08:00
Chuck Atkins
5a771bc8ad
Introduce a SPACK_PYTHON environment variable (#21222)
The SPACK_PYTHON environment variable can be set to a python interpreter to be
used by the spack command.  This allows the spack command itself to use a
consistent and separate interpreter from whatever python might be used for package
building.
2021-02-12 10:52:44 -08:00
Massimiliano Culpo
113073ceed
unit test: refactored bindist.py (#21497)
Modifications:
- Make use of SpackCommand objects wherever possible
- Deduplicated code when possible
- Moved cleaning of mirrors to fixtures
- Ensure mock configuration has a clear initialization order
2021-02-11 10:29:56 -08:00
Todd Gamblin
3b3314802e database: don't create a date object in query() unless it's necessary
`query()` calls `datetime.datetime.fromtimestamp` regardless of whether a
date query is being done. Guard this with an if statement to avoid the
unnecessary work.
2021-02-11 15:30:57 +01:00
Todd Gamblin
c81ca37dfc version: precompile regexes in Version constructor 2021-02-11 15:30:57 +01:00
Todd Gamblin
e3e913ef8f spack_json: _strify should be a no-op in Python 3
_strify traverses *all* of the read-in data and converts strings, but
only for Python 2.  Ignore it in Python 3.
2021-02-11 15:30:57 +01:00
Todd Gamblin
52508e6ee7 database: do not redundantly mark specs concrete
Speed up reads by not traversing each spec recursively when marking them
concrete.
2021-02-11 15:30:57 +01:00
Todd Gamblin
6fe931ccb1 spec performance: don't parse in from_node_dict
Constructing a spec from a name instead of setting name directly forces
from_node_dict to call Spec.parse(), which is slow. Avoid this by using a
zero-arg constructor and setting name directly.
2021-02-11 15:30:57 +01:00
Massimiliano Culpo
4558dc06e2 Added a context manager to swap architectures
This solves a few FIXMEs in conftest.py, where
we were manipulating globals and seeing side
effects prior to registering fixtures.

This commit solves the FIXMEs, but introduces
a performance regression on tests that may need
to be investigated
2021-02-10 16:50:09 -08:00
Massimiliano Culpo
553d37a6d6 Move context manager to swap the current configuration into spack.config
The context manager can be used to swap the current
configuration temporarily, for any use case that may need it.
2021-02-10 16:50:09 -08:00
Massimiliano Culpo
cb2c233a97 Move context manager to swap the current store into spack.store
The context manager can be used to swap the current
store temporarily, for any use case that may need it.
2021-02-10 16:50:09 -08:00
Massimiliano Culpo
1a8963b0f4 repo: generalize "swap" context manager to also accept paths
The method is now called "use_repositories" and
makes it clear in the docstring that it accepts
as arguments either Repo objects or paths.

Since there was some duplication between this
contextmanager and "use_repo" in the testing framework,
remove the latter and use spack.repo.use_repositories
across the entire code base.

Make a few adjustment to MockPackageMultiRepo, since it was
stating in the docstring that it was supposed to mock
spack.repo.Repo and was instead mocking spack.repo.RepoPath.
2021-02-10 16:50:09 -08:00
Scott McMillan
0007ed72c3
Fix: Add a space between -isystem and the directory (#21599)
Some compilers, such as the NV compilers, do not recognize -isystem
dir when specified without a space.

Works: -isystem ../include
Does not work: -isystem../include

This PR updates the compiler wrapper to include the space with -isystem.
2021-02-10 15:56:42 -08:00
Greg Becker
2b6f896ca7
Bugfix: environments/views on separate mounts (#20720)
Environment views fail when the tmpdir used for view generation is
on a separate mount from the install_tree because the files cannot
by symlinked between the two. The fix is to use an alternative
tmpdir located alongside the view.
2021-02-10 13:39:11 -08:00
Adam J. Stewart
7ccb9992a6
Procedure to deprecate old versions of software (#20767)
* Procedure to deprecate old versions of software

* Add documentation

* Fix bug in logic

* Update tab completion

* Deprecate legacy packages

* Deprecate old mxnet as well

* More explicit docs
2021-02-09 13:51:18 -05:00
BenWeber42
e5ab686d77
Changed stages permissions to 750 (#21425) 2021-02-09 10:12:43 -08:00
BenWeber42
e4d74825f3
Fixed uninstall rm parent folder race condition (#21424) 2021-02-09 10:05:06 -08:00
Mark Meredith
784b421eda
Fix typo (#21567) 2021-02-09 15:34:42 +00:00
Adam J. Stewart
48954a5a3e
Restore verbosity of patching (#21233) 2021-02-08 10:29:19 -08:00
albestro
02b64c8903
let intel consider cray-mpich as mpich (#21512) 2021-02-05 17:55:39 +00:00
Adam J. Stewart
ba70f90ee0
Fix usage of PythonPackage.test outside of PythonPackage (#20555) 2021-02-04 11:00:37 -06:00
Adam J. Stewart
df5992293a
Python: add maintainer(s) (#21125)
* Python: add maintainer(s)

* Fix unit tests
2021-02-04 10:00:21 -06:00
Massimiliano Culpo
694d633a2c
spack external find: allow to search by tags (#21407)
This commit adds an option to the `external find`
command that allows it to search by tags. In this
way group of executables with common purposes can
be grouped under a single name and a simple command
can be used to detect all of them.

As an example introduce the 'build-tools' tag to
search for common development tools on a system
2021-02-04 13:17:32 +01:00
Massimiliano Culpo
ba42c36f00
concretizer: simplify "fact" method (#21148)
The "fact" method before was dealing with multiple facts
registered per call, which was used when we were emitting
grounded rules from knowledge of the problem instance.

Now that the encoding is changed we can simplify the method
to deal only with a single fact per call.
2021-02-03 10:12:03 -08:00
Greg Becker
7dcf3f7aed
add intel oneapi to compiler/pkg translations (#21448) 2021-02-02 19:11:51 +00:00
Adam J. Stewart
b597cbe1c0
PythonPackage: fewer phases (#20738) 2021-02-01 12:48:45 -06:00
Adam J. Stewart
1d636bed6a
R: add maintainer(s) (#21119)
* R: add maintainer(s)

* Add maintainer to base class
2021-02-01 11:33:33 -06:00
Adam J. Stewart
40a40e0265
Python 3.10 support: collections.abc (#20441) 2021-02-01 11:30:25 -06:00
Yang Zongze
f8124369f9
Print groups properly for spack find -d (#20028) 2021-01-29 11:05:36 -08:00
Adam J. Stewart
eeddaaea52
Make git fetching even quieter (for git v1.7.2+)(#21013) 2021-01-28 20:41:05 +01:00
Sergey Kosukhin
4d7a9df810
Add a context wrapper for mtime preservation (#21258)
Sometimes we need to patch a file that is a dependency for some other
automatically generated file that comes in a release tarball. As a
result, make tries to regenerate the dependent file using additional
tools (e.g. help2man), which would not be needed otherwise.

In some cases, it's preferable to avoid that (e.g. see #21255). A way
to do that is to save the modification timestamps before patching and
restoring them afterwards. This PR introduces a context wrapper that
does that.
2021-01-27 11:41:07 -08:00
Mark C. Miller
f766585882
Doc default behavior of install tests (#21309)
Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>
2021-01-27 09:08:27 -08:00
Adam J. Stewart
aa8e026242
spack setup: remove the command for v0.17.0 (#20277)
spack setup was deprecated in 0.16 and will be removed in 0.17

Follow-up to #18240
2021-01-27 09:24:09 +01:00
Tom Scogland
12eb4a146f
use module and package flags to get more correct mypy behavior (#21225)
The first of my two upstream patches to mypy landed in the 0.800 tag that was released this morning, which lets us use module and package parameters with a .mypy.ini file that has a files key. This uses those parameters to check all of spack in style, but leaves the packages out for now since they are still very, very broken. If no package has been modified, the packages are not checked, but if one has they are. Includes some fixes for the log tests since they were not type checking.

Should also fix all failures related to "duplicate module named package" errors.

Hopefully the next drop of mypy will include my other patch so we can just specify the modules and packages in the config file to begin with, but for now we'll have to live with a bare mypy doing a check of the libs but not the packages.

* use module and package flags to check packages properly
* stop checking package files, use package flag for libs

The packages are not type checkable yet, need to finish out another PR
before they can be.  The previous commit also didn't check the libraries
properly, this one does.
2021-01-22 16:24:15 -08:00
AMD Toolchain Support
2c1bb64594
Added @property stdcxx_libs to return -lstdc++ for AOCC compiler (#21145) 2021-01-22 09:58:04 -06:00
Tamara Dahlgren
6b13909cc1
docs: Update the CudaPackage (build system) description (#20742)
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
2021-01-21 12:43:21 -08:00
Tamara Dahlgren
25bab31bc8
Added ROCmPackage (build system) documentation (#20743) 2021-01-21 10:46:39 -08:00
eugeneswalker
7f86cc87b0
store sbang_install_path in buildinfo, use for subsequent relocation (#20768) 2021-01-20 12:43:07 -08:00
Nathan Hanford
ebc871abbf
[WIP] relocate.py: parallelize test replacement logic (#19690)
* sbang pushed back to callers;
star moved to util.lang

* updated unit test

* sbang test moved; local tests pass

Co-authored-by: Nathan Hanford <hanford1@llnl.gov>
2021-01-20 09:17:47 -08:00
Robert Cohn
09ee3f8d8e
add required libs for sycl programs (#20728) 2021-01-18 23:15:24 -06:00
Danny Taller
74b2c85b41
improve documentation for Rocm (hip amd builds) (#20812)
* improve documentation
2021-01-14 08:54:58 -08:00
Massimiliano Culpo
0bd76ac9e6 concretizer: require at least a dependency type to say the dependency holds
fixes #20784

Similarly to the previous bug, here we were deducing
conditions to be imposed on nodes that were not part
of the DAG.
2021-01-12 22:23:39 -08:00
Massimiliano Culpo
ed8fe68cf2 concretizer: dependency conditions cannot hold if package is external
fixes #20736

Before this one line fix we were erroneously deducing
that dependency conditions hold even if a package
was external.

This may result in answer sets that contain imposed
conditions on a node without the node being present
in the DAG, hence #20736.
2021-01-12 22:23:39 -08:00
Robert Underwood
823ab32c10
restore ability of dev-build to skip patches (#20351)
At some point in the past, the skip_patch argument was removed
from the call to package.do_install() this broke the --skip-patch
flag on the dev-build command.
2021-01-12 14:32:04 -06:00
Adam J. Stewart
881bdd5b9e
Package Repositories docs: num packages has grown (#20735) 2021-01-11 11:00:14 +01:00
Tamara Dahlgren
31f26daf10
Update the docs footer copyright (#20741) 2021-01-11 08:00:08 +01:00
eugeneswalker
6157854de6
fix gpg user rundir check (#20705) 2021-01-06 12:29:00 -08:00
Massimiliano Culpo
0111a18b23 concretizer: make rules on virtual packages more linear
fixes #20679

In this refactor we have a single cardinality rule on the
provider, which triggers a rule transforming a dependency
on a virtual package into a dependency on the provider of
the virtual.
2021-01-05 16:59:15 -08:00
Vanessasaurus
67ce1939a3
spack python: allow use of IPython (#20329)
This adds a -i option to "spack python" which allows use of the
IPython interpreter; it can be used with "spack python -i ipython".
This assumes it is available in the Python instance used to run
Spack (i.e. that you can "import IPython").
2021-01-05 16:54:47 -08:00
Greg Becker
61c1b71d38
bugfix for target adjustments on target ranges (#20537) 2021-01-05 12:27:13 -08:00
Todd Gamblin
5ac05db917
concretizer: use consistent naming for compiler predicates (#20677)
Every other predicate in the concretizer uses a `_set` suffix to
implement user- or package-supplied settings, but compiler settings use a
`_hard` suffix for this. There's no difference in how they're used, so
make the names the same.

- [x] change `node_compiler_hard` to `node_compiler_set`
- [x] change `node_compiler_version_hard` to `node_compiler_version_set`
2021-01-05 08:41:01 +01:00
Todd Gamblin
9c941bb706 concretizer: simplify handling of virtual version constraints
Previously, the concretizer handled version constraints by comparing all
pairs of constraints and ensuring they satisfied each other. This led to
INCONSISTENT ressults from clingo, due to ambiguous semantics like:

    version_constraint_satisfies("mpi", ":1", ":3")
    version_constraint_satisfies("mpi", ":3", ":1")

To get around this, we introduce possible (fake) versions for virtuals,
based on their constraints. Essentially, we add any Versions,
VersionRange endpoints, and all such Versions and endpoints from
VersionLists to the constraint. Virtuals will have one of these synthetic
versions "picked" by the solver. This also allows us to remove a special
case from handling of `version_satisfies/3` -- virtuals now work just
like regular packages.
2021-01-04 14:51:10 -08:00
Todd Gamblin
a1ed71f7e4 concretizer: remove rule generation code from concretizer
Our program only generates facts now, so remove all unused code related
to generating cardinality constraints and rules.
2021-01-04 14:51:10 -08:00
Todd Gamblin
0ce08640e0 concretizer: convert virtuals to facts; move all rules to concretize.lp
This converts the virtual handling in the new concretizer from
already-ground rules to facts. This is the last thing that needs to be
refactored, and it converts the entire concretizer to just use facts.

The previous way of handling virtuals hinged on rules involving
`single_provider_for` facts that were tied to the virtual and a version
range. The new method uses the condition pattern we've been using for
dependencies, externals, and conflicts.

To handle virtuals as conditions, we impose constraints on "fake" virtual
specs in the logic program. i.e., `version_satisfies("mpi", "2.0:",
"2.0")` is legal whereas before we wouldn't have seen something like
this. Currently, constriants are only handled on versions -- we don't
handle variants or anything else yet, but they key change here is that we
*could*. For a long time, virtual handling in Spack has only dealt with
versions, and we'd like to be able to handle variants as well. We could
easily add an integrity constraint to handle variants like the one we use
for versions.

One issue with the implementation here is that virtual packages don't
actually declare possible versions like regular packages do. To get
around that, we implement an integrity constraint like this:

    :- virtual_node(Virtual),
       version_satisfies(Virtual, V1), version_satisfies(Virtual, V2),
       not version_constraint_satisfies(Virtual, V1, V2).

This requires us to compare every version constraint to every other, both
in program generation and within the concretizer -- so there's a
potentially quadratic evaluation time on virtual constraints because we
don't have a real version to "anchor" things to. We just say that all the
constraints need to agree for the virtual constraint to hold.

We can investigate adding synthetic versions for virtuals in the future,
to speed this up.
2021-01-04 14:51:10 -08:00
Todd Gamblin
49ac3471cf concretizer: consolidate handling of virtuals into spec_clauses 2021-01-04 14:51:10 -08:00
Todd Gamblin
fa411e7c07 concretizer: make _condtion_id_counter an iterator 2021-01-04 14:51:10 -08:00
Todd Gamblin
3cc89726ee concretizer: more detailed section headers in concretize.lp 2021-01-04 14:51:10 -08:00
Massimiliano Culpo
cfd0ff52d1
ci: fix issue with latest sphinx (#20661) 2021-01-04 22:10:49 +01:00
Todd Gamblin
16ce207481
bugfix: infinite loop when building a set from incomplete specs (#20649)
This code in `SpecBuilder.build_specs()` introduced in #20203, can loop
seemingly interminably for very large specs:

```python
set([spec.root for spec in self._specs.values()])
```

It's deceptive, because it seems like there must be an issue with
`spec.root`, but that works fine. It's building the set afterwards that
takes forever, at least on `r-rminer`. Currently if you try running
`spack solve r-rminer`, it loops infinitely and spins up your fan.

The issue (I think) is that the spec is not yet complete when this is
run, and something is going wrong when constructing and comparing so many
values produced by `_cmp_key()`. We can investigate the efficiency of
`_cmp_key()` separately, but for now, the fix is:

```python
roots = [spec.root for spec in self._specs.values()]
roots = dict((id(r), r) for r in roots)
```

We know the specs in `self._specs` are distinct (they just came out of
the solver), so we can just use their `id()` to unique them here. This
gets rid of the infinite loop.
2021-01-04 10:28:16 +01:00
Todd Gamblin
a8ccb8e116 copyrights: update all files with license headers for 2021
- [x] add `concretize.lp`, `spack.yaml`, etc. to licensed files
- [x] update all licensed files to say 2013-2021 using
      `spack license update-copyright-year`
- [x] appease mypy with some additions to package.py that needed
      for oneapi.py
2021-01-02 12:12:00 -08:00
Todd Gamblin
78f39bdfee commands: add spack license update-copyright-year
This adds a new subcommand to `spack license` that automatically updates
the copyright year in files that should have a license header.

- [x] add `spack license update-copyright-year` command
- [x] add test
2021-01-02 12:12:00 -08:00
Adam J. Stewart
0d95fd6d52
extends: add type kwarg (#20045)
* extends: add type kwarg

* Flake8 fix
2020-12-30 11:09:58 -06:00
Massimiliano Culpo
eca1dd8738 concretizer: generate facts for externals
Generate only facts for external specs. Substitute the
use of already grounded rules with non-grounded rules
in concretize.lp
2020-12-29 23:51:20 -08:00
Adam J. Stewart
05f8e08067
PythonPackage: add pypi attribute to infer homepage/url/list_url (#17587) 2020-12-29 09:03:08 +01:00
Massimiliano Culpo
60f4621a73
archspec: fixed a typo in the vendored library (#20584) 2020-12-28 12:09:02 -06:00
Omri Mor
cfbe3aa056
Remove more variables from build environment (#20156)
GCC looks for included files based on several env vars.
Remove C_INCLUDE_PATH, CPLUS_INCLUDE_PATH, and OBJC_INCLUDE_PATH
from the build environment to ensure it's clean and prevent
accidental clobbering.
2020-12-24 16:48:53 -06:00
Greg Becker
6947951aaf
bugfix: do not write empty default dicts/lists in envs (#20526)
Environment yaml files should not have default values written to them.

To accomplish this, we change the validator to not add the default values to yaml. We rely on the code to set defaults for all values (and use defaulting getters like dict.get(key, default)).

Includes regression test.
2020-12-23 20:29:38 -08:00
Massimiliano Culpo
91e86f9d0d concretizer: remove vestigial code and comment 2020-12-23 16:40:47 -08:00
Todd Gamblin
1571d6240b style: ensure that all packages pass spack style -a
- fix trailing whitespace and other issues uncovered by better flake8
  checking.

- fix extra whitespace printed by `spack style` command
2020-12-23 16:17:54 -08:00
Robert Cohn
0bb18d8a38
Add Intel oneAPI packages (#20411)
This creates a set of packages which all use the same script to install
components of Intel oneAPI. This includes:

* An inheritable IntelOneApiPackage which knows how to invoke the
  installation script based on which components are requested
* For components which include headers/libraries, an inheritable
  IntelOneApiLibraryPackage is provided to locate them
* Individual packages for DAL, DNN, TBB, etc.
* A package for the Intel oneAPI compilers (icx/ifx). This also includes
  icc/ifortran but these are not currently detected in this PR
2020-12-23 15:39:40 -08:00
Tom Scogland
857749a9ba
add mypy to style checks; rename spack flake8 to spack style (#20384)
I lost my mind a bit after getting the completion stuff working and
decided to get Mypy working for spack as well. This adds a 
`.mypy.ini` that checks all of the spack and llnl modules, though
not yet packages, and fixes all of the identified missing types and
type issues for the spack library.

In addition to these changes, this includes:

* rename `spack flake8` to `spack style`

Aliases flake8 to style, and just runs flake8 as before, but with
a warning.  The style command runs both `flake8` and `mypy`,
in sequence. Added --no-<tool> options to turn off one or the
other, they are on by default.  Fixed two issues caught by the tools.

* stub typing module for python2.x

We don't support typing in Spack for python 2.x. To allow 2.x to
support `import typing` and `from typing import ...` without a
try/except dance to support old versions, this adds a stub module
*just* for python 2.x.  Doing it this way means we can only reliably
use all type hints in python3.7+, and mypi.ini has been updated to
reflect that.

* add non-default black check to spack style

This is a first step to requiring black.  It doesn't enforce it by
default, but it will check it if requested.  Currently enforcing the
line length of 79 since that's what flake8 requires, but it's a bit odd
for a black formatted project to be quite that narrow.  All settings are
in the style command since spack has no pyproject.toml and I don't
want to add one until more discussion happens. Also re-format
`style.py` since it no longer passed the black style check
with the new length.

* use style check in github action

Update the style and docs action to use `spack style`, adding in mypy
and black to the action even if it isn't running black right now.
2020-12-22 21:39:10 -08:00
Todd Gamblin
5f2a821183
concretizer: refactor conditional rules to be less repetitious (#20507)
We have to repeat all the spec attributes in a number of places in
`concretize.lp`, and Spack has a fair number of spec attributes. If we
instead add some rules up front that establish equivalencies like this:

```
    node(Package) :- attr("node", Package).
    attr("node", Package) :- node(Package).

    version(Package, Version) :- attr("version", Package, Version).
    attr("version", Package, Version) :- version(Package, Version).
```

We can rewrite most of the repetitive conditions with `attr` and repeat
only for each arity (there are only 3 arities for spec attributes so far)
as opposed to each spec attribute. This makes the logic easier to read
and the rules easier to follow.

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2020-12-22 19:49:36 +01:00
Tom Scogland
c1e4f3e131
Refactor flake8 handling and tool compatibility (#20376)
This PR does three related things to try to improve developer tooling quality of life:

1. Adds new options to `.flake8` so it applies the rules of both `.flake8` and `.flake_package` based on paths in the repository.
2. Adds a re-factoring of the `spack flake8` logic into a flake8 plugin so using flake8 directly, or through editor or language server integration, only reports errors that `spack flake8` would.
3. Allows star import of `spack.pkgkit` in packages, since this is now the thing that needs to be imported for completion to work correctly in package files, it's nice to be able to do that.

I'm sorely tempted to sed over the whole repository and put `from spack.pkgkit import *` in every package, but at least being allowed to do it on a per-package basis helps.

As an example of what the result of this is:

```
~/Workspace/Projects/spack/spack develop* ⇣
❯ flake8 --format=pylint ./var/spack/repos/builtin/packages/kripke/package.py
./var/spack/repos/builtin/packages/kripke/package.py:6: [F403] 'from spack.pkgkit import *' used; unable to detect undefined names
./var/spack/repos/builtin/packages/kripke/package.py:25: [E501] line too long (88 > 79 characters)

~/Workspace/Projects/spack/spack refactor-flake8*
1 ❯ flake8 --format=spack ./var/spack/repos/builtin/packages/kripke/package.py

~/Workspace/Projects/spack/spack refactor-flake8*
❯ flake8 ./var/spack/repos/builtin/packages/kripke/package.py
```

* qa/flake8: update .flake8, spack formatter plugin

Adds:
* Modern flake8 settings for per-path/glob error ignores, allows
  packages to use the same `.flake8` as the rest of spack
* A spack formatter plugin to flake8 that implements the behavior of
  `spack flake8` for direct invocations.  Makes integration with
  developer tooling nicer, linting with flake8 reports only errors that
  `spack flake8` would report.  Using pyls and pyls-flake8, or any other
  non-format-dependent flake8 integration, now works with spack's rules.

* qa/flake8: allow star import of spack.pkgkit

To get working completion of directives and spack components it's
necessary to import the contents of spack.pkgkit.  At the moment doing
this makes flake8 displeased.  For now, allow spack.pkgkit and spack
both, next step is to ban spack * and require spack.pkgkit *.

* first cut at refactoring spack flake8

This version still copies all of the files to be checked as befire, and
some other things that probably aren't necessary, but it relies on the
spack formatter plugin to implement the ignore logic.

* keep flake8 from rejecting itself

* remove separate packages flake8 config

* fix failures from too many files

I ran into this in the PR converting pkgkit to std.  The solution in
that branch does not work in all cases as it turns out, and all the
workarounds I tried to use generated configs to get a single invocation
of flake8 with a filename optoion to work failed.  It's an astonishingly
frustrating config option.

Regardless, this removes all temporary file creation from the command
and relies on the plugin instead.  To work around the huge number of
files in spack and still allow the command to control what gets checked,
it scans files in batches of 100.  This is a completely arbitrary number
but was chosen to be safely under common line-length limits.  One
side-effect of this is that every 100 files the command will produce
output, rather than only at the end, which doesn't seem like a terrible
thing.
2020-12-22 09:28:46 -08:00
Massimiliano Culpo
cde6ffe369 concretizer: optimize loop on compiler version
Similar to the optimization on platform
2020-12-22 00:02:54 -08:00
Massimiliano Culpo
635c6c29fa concretizer: optimized loop on node platforms
We can speed-up the computation by avoiding a
double loop in a cardinality constraint and
enforcing the rule instead as an integrity
constraint.
2020-12-22 00:02:54 -08:00
Massimiliano Culpo
19fba3ae06 concretizer: fix failing unit tests 2020-12-20 07:00:46 -08:00
Massimiliano Culpo
72569a0198 concretizer: emit facts for integrity constraints 2020-12-20 07:00:46 -08:00
Massimiliano Culpo
e644255770 concretizer: emit facts for constraints on imposed dependencies 2020-12-20 07:00:46 -08:00
Massimiliano Culpo
d8dc4b141e concretizer: avoid redundant grounding on dependency types 2020-12-20 07:00:46 -08:00
Todd Gamblin
bb78a73ed3 concretizer: move conditional dependency logic into concretize.lp
Continuing to convert everything in `asp.py` into facts, make the
generation of ground rules for conditional dependencies use facts, and
move the semantics into `concretize.lp`.

This is probably the most complex logic in Spack, as dependencies can be
conditional on anything, and we need conditional ASP rules to accumulate
and map all the dependency conditions to spec attributes.

The logic looks complicated, but essentially it accumulates any
constraints associated with particular conditions into a fact associated
with the condition by id. Then, if *any* condition id's fact is True, we
trigger the dependency.

This simplifies the way `declared_dependency()` works -- the dependency
is now declared regardless of whether it is conditional, and the
conditions are handled by `dependency_condition()` facts.
2020-12-20 07:00:46 -08:00
Todd Gamblin
d7fe2d5678 concretizer: spec_clauses should traverse dependencies
There are currently no places where we do not want to traverse
dependencies in `spec_clauses()`, so simplify the logic by consolidating
`spec_traverse_clauses()` with `spec_clauses()`.
2020-12-20 07:00:46 -08:00
Todd Gamblin
87a9e1c951 concretizer: pull _develop_specs_from_env out of main setup loop 2020-12-20 07:00:46 -08:00
Todd Gamblin
950fb0948b concretizer: add #defined statements to avoid warnings.
`version_satisfies/2` and `node_compiler_version_satisfies/3` are
generated but need `#defined` directives to avoid " info: atom does not
occur in any rule head:" warnings.
2020-12-20 07:00:46 -08:00
Massimiliano Culpo
4901728c5b
asp: memoize the list of all target_specs to speed-up setup phase (#20473)
* asp: memoize the list of all target_specs to speed-up setup phase

* asp: memoize using a cache per solver object
2020-12-19 07:07:22 -08:00
Scott Wittenburg
594512bdb3
ci: fixes for compiler bootstrapping (#17563)
This PR addresses a number of issues related to compiler bootstrapping.

Specifically:
1. Collect compilers to be bootstrapped while queueing in installer
Compiler tasks currently have an incomplete list in their task.dependents,
making those packages fail to install as they think they have not all their
dependencies installed. This PR collects the dependents and sets them on
compiler tasks.

2. allow boostrapped compilers to back off target
Bootstrapped compilers may be built with a compiler that doesn't support
the target used by the rest of the spec.  Allow them to build with less
aggressive target optimization settings.

3. Support for target ranges
Backing off the target necessitates computing target ranges, so make Spack
handle those properly.  Notably, this adds an intersection method for target
ranges and fixes the way ranges are satisfied and constrained on Spec objects.

This PR also:
- adds testing
- improves concretizer handling of target ranges

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
Co-authored-by: Gregory Becker <becker33@llnl.gov>
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2020-12-18 02:05:06 -08:00
psakievich
093a247b25
View location resolve environment variables (#20420) 2020-12-17 10:25:08 -08:00
Tamara Dahlgren
b7d9e269ef
docs: add single node concurrent build example (#20416) 2020-12-17 17:23:55 +01:00
Massimiliano Culpo
76f1548fe2
unit-tests: ensure that installed packages can be reused (#20307)
refers #20292

Added a unit test that ensures we can reuse installed
packages even if in the repository variants have been
removed or added.
2020-12-17 00:31:59 -08:00
Adam J. Stewart
826cd07cf7
PythonPackage: add import module smoke tests (#20023) 2020-12-16 15:15:03 -08:00
Greg Becker
3840c0ac45
docs: fix spack install debug arg order (#20428) 2020-12-16 13:57:08 -08:00
Adam J. Stewart
20752db103
Docs: add more Command Reference links to spack test (#20413) 2020-12-16 12:08:32 -08:00
Tamara Dahlgren
cb01981628
docs: fix spack command for unit-test pytest help (#20415) 2020-12-16 10:13:22 -08:00
Greg Becker
352dc0624c
Fix comparisons for abstract specs (#20341)
bug only relevant for python3
2020-12-15 14:44:58 -08:00
Todd Gamblin
b6089ac691
concretizer: don't use one_of_iff for range constraints (#20383)
Currently, version range constraints, compiler version range constraints,
and target range constraints are implemented by generating ground rules
from `asp.py`, via `one_of_iff()`.  The rules look like this:

```
version_satisfies("python", "2.6:") :- 1 { version("python", "2.4"); ... } 1.
1 { version("python", "2.4"); ... } 1. :- version_satisfies("python", "2.6:").
```

So, `version_satisfies(Package, Constraint)` is true if and only if the
package is assigned a version that satisfies the constraint. We
precompute the set of known versions that satisfy the constraint, and
generate the rule in `SpackSolverSetup`.

We shouldn't need to generate already-ground rules for this. Rather, we
should leave it to the grounder to do the grounding, and generate facts
so that the constraint semantics can be defined in `concretize.lp`.

We can replace rules like the ones above with facts like this:

```
version_satisfies("python", "2.6:", "2.4")
```

And ground them in `concretize.lp` with rules like this:

```
1 { version(Package, Version) : version_satisfies(Package, Constraint, Version) } 1
  :- version_satisfies(Package, Constraint).
version_satisfies(Package, Constraint)
  :- version(Package, Version), version_satisfies(Package, Constraint, Version).
```

The top rule is the same as before. It makes conditional dependencies and
other places where version constraints are used work properly. Note that
we do not need the cardinality constraint for the second rule -- we
already have rules saying there can be only one version assigned to a
package, so we can just infer from `version/2` `version_satisfies/3`.
This form is also safe for grounding -- If we used the original form we'd
have unsafe variables like `Constraint` and `Package` -- the original
form only really worked when specified as ground to begin with.

- [x] use facts instead of generating rules for package version constraints
- [x] use facts instead of generating rules for compiler version constraints
- [x] use facts instead of generating rules for target range constraints
- [x] remove `one_of_iff()` and `iff()` as they're no longer needed
2020-12-15 11:58:58 -08:00
Tamara Dahlgren
21f30e3074
Bugfix/docs: correct and expand smoke test documentation (#20278) 2020-12-15 08:38:00 -08:00
Tamara Dahlgren
d67ca265a3
outputs: restore default output of fetch/build/total times (#20394) 2020-12-15 01:46:30 -08:00
Massimiliano Culpo
e7f4c2b49e
package sanity: ensure all variant defaults are allowed values (#20373) 2020-12-15 10:22:15 +01:00
Todd Gamblin
495e8cfb8e
concretizer: remove clingo command-line driver (#20362)
I was keeping the old `clingo` driver code around in case we had to run
using the command line tool instad of through the Python interface.

So far, the command line is faster than running through Python, but I'm
working on fixing that.  I found that if I do this:

```python
control = clingo.Control()
control.load("concretize.lp")
control.load("hdf5.lp")       # code from spack solve --show asp hdf5
control.load("display.lp")

control.ground([("base", [])])
control.solve(...)
```

It's just as fast as the command line tool. So we can always generate the
code and load it manually if we need to -- we don't need two drivers for
clingo. Given that the python interface is also the only way to get unsat
cores, I think we pretty much have to use it.

So, I'm removing the old command line driver and other unused code. We
can dig it up again from the history if it is needed.
2020-12-14 09:35:53 +01:00
Ben Cowan
cf37e9276d
Debugging support: fix compiler wrapper log on Mac OS (#20333)
This fixes a logging error observed on macOS 11.0.1 (Big Sur).
When performing a Spack install in debugging mode (e.g.
`spack -d install py-scipy`) Spack is supposed to write a log of
compiler wrapper command line invocations to the current working
directory.

Due to a regression error introduced by #18205, these files were
no-longer generated, and Spack was printing errors such as
"No such file or directory: None/." This is because the log file
directory gets set from `spack.main.spack_working_dir`, but that
variable is not set in the spawned process.

This PR ensures that the working directory (at the time of the
"spack install" invocation) is persisted to the subprocess.
2020-12-11 15:54:11 -08:00
Tamara Dahlgren
59628cd9e8
Tests: enable re-use of post-install tests in smoke tests (#20298) 2020-12-10 10:35:27 -08:00
Adam J. Stewart
3f5f80956e
Command Reference: add link to spack test docs (#20054) 2020-12-08 09:26:03 -08:00
Andrew W Elble
a90026fb89
concretizer: try hard to obtain all needed variant_possible_value()'s (#20102)
Track all the variant values mentioned when emitting constraints, validate them
and emit a fact that allows them as possible values.

This modification ensures that open-ended variants (variants accepting any string 
or any integer) are projected to the finite set of values that are relevant for this 
concretization.
2020-12-08 15:46:52 +01:00
Harmen Stoppels
50f8332d95
Compiler wrapper linting (#20249)
* Fix duplicate entries in case
* make sure the arg is not interpreted as two items in a list
* use -n over ! -z
2020-12-07 18:58:19 -08:00
Massimiliano Culpo
98c2627132 bugfix: work around issue handling packages not in any repo 2020-12-07 17:18:33 -08:00
Todd Gamblin
1343a815c0 concretizer: refactor handling of special variants dev_build and patches
Other parts of the concretizer code build up lists of things we can't
know without traversing all specs and packages, and they output these
list at the very end.

The code for this for variant values from spec literals was intertwined
with the code for traversing the input specs. This only covers the input
specs and misses variant values that might come from directives in
packages.

- [x] move ad-hoc value handling code into spec_clauses so we do it in
  one place for CLI and packages

- [x] move handling of `variant_possible_value`, etc. into
  `concretize.lp`, where we can automatically infer variant existence
  more concisely.

- [x] simplify/clarify some of the code for variants in `spec_clauses()`
2020-12-07 17:18:33 -08:00
vvolkl
ed258ca9e9
Add "spack versions --new" flag to only show new versions (#20030)
* [cmd versions] add spack versions --new flag to only fetch new versions

format

[cmd versions] rename --latest to --newest and add --remote-only

[cmd versions] add tests for --remote-only and --new

format

[cmd versions] update shell tab completion

[cmd versions] remove test for --remote-only --new which gives empty output

[cmd versions] final rename

format

* add brillig mock package

* add test for spack versions --new

* [brillig] format

* [versions] increase test coverage

* Update lib/spack/spack/cmd/versions.py

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>

* Update lib/spack/spack/cmd/versions.py

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2020-12-07 09:29:10 -06:00
Massimiliano Culpo
3843f43e69
concretizer: each external version is allowed by definition (#20247)
Registering external versions among the lists of allowed ones
generates the correct rules for `version_satisfies`
2020-12-06 10:29:05 +01:00
Harmen Stoppels
984ae7e695
Also allow --rpath as rpath linker flags (#18473) 2020-12-04 12:29:55 -05:00
Massimiliano Culpo
8b74b50cff
concretizer: restrict maximizing variant values to MV variants (#20194) 2020-12-04 16:27:03 +01:00
eugeneswalker
badf3368ad
allow install of build-deps from cache via --include-build-deps switch (#19955)
* allow install of build-deps from cache via --include-build-deps switch

* make clear that --include-build-deps is useful for CI pipeline troubleshooting
2020-12-03 15:27:01 -08:00
Matthias Wolf
794b60f7e7
environment installs: fix reporting. (#20004)
PR #15702 changed the invocation of the report context when installing
specs, do the same when building environments.
2020-12-03 15:04:13 -08:00
Greg Becker
d6765fe95d
avoid circular import (#20236) 2020-12-03 13:54:09 -08:00
Andrew W Elble
09aae616c7
concretizer: call inject_patches_variants() on the roots of the specs (#20203)
As was done in the old concretizer. Fixes an issue where conditionally
patched dependencies did not show up in spec (gdal+jasper)
2020-12-03 16:28:34 +01:00
Danny Taller
e22e037e30
Add CARE package, fixes for ROCmPackage and subclasses (#20070)
* use develop version of blt with fixes for rocm

* package updates for care+rocm

* fixes for plain cpu build

* add camp dependency on raja
2020-12-02 17:07:56 -08:00
Massimiliano Culpo
05848c87c5
concretizer: try hard to infer the real version of compilers (#20099)
fixes #20055

Compiler with custom versions like gcc@foo are not currently
matched to the appropriate targets. This is because the
version of spec doesn't match the "real" version of the
compiler.

This PR replicates the strategy used in the original
concretizer to deal with that and tries to detect the real
version of compilers if the version in the spec returns no
results.
2020-12-02 20:30:28 +01:00
Harmen Stoppels
b0baf42988
Fix hipcc once more (#20095) 2020-12-02 15:58:58 +01:00
Andrew W Elble
0c326e87a9
concretizer: don't optimize emitting version_satisfies() (#20128)
When all versions were allowed a version_satisfies rule was not emitted,
and this caused conditional directives to fail.
2020-12-02 09:53:53 +01:00
Massimiliano Culpo
7c01ba8fea
spec: return early from concretization if a spec is already concrete (#20196) 2020-12-01 18:09:14 +01:00
AMD Toolchain Support
ec1eddb6e7
AOCC-2.3.0 is now added to spack (#20089)
* AOCC-2.3.0 is now added to spack

Change-Id: I18fd9606e6fd9a288cc7dc6c6ead11ea17839a7c

* Added flag and version tests for AOCC-2.3.0

* Addressed review comments

Co-authored-by: vkallesh <Vijay-teekinavar.Kallesh@amd.com>
2020-12-01 08:07:58 -06:00
Massimiliano Culpo
e2033566bf
concretizer: remove ad-hoc rule for external packages (#20193)
fixes #20040

Matching compilers among nodes has been prioritized
in #20020. Selection of default variants has been
tuned in #20182. With this setup there is no need
to have an ad-hoc rule for external packages. On
the contrary it should be removed to prefer having
default variant values over more external nodes in
the DAG.
2020-12-01 10:11:40 +01:00
Massimiliano Culpo
7fd777c3d9
concretizer: swap priority of selecting provider and default variant (#20182)
refers #20040

Before this PR optimization rules would have selected default
providers at a higher priority than default variants. Here we
swap this priority and we consider variants that are forced by
any means (root spec or spec in depends_on clause) the same as
if they were with a default value.

This prevents the solver from avoiding expected configurations
just because they contain directives like:

depends_on('pkg+foo')

and `+foo` is not the default variant value for pkg.
2020-12-01 07:45:48 +01:00
George Hartzell
bb9f5d613c
Typos: add missing closing parens (#20174) 2020-11-30 10:28:07 -06:00
Adam J. Stewart
868dbb24c1
libQGLViewer: add new package (#20164) 2020-11-30 10:25:40 -05:00
Massimiliano Culpo
8dd3797d32
concretizer: treat target ranges in directives correctly (#19988)
fixes #19981

This commit adds support for target ranges in directives,
for instance:

conflicts('+foo', when='target=x86_64:,aarch64:')

If any target in a spec body is not a known target the
following clause will be emitted:

node_target_satisfies(Package, TargetConstraint)

when traversing the spec and a definition of
the clause will then be printed at the end similarly
to what is done for package and compiler versions.
2020-11-27 20:53:39 +01:00
Massimiliano Culpo
44665cb4e6
archspec: added support for aocc (#20124) 2020-11-26 16:18:40 +01:00
Massimiliano Culpo
03ff89fee6
concretizer: prioritize matching compilers over newer versions (#20020)
fixes #20019

Before this modification having a newer version of a node came
at higher priority in the optimization than having matching
compilers. This could result in unexpected configurations for
packages with conflict directives on compilers of the type:

conflicts('%gcc@X.Y:', when='@:A.B')

where changing the compiler for just that node is preferred to
lower the node version to less than 'A.B'. Now the priority has
been switched so the solver will try to lower the version of the
nodes in question before changing their compiler.
2020-11-26 13:10:48 +01:00
Massimiliano Culpo
8991cc4632
concretizer: allow a bool to be passed as argument for tests dependencies (#20082)
refers #20079

Added docstrings to 'concretize' and 'concretized' to
document the format for tests.

Added tests for the activation of test dependencies.
2020-11-26 08:55:17 +01:00
Massimiliano Culpo
983fb11dee
concretizer: treat conditional providers correctly (#20086)
refers #20040

This modification emits rules like:

provides_virtual("netlib-lapack","blas") :- variant_value("netlib-lapack","external-blas","False").

for packages that provide virtual dependencies conditionally instead
of a fact that doesn't account for the condition.
2020-11-25 22:03:42 +01:00
Harmen Stoppels
f40492b7d4
concretizer: remove debug statement (#20085) 2020-11-25 14:09:52 +01:00
Adam J. Stewart
fb2ac2077d
Docs: remove duplication in Command Reference (#20021) 2020-11-23 12:38:34 +01:00
Martin Aumüller
b490d65f28
recognize macOS 11.1 as big sur (#20038)
Big Sur versions go 11.0, 11.0.1, 11.1 (vs. prior versions that
only used the minor component)

Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2020-11-23 08:37:40 +01:00
Adam J. Stewart
14a9359395
spack debug report: print concretizer (#19983) 2020-11-19 11:12:28 +01:00
Tomoki, Karatsu
8f3594564c
fujitsu compiler: added / fixed support for compiler flags (#19967)
Added flags for:
- Debug symbols
- C++17 standard

Fixed the list of flags for generic optimizations
2020-11-19 11:09:34 +01:00
Michael Kuhn
1b7a5e53a6
clang/llvm: fix version detection (#19978)
This PR fixes two problems with clang/llvm's version detection. clang's
version output looks like this:

```
clang version 11.0.0
Target: x86_64-unknown-linux-gnu
```

This caused clang's version to be misdetected as:

```
clang@11.0.0
Target:
```

This resulted in errors when trying to actually use it as a compiler.

When using `spack external find`, we couldn't determine the compiler
version, resulting in errors like this:

```
==> Warning: "llvm@11.0.0+clang+lld+lldb" has been detected on the system but will not be added to packages.yaml [reason=c compiler not found for llvm@11.0.0+clang+lld+lldb]
```

Changing the regex to only match until the end of the line fixes these
problems.

Fixes: #19473
2020-11-19 11:06:45 +01:00
Greg Becker
10f784338b
fix error handling for spack test results command (#19987) 2020-11-18 16:16:34 -08:00
Danny Taller
3b9155239b
hip support for umpire, chai, raja, camp (#19715)
* create HipPackage base class and do some refactoring

* comments and added conflict to raja for openmp with hip
2020-11-18 11:52:21 -08:00
Todd Gamblin
82383093ee bump version number to 0.16.0 2020-11-18 04:22:09 -08:00
Michael Kuhn
20367e472d
cmd: add spack mark command (#16662)
This adds a new `mark` command that can be used to mark packages as either
explicitly or implicitly installed. Apart from fixing the package
database after installing a dependency manually, it can be used to
implement upgrade workflows as outlined in #13385.

The following commands demonstrate how the `mark` and `gc` commands can be
used to only keep the current version of a package installed:
```console
$ spack install pkgA
$ spack install pkgB
$ git pull # Imagine new versions for pkgA and/or pkgB are introduced
$ spack mark -i -a
$ spack install pkgA
$ spack install pkgB
$ spack gc
```

If there is no new version for a package, `install` will simply mark it as
explicitly installed and `gc` will not remove it.

Co-authored-by: Greg Becker <becker33@llnl.gov>
2020-11-18 03:20:56 -08:00
Greg Becker
77b2e578ec
spack test (#15702)
Users can add test() methods to their packages to run smoke tests on
installations with the new `spack test` command (the old `spack test` is
now `spack unit-test`). spack test is environment-aware, so you can
`spack install` an environment and then run `spack test run` to run smoke
tests on all of its packages. Historical test logs can be perused with
`spack test results`. Generic smoke tests for MPI implementations, C,
C++, and Fortran compilers as well as specific smoke tests for 18
packages.

Inside the test method, individual tests can be run separately (and
continue to run best-effort after a test failure) using the `run_test`
method. The `run_test` method encapsulates finding test executables,
running and checking return codes, checking output, and error handling.

This handles the following trickier aspects of testing with direct
support in Spack's package API:

- [x] Caching source or intermediate build files at build time for
      use at test time.
- [x] Test dependencies,
- [x] packages that require a compiler for testing (such as library only
      packages).

See the packaging guide for more details on using Spack testing support.
Included is support for package.py files for virtual packages. This does
not change the Spack interface, but is a major change in internals.

Co-authored-by: Tamara Dahlgren <dahlgren1@llnl.gov>
Co-authored-by: wspear <wjspear@gmail.com>
Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
2020-11-18 02:39:02 -08:00
Massimiliano Culpo
89181f253b Improve warning message for deprecated attributes in "packages.yaml"
The deprecatedProperties custom validator now can accept a function
to compute a better error message.

Improve error/warning message for deprecated properties
2020-11-17 17:34:27 -08:00
Peter Scheibel
c9ad2affcc
Documentation: spack load/environments prefix inspections (#19961)
As of #18260, `spack load` and `spack env activate` now use
`prefix_inspections` from the modules configuration to decide
how to modify environment variables.

This updates the modules configuration documentation to describe
how to update environment variables with the `prefix_inspections`
section. This also updates the `spack load` and environments
documentation to refer to the new `prefix_inspections` documentation.
2020-11-17 15:24:00 -08:00
Dr. Christian Tacke
d65f078f66
spack load/environments: allow customization of prefix inspections (#18260)
`spack load` and `spack env activate` now use the prefix inspections
defined in `modules.yaml`. This allows users to customize/override
environment variable modifications if desired.

If no `prefix_inspections` configuration is present, Spack uses the
values in the default configuration.
2020-11-17 14:04:13 -08:00
Massimiliano Culpo
5f636fc317
spack containerize: allow users to customize the base image (#15028)
This PR reworks a few attributes in the container subsection of
spack.yaml to permit the injection of custom base images when
generating containers with Spack. In more detail, users can still
specify the base operating system and Spack version they want to use:

  spack:
    container:
      images:
        os: ubuntu:18.04
        spack: develop

in which case the generated recipe will use one of the Spack images
built on Docker Hub for the build stage and the base OS image in the
final stage. Alternatively, they can specify explicitly the two
base images:

  spack:
    container:
      images:
        build: spack/ubuntu-bionic:latest
        final: ubuntu:18.04

and it will be up to them to ensure their consistency.

Additional changes:

* This commit adds documentation on the two approaches.
* Users can now specify OS packages to install (e.g. with apt or yum)
  prior to the build (previously this was only available for the
  finalized image).
* Handles to avoid an update of the available system packages have been
  added to the configuration to facilitate the generation of recipes
  permitting deterministic builds.
2020-11-17 11:25:13 -08:00
Massimiliano Culpo
7ffad278d3 concretizer: modified weights for providers and matching for externals
This commit address the case of concretizing a root spec with a
transitive conditional dependency on a virtual package, provided
by an external. Before these modifications default variant values
for the dependency bringing in the virtual package were not
respected, and the external package providing the virtual was added
to the DAG.

The issue stems from two facts:
- Selecting a provider has higher precedence than selecting default variants
- To ensure that an external is preferred, we used a negative weight

To solve it we shift all the providers weight so that:
- External providers have a weight of 0
- Non external provider have a weight of 10 or more

Using a weight of zero for external providers is such that having
an external provider, if present, or not having a provider at all
has the same effect on the higher priority minimization.

Also fixed a few minor bugs in concretize.lp, that were causing
spurious entries in the final answer set.

Cleaned concretize.lp from leftover rules.
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
ca31f52be3 concretizer: maximize the number of default values used for a single variant
If a the default of a multi-valued variant is set to
multiple values either in package.py or in packages.yaml
we need to ensure that all the values are present in the
concretized spec.

Since each default value has a weight of 0 and the
variant value is set implicitly by the concretizer
we need to add a rule to maximize on the number of
default values that are used.
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
9a03fd2834 concretizer: don't require a provider for virtual deps if spec is external
This commit introduces a new rule:

real_node(Package) :- not external(Package), node(Package).

that permits to distinguish between an external node and a
real node that shouldn't trim dependency. It solves the
case of concretizing ninja with an external Python.
2020-11-17 10:04:13 -08:00
Todd Gamblin
44aa94a210 concretizer: spec_clauses() shouldn't emit node_compiler_hard for rule bodies.
`node_compiler_hard()` means that something explicitly asked for a node's
compiler to be set -- i.e., it's not inherited, it's required. We're
generating this in spec_clauses even for specs in rule bodies, which
results in conditions like this for optional dependencies:

In py-torch/package.py:

    depends_on('llvm-openmp', when='%apple-clang +openmp')

In the generated ASP:

    declared_dependency("py-torch","llvm-openmp","build")
      :- node("py-torch"),
         variant_value("py-torch","openmp","True"),
         node_compiler("py-torch","apple-clang"),
         node_compiler_hard("py-torch","apple-clang"),
         node_compiler_version_satisfies("py-torch","apple-clang",":").

The `node_compiler_hard` there means we would have to *explicitly* set
py-torch's compiler to trigger the llvm-openmp dependency, rather than
just letting it be set by preferences. This is wrong; the dependency
should be there regardless of how the compiler was set.

- [x] remove fn.node_compiler_hard() call from spec_clauses when
      generating rule body clauses.
2020-11-17 10:04:13 -08:00
Todd Gamblin
0620d954f5 concretizer: don't generate rules for empty version lists
If the version list passed to one_of_iff is empty, it still generates a
rule like this:

    node_compiler_version_satisfies("fujitsu-mpi", "arm", ":") :- 1 {  } 1.
    1 {  } 1 :- node_compiler_version_satisfies("fujitsu-mpi", "arm", ":").

The cardinality rules on the right and left above are never
satisfiale, and these rules do nothing.

- [x] Skip generating any rules at all for empty version lists.
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
2231dfc898 concretizer: add a rule to avoid cycles in the graph of dependencies 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
522be6cadf External packages have a consistent hash across different concretizers 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
5c5a44988e Don't fail if MV variants have a tuple as default value 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
1b0338befb Fixup for target preferences 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
e0ae60edc4 Added unit tests to for regressions on open concretizer bugs 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
63327d1eea Changed clingo options 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
577676106c Reworked optimization rules 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
6baa8157c7 concretizer: set target preference for inheritance from root 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
ccb537479a install: one less concretization when installing from file 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
27bb970a97 Fixed branch after rebase (port to archspec)
TODO: Investigate the need to remove
memoization on Spec.patches (infinite
recursion when testing `__contains__`)
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
930b05fab4 Add unit tests for dependencies being patched by parent 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
e226523aeb concretizer: handle dependencies conditional on other dependencies 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
e7208b1598 tests: verify to handle dependencies conditional on other dependencies 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
d00e8394f8 concretizer: handle conflicts with compiler ranges correctly
As reported, conflicts with compiler ranges were not treated
correctly. This commit adds tests to verify the expected behavior
for the new concretizer.

The new rules to enforce a correct behavior involve:
- Adding a rule to prefer the compiler selected for
  the root package, if no other preference is set
- Give a strong negative weight to compiler preferences
  expressed in packages.yaml
- Maximize on compiler AND compiler version match
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
0a56b7cfd6 Github actions: add CI for ASP based solver 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
7753d58e7e Make all tests pass
Fixed a couple of tests and marked a few xfails
to solve them later.
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
8a855ddac5 concretizer: added handling for dev_path variant
This variant is currently either set from command line, in
which case it enters the concretization, or attached from
environment after concretization.
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
a0e8ad7a8b concretizer: ensure upfront that variants are valid 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
ae1ef85af5 concretizer: account for test dependencies only when required 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
346beedfd4 Fix installer.py unit tests that check output 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
87c87ff767 Compute the correct package name for hierarchies that change class names 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
116f6b30eb concretizer: handle variants defined through validators
Variant of this kind don't have a list of possible
values encoded in the ASP facts. Since all we have
is a validator the list of possible values just includes
just the default value and possibly the value passed
from packages.yaml or cli.
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
ada2fa36a9 concretizer: account for patches variant
This is done after the builder has actually built
the specs, to respect the semantics use with the
old concretizer.

Later we could move this to the solver as
a multivalued variant.
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
a1fe88c95b concretizer: ensure that no deprecated spec is being used
This is done after the builder has actually built
the specs, to respect the semantics use with the
old concretizer.

A better approach is to substitute the spec
directly in concretization.
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
58683b9e56 conftest: hook the new solver in the config fixture 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
3e4fd64169 concretizer: handle "none" value and '*' wildcard
The "none" variant value cannot be combined with
other values.

The '*' wildcard matches anything, including "none".
It's thus relevant in queries, but disregarded in
concretization.
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
8b055ac8d8 Fixed failing unit tests
- The test on concretization of anonymous dependencies
  has been fixed by raising the expected exception.
- The test on compiler bootstrap has been fixed by
  updating the version of GCC used in the test.
  Since gcc@2.0 does not support targets later than
  x86_64, the new concretizer was looking for a
  non-existing spec, i.e. it was correctly trying
  to retrieve 'gcc target=x86_64' instead of
  'gcc target=core2'.
- The test on gitlab CI needed an update of the target
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
c047495981 concretizer: virtual entry in packages.yaml, external modules
This commit adds support for specifying rules in
packages.yaml that refer to virtual packages.

The approach is to normalize in memory each
configuration and turn it into an equivalent
configuration without rules on virtual. This
is possible if the set of packages to be handled
is considered fixed.
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
4fe527cd3b concretizer: concretize a virtual root
Before this modification the root of a DAG has to be
a real package. This commit adds rules to concretize
virtual roots.
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
1b115e200b concretizer: handle version preferences from packages.yaml 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
9c23ed6484 concretizer: handle target preferences from packages.yaml
The weight of the target used in concretization is, in order:
1. A specific per package weight, if set in packages.yaml
2. Inherited from the parent, if possible
3. The default target weight (always set)
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
67344326c3 concretizer: fixed test on compiler preferences 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
d4b83daa48 concretizer: added logic for preferred variants
If preferred variants are present, they'll
set the default value of a variant. Otherwise
the default value is what is encoded
in package.py
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
81c7cf45e1 concretizer: refine compiler logic
Concrete versions for compilers are respected
verbatim.

Permit to use a non-existing compiler if the
appropriate configuration option has been
set.
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
c065245f14 Fixed failing unit tests
- Tests based on TestArchitecture
- Tests on non-buildable external
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
2ea8bd0b19 concretizer: prefer using the same compiler over using newer versions 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
28afdb9530 concretizer: added support for versioned virtual specs 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
48eb50921a concretizer: added rules and code for externals
Generate facts on externals by inspecting
packages.yaml. Added rules in concretize.lp

Added extra logic so that external specs
disregard any conflict encoded in the
package.

In ASP this would be a simple addition to
an integrity constraint:

:- c1, c2, c3, not external(pkg)

Using the the Backend API from Python it
requires some scaffolding to obtain a default
negated statement.
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
b92659c3bf package_sanity: fixed wrong string format 2020-11-17 10:04:13 -08:00
Massimiliano Culpo
1cdee03c4b concretizer: add conflict rules from packages
Conflict rules from packages are added as integrity
constraints in the ASP formulation. Most of the code
to generate them has been reused from PyclingoDriver.rules
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
2595b58503 test_noversion_pkg: generalized the error to be caught
The new concretizer and the old concretizer solve constraints
in a different way. Here we ensure that a SpackError is raised,
instead of a specific error that made sense in the old concretizer
but probably not in the new.
2020-11-17 10:04:13 -08:00
Massimiliano Culpo
aaa75b831f compiler constraints: deduplicate the list of compilers before encoding one_of_iff rules
This fixes 8 bugs in test/concretize.py
2020-11-17 10:04:13 -08:00
Todd Gamblin
e56f90c3ef concretizer: add compiler version constraints
Add rules to account for compiler version
constraints in concretize.lp.
2020-11-17 10:04:13 -08:00
Todd Gamblin
115384afbd concretizer: use cardinality constraints for versions
Instead of python callbacks, use cardinality constraints for package
versions. This is slightly faster and has the advantage that it can be
written to an ASP program to be executed *outside* of Spack. We can use
this in the future to unify the pyclingo driver and the clingo text
driver.

This makes use of add_weight_rule() to implement cardinality constraints.
add_weight_rule() only has a lower bound parameter, but you can implement
a strict "exactly one of" constraint using it. In particular, wee want to
define:

    1 {v1; v2; v3; ...} 1 :- version_satisfies(pkg, constraint).
    version_satisfies(pkg, constraint) :- 1 {v1; v2; v3; ...} 1.

And we do that like this, for every version constraint:

    atleast1(pkg, constr) :- 1 {version(pkg, v1); version(pkg, v2); ...}.
    morethan1(pkg, constr) :- 2 {version(pkg, v1); version(pkg, v2); ...}.
    version_satisfies(pkg, constr) :- atleast1, not morethan1(pkg, constr).
    :- version_satisfies(pkg, constr), morethan1.
    :- version_satisfies(pkg, constr), not atleast1.

v1, v2, v3, etc. are computed on the Python side by comparing every
possible package version with the constraint.

Computing things like this has the added advantage that if v1, v2, v3,
etc. comprise *all* possible versions of a package, we can just omit the
rules for the constraint under consideration. This happens pretty
frequently in the Spack mainline.
2020-11-17 10:04:13 -08:00
Todd Gamblin
0ed019d4ef concretizer: first working version with pyclingo interface
- [x] Solver now uses the Python interface to clingo
- [x] can extract unsatisfiable cores from problems when things go wrong
- [x] use Python callbacks for versions instead of choice rules (this may
      ultimately hurt performance)
2020-11-17 10:04:13 -08:00
Todd Gamblin
14ab63f97c concretizer: add a configuration option to use new or old concretizer
- [x] spec.py can call out to the new concretizer
- [x] config.yaml now has an option to choose a concretizer (original, clingo)
2020-11-17 10:04:13 -08:00
Todd Gamblin
2dd06f14f9 concretizer: use repository names, not specs with is_virtual 2020-11-17 10:04:13 -08:00
Todd Gamblin
ac9405a80e concretizer: refactor to support multiple solver backends
There are now three parts:

- `SpackSolverSetup`
  - Spack-specific logic for generating constraints. Calls methods on
    `AspTextGenerator` to set up the solver with a Spack problem. This
    shouln't change much from solver backend to solver backend.

- ClingoDriver
  - The solver driver provides methods for SolverSetup to generates an ASP
    program, send it to `clingo` (run as an external tool), and parse the
    output into function tuples suitable for `SpecBuilder`.
  - The interface is generic and should not have to change much for a
    driver for, say, the Clingo Python interface.

- SpecBuilder
  - Builds Spack specs from function tuples parsed by the solver driver.
2020-11-17 10:04:13 -08:00
Todd Gamblin
5bb83be827 concretizer: set spec constraints correctly for body and head 2020-11-17 10:04:13 -08:00
Todd Gamblin
cd55fd4bd3 concretizer: allow non-default OS, inherit OS along dependencies 2020-11-17 10:04:13 -08:00
Todd Gamblin
51cb49743e tests: add framework to mock targets 2020-11-17 10:04:13 -08:00
Todd Gamblin
43e7255e19 concretizer: split platforms, OS, and targets apart in Python and ASP 2020-11-17 10:04:13 -08:00
Todd Gamblin
cb919c2e39 concretizer: targets are inherited like compilers 2020-11-17 10:04:13 -08:00
Todd Gamblin
afa74ea155 concretizer: change single-letter variables to descriptive names
The original implementation was difficult to read, as it only had
single-letter variable names.  This converts all of them to descriptive
names, e.g., P -> Package, V -> Virtual/Version/Variant, etc.
2020-11-17 10:04:13 -08:00
Todd Gamblin
35ae4c0ddd concretizer: handle compiler existence check settings
To handle unknown compilers propely in tests (and elsewhere), we need to
add unknown compilers from the spec to the list of possible compilers.

Rework how the compiler list is generated and includes compilers from
specs if the existence check is disabled.
2020-11-17 10:04:13 -08:00
Todd Gamblin
3b648c294e concretizer: add initial package existence check 2020-11-17 10:04:13 -08:00
Todd Gamblin
520b71e89b concretizer: handle virtual spec constraints better
Specs like hdf5 ^mpi were unsatisfiable because we added a requierment
for `node("mpi").`.  This can't be resolved because "mpi" is not a
package.

- [x] Introduce `virtual_node()`, which says *some* provider must be in
      the DAG.
2020-11-17 10:04:13 -08:00
Todd Gamblin
3ef7c06a48 concretizer: solve with compiler flags but preserve order
This adds compiler flags to the ASP solve so that we can have conditions
based on them in the solve.  But, it keeps order out of the solve to
avoid unneeded complexity and combinatorial explosions.

The solver determines which flags are on a spec, but the order is
determined by DAG precedence (childrens' flags take precedence over
parents' and are added on the right) and order (order flags were
specified on the command line is respected).

The solver is responsible for determining when to propagate flags, when
to inheit them from other nodes, when to take them from compiler
preferences, etc.
2020-11-17 10:04:13 -08:00
Todd Gamblin
7a1b5ca65e concretizer: add timers around phases 2020-11-17 10:04:13 -08:00
Todd Gamblin
5185ed1d28 concretizer: optimize microarchitectures, constrained by compiler support
Weight microarchitectures and prefers more rercent ones.  Also disallow
nodes where the compiler does not support the selected target.

We should revisit this at some point as it seems like if I play around
with the compiler support for different architectures, the solver runs
very slowly.  See notes in comments -- the bad case was gcc supporting
broadwell and skylake with clang maxing out at haswell.
2020-11-17 10:04:13 -08:00
Todd Gamblin
71726a9b33 concretizer bugfix: require at least one value for multi-value variants
We didn't have a cardinality constraint for multi-valued variants, so the
solver wasn't filling them in.

- [x] add a requirement for at least one value for multi-valued variants
2020-11-17 10:04:13 -08:00
Todd Gamblin
309ae856ab commands: add --json argument to spack solve 2020-11-17 10:04:13 -08:00
Todd Gamblin
cb8ca505ef concretizer: make some rules into facts 2020-11-17 10:04:13 -08:00
Todd Gamblin
810542d4fe concretizer bugfix: all variants need possible values
Variants like `cpu_target` on `openblas` don't have defineed values, but
they have a default.  Ensure that the default is always a possible value
for the solver.
2020-11-17 10:04:13 -08:00
Todd Gamblin
9b1f05df00 concretizer bugfix: fix generations of conditionals for dependencies
Spack was generating the same dependency connstraints twice in the output ASP:

```
declared_dependency("abinit", "hdf5", "link")
    :- node("abinit"),
       variant_value("abinit", "mpi", "True"),
       variant_value("abinit", "mpi", "True").
```

This was because `AspFunction` was modifying itself when called.

- [x] fix `AspFunction` so that every call returns a new object
2020-11-17 10:04:13 -08:00
Todd Gamblin
e31be3da56 concretizer bugfix: *at most* one provider for any virtual 2020-11-17 10:04:13 -08:00
Todd Gamblin
04295f6531 concretizer: optimized for preferred virtuals before recent versions 2020-11-17 10:04:13 -08:00
Todd Gamblin
f365373a3d concretizer: handle compiler preferences with optimization
- [x] Add support for packages.yaml and command-line compiler preferences.
- [x] Rework compiler version propagation to use optimization rather than
  hard logic constraints
2020-11-17 10:04:13 -08:00
Todd Gamblin
1859ff31c9 concretizer: deterministic order for asp output for better diffs
Technically the ASP output order does not matter, but it's hard to diff
two different solve fomulations unless we order it.

- [x] make sure ASP output is emitted in a deterministic order (by
      sorting all hash keys)
2020-11-17 10:04:13 -08:00
Todd Gamblin
36dae9ee05 concretizer: rename --dump to --show 2020-11-17 10:04:13 -08:00
Todd Gamblin
da215b50a3 concretizer: handle package namespaces 2020-11-17 10:04:13 -08:00
Todd Gamblin
4d34363c1d concretizer: handle constraints on dependencies, adjust optimization
This needs more thought, as I am pretty sure the weights are not correct.
Or, at least, I'm not convinced that they do what we want in all cases.
See note in concretize.lp.
2020-11-17 10:04:13 -08:00
Todd Gamblin
db62b00d58 concretizer: handle dependency types 2020-11-17 10:04:13 -08:00
Todd Gamblin
cde10692b0 concretizer: prioritize versions by package pref, newest, preferred, actual
Solver now prefers newer versions like the old concretizer.  Prefer
package preferences from packages.yaml, preferred=True, package
definition, and finally each version itself.
2020-11-17 10:04:13 -08:00
Todd Gamblin
18fba433f6 concretizer: Use "competition" output format to avoid extra parsing
Competition output only prints out one model, so we do not have to
unnecessarily parse all the non-optimal models.  We'll just look at the
best model and bring that in.

In practice, this saves a lot of JSON parsing and spec construction time.
2020-11-17 10:04:13 -08:00
Todd Gamblin
b4e6d9d28e concretizer: handle virtual provider preferences from packages.yaml 2020-11-17 10:04:13 -08:00
Todd Gamblin
36ec66d997 concretizer: use clingo json output instead of text
Clingo actually has an option to output JSON -- use that instead of
parsing the raw otuput ourselves.

This also allows us to pick the best answer -- modify the parser to
*only* construct a spec for that one rather than building all of them
like we did before.
2020-11-17 10:04:13 -08:00
Todd Gamblin
a332981f2f concretizer: require only one provider for any virtual in the DAG 2020-11-17 10:04:13 -08:00
Todd Gamblin
501cb371c9 concretizer: handle variant defaults with optimization
- Instead of using default logic, handle variant defaults by minimizing
  the number of non-default variants in the solution.

- This actually seems to be pretty fast, and it fixes the long-standing
  issue that writing this:

      spack install hdf5 ^mpich

  will fail if you don't specify hdf5+mpi.  With optimization and
  allowing enums to be enumerated, the solver seems to be able to quickly
  discover that +mpi is the only way hdf5 can depend on mpich, and it
  forces the switch to be thrown.
2020-11-17 10:04:13 -08:00
Todd Gamblin
1cab1b1994 concretizer: support conditional dependencies 2020-11-17 10:04:13 -08:00
Todd Gamblin
51af590e64 variants: allow MultiValuedVariants to be constructed incrementally 2020-11-17 10:04:13 -08:00
Todd Gamblin
be10568a6a concretizer: initial support for virtual dependencies
Add initial support for virtual dependencies.  Solver now knows about all
virtuals and can choose one to resolve a dependency.
2020-11-17 10:04:13 -08:00
Todd Gamblin
3f93553a08 concretizer: print out virtuals 2020-11-17 10:04:13 -08:00
Todd Gamblin
8a6207aa70 concretizer: handle versions with choice construct rather than conflicts
Use '1 { version(x); version(y); version(z) } 1.' instead of declaring
conflicts for non-matching versions.  This keeps the sense of version
clauses positive, which will allow them to be used more easily in
conditionals later.

Also refactor `spec_clauses()` method to return clauses that can be used
in conditions, etc. instead of just printing out facts.
2020-11-17 10:04:13 -08:00
Todd Gamblin
6e31430bec concretizer: add another definition pragma.
- single_value_variant may not be defined by the generated program.  Mark
  it to avoid warnings.
2020-11-17 10:04:13 -08:00
Todd Gamblin
a81258663c concretizer: cleanup 2020-11-17 10:04:13 -08:00
Todd Gamblin
6bbc64555b concretizer: use conditional literals for versions. 2020-11-17 10:04:13 -08:00
Todd Gamblin
4288639770 concretizer: mark depends_on/2 defined for solves without dependencies. 2020-11-17 10:04:13 -08:00
Todd Gamblin
60cf3fdb34 concretizer: add basic semantics for compilers
- This handles setting the compiler and falling back to a default
  compiler, as well as providing default values for compilers/compiler
  versions.

- Versions still aren't quite right -- you can't properly override
  versions on compiler specs.
2020-11-17 10:04:13 -08:00
Todd Gamblin
f7dce19754 concretizer: simplify and move architecture semantics into concretize.lp
- Model architecture default settings and propagation off of variants

- Leverage ASP default logic to set architecture to default if it's not
  set otherwise.

- Move logic out of Python and into concretize.lp as first-order rules.
2020-11-17 10:04:13 -08:00
Todd Gamblin
34ea3d20cf concretizer: break output up into easier-to-understand sections 2020-11-17 10:04:13 -08:00
Todd Gamblin
d94d957536 concretizer: simplify and suppress warnings for variant handling
We are relying on default logic in the variant handling in that we set a
default value if we never see `variant_set(P, V, X)`.

- Move the logic for this into `concretize.lp` instead of generating it
  for every package.

- For programs that don't have explicit variant settings, clingo warns
  that variant_set(P, V, X) doesn't appear in any rule head, because a
  setting is never generated.

  - Specifically suppress this warning.
2020-11-17 10:04:13 -08:00
Todd Gamblin
b171ac5050 concretizer: split long lines in ASP programs 2020-11-17 10:04:13 -08:00
Todd Gamblin
573a2612dc concretizer: split main logic program out into files
- Add `concretize.lp` and `display.lp` as independent files
- Dump them instead of embedded strings
2020-11-17 10:04:13 -08:00
Todd Gamblin
8bc1092f41 concretizer: colorize ASP output 2020-11-17 10:04:13 -08:00
Todd Gamblin
3637b611a7 concretizer: move dump logic into solver.asp
- moving the dump logic into spack.solver.asp.solve() allows us to print
  out useful debug info sooner

- prior approach required a successful solve to print out anyhting.
2020-11-17 10:04:13 -08:00
Todd Gamblin
81e187e410 concretizer: first rudimentary round-trip with asp-based solver 2020-11-17 10:04:13 -08:00
Todd Gamblin
c7812f7e10 concretizer: add rudimentary variants with defaults to ASP solve 2020-11-17 10:04:13 -08:00
Todd Gamblin
a8a6d943d6 concretizer: beginnings of solve() command
- `spack solve` command outputs a really basic ASP program that handles
  unconditional dependencies, architecture and versions

- doesn't yet handle conflicts, picking latest versions, preferred
  versions, compilers, etc.

- doesn't handle variants
2020-11-17 10:04:13 -08:00
Todd Gamblin
5b725a37bc repo: Add all_package_classes() method.
- We were able to get names and instances previously
- Add a convenience function to get package classes
2020-11-17 10:04:13 -08:00
Robert Underwood
f359664493
include share/pkgconfig in user environments (#19909)
According to the documentation for spack and pkg-config,
$view/share/pkgconfig should also be a valid place to look
for package config files.  This commit ensures that when
spack activate env $dir is called, the environment has this
directory in PKG_CONFIG_PATH.
2020-11-17 11:10:28 -06:00