Commit graph

4775 commits

Author SHA1 Message Date
loulawrence
4da0561496
Add config option to use urllib to fetch if curl missing (#21398)
* Use Python module urllib to fetch in the case that curl is missing
2021-06-22 13:38:37 -07:00
Peter Scheibel
477c8ce820
Update conftest.py (#24473) 2021-06-22 12:57:35 -07:00
Massimiliano Culpo
acc11f676d
ASP-based solver: fix provider logic (#24351)
This commit fixes a subtle bug that may occur when
a package is a "possible_provider" of a virtual but
no "provides_virtual" can be deduced. In that case
the cardinality constraint on "provides_virtual"
may arbitrarily assign a package the role of provider
even if the constraints for it to be one are not fulfilled.

The fix reworks the logic around three concepts:
- "possible_provider": a package may provide a virtual if some constraints are met
- "provides_virtual": a package meet the constraints to provide a virtual
- "provider": a package selected to provide a virtual
2021-06-22 11:37:24 -07:00
Massimiliano Culpo
02b92dbf10
ASP-based solver: fix facts for default providers (#24380)
Facts used to compute weights for providers only need
the package name, since the other attributes are computed
as part of the solve.
2021-06-22 11:33:44 -07:00
Erik Schnetter
e3b220f699
Implement CVS fetcher (#23212)
Spack packages can now fetch versions from CVS repositories. Note
this fetch mechanism is unsafe unless using :extssh:. Most public
CVS repositories use an insecure protocol implemented as part of CVS.
2021-06-22 09:51:31 -07:00
Vanessasaurus
8e249c03de
adding save of build times on install (#24350)
Here we are adding an install_times.json into the spack install metadata folder.
We record a total, global time, along with the times for each phase. The type
of phase or install start / end is included (e.g., build or fail)

Signed-off-by: vsoch <vsoch@users.noreply.github.com>

Co-authored-by: vsoch <vsoch@users.noreply.github.com>
2021-06-22 03:01:15 -06:00
Peter Scheibel
c83f4b01aa
Fetching: git on Mac OS (#24247)
Extend the changes in #24163 to unit tests.
2021-06-21 17:53:12 -07:00
Massimiliano Culpo
32f1aa607c
Add an audit system to Spack (#23053)
Add a new "spack audit" command. This command can check for issues
with configuration or with packages and is intended to help a
user debug a failed Spack build. 

In some cases the reported issues are always errors but are too
costly to check for (e.g. packages that specify missing variants on
dependencies). In other cases the issues may be legitimate but
uncommon usage of Spack and we want to be sure the user intended the
behavior (e.g. duplicate compiler definitions).

Audits are grouped by theme, and for now the two themes are packages
and configuration. For example you can run all available audits
on packages with "spack audit packages". It is intended that in
the future users will be able to define their own audits.

The package audits are good candidates for running in package_sanity
(i.e. they could catch bugs in user-submitted packages before they
are merged) but that is left for a later PR.
2021-06-18 07:52:08 -06:00
Frank Willmore
2c1e9cc7b7
oneAPI compiler: update openmp flag (#23771) 2021-06-17 17:26:46 -07:00
Vanessasaurus
e7ac422982
Adding support for spack monitor with containerize (#23777)
This should get us most of the way there to support using monitor during a spack container build, for both Singularity and Docker. Some quick notes:

### Docker
Docker works by way of BUILDKIT and being able to specify --secret. What this means is that you can prefix a line with a mount of type secret as follows:

```bash
# Install the software, remove unnecessary deps
RUN --mount=type=secret,id=su --mount=type=secret,id=st cd /opt/spack-environment && spack env activate . && export SPACKMON_USER=$(cat /run/secrets/su) && export SPACKMON_TOKEN=$(cat /run/secrets/st) && spack install --monitor --fail-fast && spack gc -y
```
Where the id for one or more secrets corresponds to the file mounted at `/run/secrets/<name>`. So, for example, to build this container with su (spackmon user) and sv (spackmon token) defined I would export them on my host and do:

```bash
$ DOCKER_BUILDKIT=1 docker build --network="host" --secret id=st,env=SPACKMON_TOKEN --secret id=su,env=SPACKMON_USER -t spack/container . 
```
And when we add `env` to the secret definition that tells the build to look for the secret with id "st" in the environment variable `SPACKMON_TOKEN` for example.

If the user is building locally with a local spack monitor, we also need to set the `--network` to be the host, otherwise you can't connect to it (a la isolation of course.)

## Singularity

Singularity doesn't have as nice an ability to clearly specify secrets, so (hoping this eventually gets implemented) what I'm doing now is providing the user instructions to write the credentials to a file, add it to the container to source, and remove when done.

## Tags

Note that the tags PR https://github.com/spack/spack/pull/23712 will need to be merged before `--monitor-tags` will actually work because I'm checking for the attribute (that doesn't exist yet):

```bash
"tags": getattr(args, "monitor_tags", None)
```
So when that PR is merged to update the argument group, it will work here, and I can either update the PR here to not check if the attribute is there (it will be) or open another one in the case this PR is already merged. 

Finally, I added a bunch of documetation for how to use monitor with containerize. I say "mostly working" because I can't do a full test run with this new version until the container base is built with the updated spack (the request to the monitor server for an env install was missing so I had to add it here).

Signed-off-by: vsoch <vsoch@users.noreply.github.com>

Co-authored-by: vsoch <vsoch@users.noreply.github.com>
2021-06-17 17:15:22 -07:00
Scott Wittenburg
ee9b1a6ea5
ci: add all locally computed hashes as job variables (#24359) 2021-06-17 03:37:31 -06:00
Harmen Stoppels
e4d80c997a
Unset LD_PRELOAD and DYLD_INSERT_LIBRARIES (#24177)
When running executables from build dependencies, we want to avoid that
`LD_PRELOAD` and `DYLD_INSERT_LIBRARIES` any of their shared libs build
by spack with system libraries.
2021-06-17 09:25:19 +00:00
Vanessasaurus
53dae0040a
adding spack upload command (#24321)
this will first support uploads for spack monitor, and eventually could be
used for other kinds of spack uploads

Signed-off-by: vsoch <vsoch@users.noreply.github.com>

Co-authored-by: vsoch <vsoch@users.noreply.github.com>
2021-06-15 14:36:02 -07:00
Vanessasaurus
5521aae4f7
extending example for buildcaches (#22504)
* extending example for buildcaches

I was attempting to create a local build cache from a directory, and I found the
docs for both buildcaches and mirrors, but did not connect the docs that the
url variable could be the local filesystem variable. I am extending the docs for
buildcaches with an example of creating and interacting with one on the filesystem
because I suspect other users will run into this need and possibly not find what
they are looking for.

Signed-off-by: vsoch <vsoch@users.noreply.github.com>

* adding as follows to spack mirror list

Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>

Co-authored-by: vsoch <vsoch@users.noreply.github.com>
Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>
2021-06-14 21:46:27 -07:00
Vanessasaurus
39cdd085c9
adding more description to binary caches (#23934)
It is currently kind of confusing to the reader to distinguish spack buildcache install
and spack install, and it is not clear how to use a build cache once a mirror is added.
Hopefully this little big of description can help (and I hope I got it right!)

Signed-off-by: vsoch <vsoch@users.noreply.github.com>

Co-authored-by: vsoch <vsoch@users.noreply.github.com>
2021-06-14 13:17:35 -07:00
Robert Cohn
d993ee7972
oneAPI packages: fix install for python2 (#24296)
Fix platform detection logic to work for Python 2 and 3
2021-06-14 10:47:44 -07:00
Dominik Gresch
dc8626b801
IntelPackage: use 'version_yearlike' in check for libfabrics RPATH. (#16700)
Use the 'version_yearlike' attribute instead of 'version' to
check if the SPACK_COMPILER_EXTRA_RPATHS should be set to include
the built-in 'libfabrics'.
When using the bare 'version', the comparison is wrong when
building with 'intel-parallel-studio', which has the version
format '<edition>.YYYY.Nupdate', due to the leading '<edition>'.
2021-06-12 10:02:56 +00:00
Greg Becker
95c9a031ee
Ensure all roots of an installed environment are marked explicit in db (#24277) 2021-06-12 10:23:13 +02:00
Adam J. Stewart
11f370e7be
setup-env: allow users to skip module function setup (#24236)
* setup-env: allow users to skip module function setup

* Add documentation on SPACK_SKIP_MODULES
2021-06-11 19:19:24 +00:00
iarspider
ea08e93f2f
Display proper message when patch checksum doesn't match (#24229) 2021-06-11 10:31:33 +02:00
Scott Wittenburg
92bef1da6f
Pipelines: Fix default generated rebuild job script (#24185) 2021-06-08 14:33:45 -06:00
Massimiliano Culpo
f33c4e7280
ASP-based solver: permit to use virtual specs in environments (#24199)
Extracting specs for the result of a solve has been factored
as a method into the asp.Result class. The method account for
virtual specs being passed as initial requests.
2021-06-08 19:04:49 +02:00
Massimiliano Culpo
e321578bbe
ASP-based solver: reordered low priority optimization criteria (#24184)
Minimizing compiler mismatches in the DAG and preferring newer 
versions of packages are now higher priority than trying to use as 
many default values as possible in multi-valued variants.
2021-06-08 16:10:49 +02:00
Todd Gamblin
beed6047e8
macOS: add monterey as macOS version 12. (#24192) 2021-06-08 10:07:34 +00:00
Massimiliano Culpo
729d66a3f8
Fix brittle unit-tests on providers (#24186)
These tests were broken by #24176
2021-06-07 22:16:14 +02:00
Michael Kuhn
4d55203ce5
build_systems: Make autotools builds verbose (#24161)
This is also what our other build systems are doing.
2021-06-07 14:05:35 -04:00
Adam J. Stewart
3d0bad465b
Docs: fix missing backtick in Environments docs (#24109) 2021-06-07 19:05:09 +02:00
Adam J. Stewart
7449d6950a
Fix git_version on macOS (#24163) 2021-06-05 23:30:28 +00:00
Michael Kuhn
7d3a3af621
main, modules: fix module roots not being found (#24135)
Since the module roots were removed from the config file,
`--print-shell-vars` cannot find the module roots anymore. Fix it by
using the new `root_path` function. Moreover, the roots for lmod and
modules seems to have been flipped by accident.
2021-06-04 15:33:18 -07:00
Joe Heaton
13978d68ea
enable std c++14 (#24127) 2021-06-04 18:47:32 +00:00
Michael Kuhn
d5d1d9548f
cmd/stage: print stage path (#24019)
This is a small quality of life improvement so that users can easily
copy and paste the stage path after executing `spack stage spec`.
2021-06-04 11:18:55 +00:00
Greg Becker
d8fc38a467
bugfix: modules relative to view use top-level view root, not implementation root (#24124) 2021-06-04 10:13:14 +02:00
Adam J. Stewart
c09eea5947
Don't warn about missing source id for external packages (#24125) 2021-06-04 09:55:09 +02:00
Tom Scogland
b63a8b3e27
Speed-up version parsing and comparison (#22973)
The VALID_VERSION regex didn't check that the version string was
completely valid, only that a prefix of it was. This version ensures
the entire string represents a valid version.

This makes a few related changes.

1. Make the SEGMENT_REGEX identify *which* arm it matches by what groups
   are populated, including whether it's a string or int component or a
   separator all at once.

2. Use the updated regex to parse the input once with a findall rather
   than twice, once with findall and once with split, since the version
   components and separators can be distinguished by their group status.

3. Rather than "convert to int, on exception stay string," if the int
   group is set then convert to int, if not then construct an instance
   of the VersionStrComponent class

4. VersionStrComponent now implements all of the special string
   comparison logic as part of its __lt__ and __eq__ methods to deal
   with infinity versions and also overloads comparison with integers.

5. Version now uses direct tuple comparison since it has no per-element
   special logic outside the VersionStrComponent class.

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2021-06-04 09:23:37 +02:00
Scott Wittenburg
9903d05be9
Pipelines: Fix generation when dep and pkg arch differ (#24089) 2021-06-03 19:26:43 -04:00
Harmen Stoppels
473e9aa08e
Extend cuda conflicts to cray platform (#24057)
The CUDA compiler conflicts are valid on Cray too, and likely 
on Darwin x86_64 with %gcc and %clang too, so drop platform=linux
2021-06-03 03:46:27 -06:00
Scott Wittenburg
28517deeeb
Pipelines: pass relative artifact paths to child jobs (#24085)
Passing absolute paths from pipeline generate job to downstream rebuild jobs
causes problems when the CI_PROJECT_DIR is not the same for the generate and
rebuild jobs.  This has happened, for example, when gitlab checks out the
project into a runner-specific directory and different runners are chosen
for the generate and rebuild jobs.
2021-06-02 14:20:57 -06:00
Danny McClanahan
b369ff461a
ensure the staging dir exists for spack stage -p <PATH> (#23963)
* ensure that the stage root exists for `spack stage -p <PATH>`

* add test to verify `spack stage -p <PATH>` works!

* move out shared tmp staging path setup to a fixture to fix the test
2021-06-02 09:56:51 -07:00
Harmen Stoppels
e8afc5db15
Fix bug where cmake prefix path on the command line does not include transitive deps (#23965) 2021-06-01 12:45:52 -07:00
Massimiliano Culpo
707a3f7df8
Simplified the spack.util.gpg implementation (#23889)
* Simplified the spack.util.gpg implementation

All the classes defined in this Python module,
which were previously used to construct singleton
instances, have been removed in favor of four
global variables. These variables are initialized
lazily, like before.

The API of the module has been unchanged for the
most part. A few tests have been modified to use
the new global names.
2021-06-01 10:05:42 -07:00
Harmen Stoppels
bb5fd5c567
Fix leading / during spack buildcache -f ... (#24028)
For me the buildcache force overwrite option does not work. It tries to
delete a file, but errors with a key error, apparently because the
leading / has to be removed.
2021-06-01 01:10:32 -06:00
Tom Scogland
4a7b0afde2
Log performance improvement (#23925)
* util.tty.log: read up to 100 lines if ready

Rework to read up to 100 lines from the captured stdin as long as data
is ready to be read immediately.  Adds a helper function to poll with
`select` for ready data.  This showed a roughly 5-10x perf improvement
for high-rate writes through the logger with relatively short lines.

* util.tty.log: Defer flushes to end of ready reads

Rather than flush per line, flush per set of reads.  Since this is a
non-blocking loop, the total perceived wait is short.

* util.tty.log: only scan each line once, usually

Rather than always find all control characters then substitute them all,
use `subn` to count the number of control characters replaced.  Only if
control characters exist find out what they are.  This could be made
truly single pass with sub with a function, but it's a more intrusive
change and this got 99%ish of the performance improvement (roughly
another 2x in some cases).

* util.tty.log: remove check for `readable`

Python < 3 does not support a readable check on streams, should not be
necessary here since we control the only use and it's explicitly a
stream to be read.
2021-05-31 20:33:14 -07:00
Vanessasaurus
6f534acbef
adding support for export of private gpg key (#22557)
This PR allows users to `--export`, `--export-secret`, or both to  export GPG keys
from Spack. The docs are updated that include a warning that this usually does not
need to be done.

This addresses an issue brought up in slack, and also represented in #14721.

Signed-off-by: vsoch <vsoch@users.noreply.github.com>

Co-authored-by: vsoch <vsoch@users.noreply.github.com>
2021-05-28 23:32:57 -07:00
Harmen Stoppels
f6febd2ef5
Cache compiler lookup per package (#23988)
Before:

```
$ hyperfine '~/spack/bin/spack -e . build-env rocfft'
Benchmark #1: ~/spack/bin/spack -e . build-env rocfft
  Time (mean ± σ):      1.593 s ±  0.016 s    [User: 1.468 s, System: 0.126 s]
  Range (min … max):    1.575 s …  1.628 s    10 runs
```

After:

```
$ hyperfine '~/spack/bin/spack -e . build-env rocfft'
Benchmark #1: ~/spack/bin/spack -e . build-env rocfft
  Time (mean ± σ):      1.407 s ±  0.020 s    [User: 1.280 s, System: 0.127 s]
  Range (min … max):    1.393 s …  1.455 s    10 runs
```
2021-05-28 21:36:34 +00:00
Greg Becker
7490d63c38
Separable module configuration -- without the bugs this time (#23703)
Currently, module configurations are inconsistent because modulefiles are generated with the configs for the active environment, but are shared among all environments (and spack outside any environment).

This PR fixes that by allowing Spack environments (or other spack config scopes) to define additional sets of modules to generate. Each set of modules can enable either lmod or tcl modules, and contains all of the previously available module configuration. The user defines the name of each module set -- the set configured in Spack by default is named "default", and is the one returned by module manipulation commands in the absence of user intervention.

As part of this change, the module roots configuration moved from the config section to inside each module configuration.

Additionally, it adds a feature that the modulefiles for an environment can be configured to be relative to an environment view rather than the underlying prefix. This will not be enabled by default, as it should only be enabled within an environment and for non-default views constructed with separate projections per-spec.
2021-05-28 14:12:05 -07:00
Scott Wittenburg
91f66ea0a4
Pipelines: reproducible builds (#22887)
### Overview

The goal of this PR is to make gitlab pipeline builds (especially build failures) more reproducible outside of the pipeline environment.  The two key changes here which aim to improve reproducibility are: 

1. Produce a `spack.lock` during pipeline generation which is passed to child jobs via artifacts.  This concretized environment is used both by generated child jobs as well as uploaded as an artifact to be used when reproducing the build locally.
2. In the `spack ci rebuild` command, if a spec needs to be rebuilt from source, do this by generating and running an `install.sh` shell script which is then also uploaded as a job artifact to be run during local reproduction.  

To make it easier to take advantage of improved build reproducibility, this PR also adds a new subcommand, `spack ci reproduce-build`, which, given a url to job artifacts:

- fetches and unzips the job artifacts to a local directory
- looks for the generated pipeline yaml and parses it to find details about the job to reproduce
- attempts to provide a copy of the same version of spack used in the ci build
- if the ci build used a docker image, the command prints a `docker run` command you can run to get an interactive shell for reproducing the build

#### Some highlights

One consequence of this change will be much smaller pipeline yaml files.  By encoding the concrete environment in a `spack.lock` and passing to child jobs via artifacts, we will no longer need to encode the concrete root of each spec and write it into the job variables, greatly reducing the size of the generated pipeline yaml.

Additionally `spack ci rebuild` output (stdout/stderr) is no longer internally redirected to a log file, so job output will appear directly in the gitlab job trace.  With debug logging turned on, this often results in log files getting truncated because they exceed the maximum amount of log output gitlab allows.  If this is a problem, you still have the option to `tee` command output to a file in the within the artifacts directory, as now each generated job exposes a `user_data` directory as an artifact, which you can fill with whatever you want in your custom job scripts.

There are some changes to be aware of in how pipelines should be set up after this PR:

#### Pipeline generation

Because the pipeline generation job now writes a `spack.lock` artifact to be consumed by generated downstream jobs, `spack ci generate` takes a new option `--artifacts-root`, inside which it creates a `concrete_env` directory to place the lockfile.  This artifacts root directory is also where the `user_data` directory will live, in case you want to generate any custom artifacts.  If you do not provide `--artifacts-root`, the default is for it to create a `jobs_scratch_dir` within your `CI_PROJECT_DIR` (a gitlab predefined environment variable) or whatever is your current working directory if that variable isn't set. Here's the diff of the PR testing `.gitlab-ci.yml` taking advantage of the new option:

```
$ git diff develop..pipelines-reproducible-builds share/spack/gitlab/cloud_pipelines/.gitlab-ci.yml
diff --git a/share/spack/gitlab/cloud_pipelines/.gitlab-ci.yml b/share/spack/gitlab/cloud_pipelines/.gitlab-ci.yml
index 579d7b56f3..0247803a30 100644
--- a/share/spack/gitlab/cloud_pipelines/.gitlab-ci.yml
+++ b/share/spack/gitlab/cloud_pipelines/.gitlab-ci.yml
@@ -28,10 +28,11 @@ default:
     - cd share/spack/gitlab/cloud_pipelines/stacks/${SPACK_CI_STACK_NAME}
     - spack env activate --without-view .
     - spack ci generate --check-index-only
+      --artifacts-root "${CI_PROJECT_DIR}/jobs_scratch_dir"
       --output-file "${CI_PROJECT_DIR}/jobs_scratch_dir/cloud-ci-pipeline.yml"
   artifacts:
     paths:
-      - "${CI_PROJECT_DIR}/jobs_scratch_dir/cloud-ci-pipeline.yml"
+      - "${CI_PROJECT_DIR}/jobs_scratch_dir"
   tags: ["spack", "public", "medium", "x86_64"]
   interruptible: true
```

Notice how we replaced the specific pointer to the generated pipeline file with its containing folder, the same folder we passed as `--artifacts-root`.  This way anything in that directory (the generated pipeline yaml, as well as the concrete environment directory containing the `spack.lock`) will be uploaded as an artifact and available to the downstream jobs.

#### Rebuild jobs

Rebuild jobs now must activate the concrete environment created by `spack ci generate` and provided via artifacts.  When the pipeline is generated, a directory called `concrete_environment` is created within the artifacts root directory, and this is where the `spack.lock` file is written to be passed to the generated rebuild jobs.  The artifacts root directory can be specified using the `--artifacts-root` option to `spack ci generate`, otherwise, it is assumed to be `$CI_PROJECT_DIR`.  The directory containing the concrete environment files (`spack.yaml` and `spack.lock`) is then passed to generated child jobs via the `SPACK_CONCRETE_ENV_DIR` variable in the generated pipeline yaml file.

When you don't provide custom `script` sections in your `mappings` within the `gitlab-ci` section of your `spack.yaml`, the default behavior of rebuild jobs is now to change into `SPACK_CONCRETE_ENV_DIR` and activate that environment.   If you do provide custom rebuild scripts in your `spack.yaml`, be aware those scripts should do the same thing: assume `SPACK_CONCRETE_ENV_DIR` contains the concretized environment to activate.  No other changes to existing custom rebuild scripts should be required as a result of this PR. 

As mentioned above, one key change made in this PR is the generation of the `install.sh` script by the rebuild jobs, as that same script is both run by the CI rebuild job as well as exported as an artifact to aid in subsequent attempts to reproduce the build outside of CI.  The generated `install.sh` script contains only a single `spack install` command with arguments computed by `spack ci rebuild`.  If the install fails, the job trace in gitlab will contain instructions on how to reproduce the build locally:

```
To reproduce this build locally, run:
  spack ci reproduce-build https://gitlab.next.spack.io/api/v4/projects/7/jobs/240607/artifacts [--working-dir <dir>]
If this project does not have public pipelines, you will need to first:
  export GITLAB_PRIVATE_TOKEN=<generated_token>
... then follow the printed instructions.
```

When run locally, the `spack ci reproduce-build` command shown above will download and process the job artifacts from gitlab, then print out instructions you  can copy-paste to run a local reproducer of the CI job.

This PR includes a few other changes to the way pipelines work, see the documentation on pipelines for more details.

This  PR erelies on 
~- [ ] #23194 to be able to refer to uninstalled specs by DAG hash~
EDIT: that is going to take longer to come to fruition, so for now, we will continue to install specs represented by a concrete `spec.yaml` file on disk.
- [x] #22657 to support install a single spec already present in the active, concrete environment
2021-05-28 09:38:07 -07:00
Greg Becker
405314195e
aocc version detection (#23907) 2021-05-28 10:13:40 -05:00
Greg Becker
b91dff4aaf
bugfix: mirror index shows missing packages (#23939)
- [x] add `in_buildcache` field to DB records to indicate what parts of an index, 
       which includes roots and dependencies, are in the buildcache.
- [x] add `mark()` method to DB for setting values on single nodes of the DAG.
2021-05-27 20:38:13 +00:00
Greg Becker
b9a66966a8
only readlink on links (#23948) 2021-05-27 09:20:57 -07:00
Greg Becker
b7f7d901d1
allow whitespace formatting in variant descriptions (#23853) 2021-05-26 14:34:13 -06:00