Commit graph

5104 commits

Author SHA1 Message Date
Massimiliano Culpo
2d45a9d617
Speed-up environment concretization on linux with a process pool (#26264)
* Speed-up environment concretization with a process pool

We can exploit the fact that the environment is concretized
separately and use a pool of processes to concretize it.

* Add module spack.util.parallel

Module includes `pool` and `parallel_map` abstractions,
along with implementation details for both.

* Add a new hash type to pass specs across processes

* Add tty msg with concretization time
2021-10-19 10:09:34 -05:00
Christopher Kotfila
ad35251860
Fix trigger and child links in pipeline docs (#26814) 2021-10-19 14:44:36 +00:00
Scott Wittenburg
95538de731
Speed up pipeline generation (#26622)
- [x] Stage already concretized specs instead of abstract ones
- [x] Reduce number of network calls by reading naughty list up front
2021-10-18 20:58:02 -07:00
Todd Gamblin
c5ca0db27f
patches: make re-applied patches idempotent (#26784)
We use POSIX `patch` to apply patches to files when building, but
`patch` by default prompts the user when it looks like a patch
has already been applied. This means that:

1. If a patch lands in upstream and we don't disable it
   in a package, the build will start failing.
2. `spack develop` builds (which keep the stage around) will
   fail the second time you try to use them.

To avoid that, we can run `patch` with `-N` (also called
`--forward`, but the long option is not in POSIX). `-N` causes
`patch` to just ignore patches that have already been applied.
This *almost* makes `patch` idempotent, except that it returns 1
when it detects already applied patches with `-N`, so we have to
look at the output of the command to see if it's safe to ignore
the error.

- [x] Remove non-POSIX `-s` option from `patch` call
- [x] Add `-N` option to `patch`
- [x] Ignore error status when `patch` returns 1 due to `-N`
- [x] Add tests for applying a patch twice and applying a bad patch
- [x] Tweak `spack.util.executable` so that it saves the error that
      *would have been* raised with `fail_on_error=True`. This lets
      us easily re-raise it.

Co-authored-by: Greg Becker <becker33@llnl.gov>
2021-10-18 23:11:42 +00:00
Seth R. Johnson
c48b733773
Make macOS installed libraries more relocatable (#26608)
* relocate: call install_name_tool less

* zstd: fix race condition

Multiple times on my mac, trying to install in parallel led to failures
from multiple tasks trying to simultaneously create `$PREFIX/lib`.

* PackageMeta: simplify callback flush

* Relocate: use spack.platforms instead of platform

* Relocate: code improvements

* fix zstd

* Automatically fix rpaths for packages on macOS

* Only change library IDs when the path is already in the rpath

This restores the hardcoded library path for GCC.

* Delete nonexistent rpaths and add more testing

* Relocate: Allow @executable_path and @loader_path
2021-10-18 13:34:16 -04:00
Shahzeb Siddiqui
3c013b5be6
docutils > 0.17 issue with rendering list items in sphinx (#26355)
* downgrade_docutils_version

* invalid version

* Update requirements.txt

* Improve spelling and shorten the reference link

* Update spack.yaml

* update version requirement

* update version to maximum of 0.16

Co-authored-by: bernhardkaindl <43588962+bernhardkaindl@users.noreply.github.com>
2021-10-18 16:55:46 +00:00
Harmen Stoppels
30e8dd95b5
Remove unused exist_errors in installer.py (#26650) 2021-10-18 15:53:51 +02:00
Harmen Stoppels
1e5f7b3542
Don't print error output in the test whether gpgconf works (#26682) 2021-10-18 15:52:53 +02:00
Harmen Stoppels
33ef7d57c1
Revert 19736 because conflicts are avoided by clingo by default (#26721) 2021-10-18 08:41:35 +02:00
Brice Videau
0bc1bffe50
Fix ruby dependent extensions. (#26729)
* Fix ruby dependent extensions.

* Added Kerilk as maintainer.
2021-10-15 16:59:32 +00:00
Harmen Stoppels
f8e4aa7d70
Revert "Don't run lsb_release on linux (#26707)" (#26754)
This reverts commit fcac95b065.
2021-10-15 09:34:04 +00:00
Harmen Stoppels
e0fbf09239
EnvironmentModifications: allow disabling stack tracing (#26706)
Currently Spack keeps track of the origin in the code of any
modification to the environment variables. This is very slow 
and enabled unconditionally even in code paths where the 
origin of the modification is never queried.

The only place where we inspect the origins of environment 
modifications is before we start a build, If there's an override 
of the type `e.set(...)` after incremental changes like 
`e.append_path(..)`, which is a "suspicious" change.

This is very rare though.

If an override like this ever happens, it might mean a package is
broken. If that leads to build errors, we can just ask the user to run
`spack -d install ...` and check the warnings issued by Spack to find
the origins of the problem.
2021-10-15 10:00:44 +02:00
Tamara Dahlgren
41d375f6a4
Stand-alone tests: disallow re-using an alias (#25881)
It can be frustrating to successfully run `spack test run --alias <name>` only to find you cannot get the results because you already use `<name>` in some previous stand-alone test execution.  This PR prevents that from happening.
2021-10-14 15:08:00 -07:00
Massimiliano Culpo
eded8f48dc
ASP-based solver: add a rule for version uniqueness in virtual packages (#26740)
fixes #26718

A virtual package may or may not have a version, but it
never has more than one. Previously we were missing a rule
for that.
2021-10-14 23:06:41 +02:00
Massimiliano Culpo
949094544e
Constrain abstract specs rather than concatenating strings in the "when" context manager (#26700)
Using the Spec.constrain method doesn't work since it might
trigger a repository lookup which could break our directives
and triggers a circular import error.

To fix that we introduce a function to merge abstract anonymous
specs, based only on package names, which does not perform any
lookup in the repository.
2021-10-14 12:33:10 +02:00
Harmen Stoppels
fcac95b065
Don't run lsb_release on linux (#26707)
Running `lsb_release` on Linux takes about 50ms because it is written in
Python. We do not use the output, so this change makes use not call it.
2021-10-14 01:27:24 +02:00
Patrick Gartung
047c95aa8d
buildcache: do one less tar file extraction
The buildcache is now extracted in a temporary folder within the current store,
moved to its final place and relocated. 

"spack clean -s" has been extended to also clean the temporary extraction directory.

Add hardlinks with absolute paths for libraries in the corge, garply and quux packages
to detect incorrect handling of hardlinks in tests.
2021-10-13 17:38:29 +02:00
Harmen Stoppels
1ed695dca7
Improve error messages for bootstrap download failures (#26599) 2021-10-12 22:11:07 +02:00
Alexander Jaust
50a2316a15
Add missing spack command in basic usage tutorial (#26646)
The `find` command was missing for the examples forcing colorized output. Without this (or another suitable) command, spack produces output that is not using any color. Thus, without the `find` command one does not see any difference between forced colorized and non-colorized output.
2021-10-12 19:23:53 +02:00
Harmen Stoppels
e168320bb1
spack: Add package (#25979)
* Make python 2 use 'from __future__ import absolute_import' to allow import spack.pkgkit

* Add Spack

* Improve ranges
2021-10-12 11:39:39 -04:00
Vanessasaurus
ce7eebfc1f
allowing spack monitor to handle redirect (#26666)
when deployed on kubernetes, the server sends back permanent redirect responses.
This is elegantly handled by the requests library, but not urllib that we have
to use here, so I have to manually handle it by parsing the exception to
get the Location header, and then retrying the request there.

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
2021-10-12 17:29:22 +02:00
Massimiliano Culpo
551120ee0b
ASP-based solver: decrease the priority of multi-valued variant optimization for root (#26677)
The ASP-based solver maximizes the number of values in multi-valued
variants (if other higher order constraints are met), to avoid cases
where only a subset of the values that have been specified on the
command line or imposed by another constraint are selected.

Here we swap the priority of this optimization target with the
selection of the default providers, to avoid unexpected results
like the one in #26598
2021-10-12 14:15:48 +02:00
Harmen Stoppels
c2bf585d17
Fix potentially broken shutil.rmtree in tests (#26665)
Seems like https://bugs.python.org/issue29699 is relevant. Better to
just ignore errors when removing them tmpdir. The OS will remove it
anyways.

Errors are happening randomly from tests that are using this fixture.
2021-10-12 14:01:52 +02:00
Harmen Stoppels
0c0831861c
Avoid quadratic complexity in log parser (#26568)
TL;DR: there are matching groups trying to match 1 or more occurrences of
something. We don't use the matching group. Therefore it's sufficient to test
for 1 occurrence. This reduce quadratic complexity to linear time.

---

When parsing logs of an mpich build, I'm getting a 4 minute (!!) wait
with 16 threads for regexes to run:

```
In [1]: %time p.parse("mpich.log")
Wall time: 4min 14s
```

That's really unacceptably slow... 

After some digging, it seems a few regexes tend to have `O(n^2)` scaling
where `n` is the string / log line length. I don't think they *necessarily*
should scale like that, but it seems that way. The common pattern is this

```
([^:]+): error
```

which matches `: error` literally, and then one or more non-colons before that. So
for a log line like this:

```
abcdefghijklmnopqrstuvwxyz: error etc etc
```

Any of these are potential group matches when using `search` in Python:

```
abcdefghijklmnopqrstuvwxyz
 bcdefghijklmnopqrstuvwxyz
  cdefghijklmnopqrstuvwxyz
                         ⋮
                        yz
                         z
```

but clearly the capture group should return the longest match.

My hypothesis is that Python has a very bad implementation of `search`
that somehow considers all of these, even though it can be implemented
in linear time by scanning for `: error` first, and then greedily expanding
the longest possible `[^:]+` match to the left. If Python indeed considers
all possible matches, then with `n` matches of length `1 .. n` you
see the `O(n^2)` slowness (i verified this by replacing + with {1,k}
and doubling `k`, it doubles the execution time indeed).

This PR fixes this by removing the `+`, so effectively changing the 
O(n^2) into a O(n) worst case.

The reason we are fine with dropping `+` is that we don't use the
capture group anywhere, so, we just ensure `:: error` is not a match
but `x: error` is.

After going from O(n^2) to O(n), the 15MB mpich build log is parsed
in `1.288s`, so about 200x faster.

Just to be sure I've also updated `^CMake Error.*:` to `^CMake Error`,
so that it does not match with all the possible `:`'s in the line.
Another option is to use `.*?` there to make it quit scanning as soon as
possible, but what line that starts with `CMake Error` that does not have
a colon is really a false positive...
2021-10-12 00:05:11 -07:00
Michael Kuhn
d1f3279607
installer: Support showing status information in terminal title (#16259)
Installing packages with a lot of dependencies does not have an easy way
of judging the current progress (apart from running `spack spec -I pkg`
in another terminal). This change allows Spack to update the terminal's
title with status information, including its current progress as well as
information about the current and total number of packages.
2021-10-11 17:54:59 +02:00
Harmen Stoppels
89220bc0e1
Only install env modifications in <prefix>/.spack (#24081)
- Do not store the full list of environment variables in
  <prefix>/.spack/spack-build-env.txt because it may contain user secrets.

- Only store environment variable modifications upon installation.

- Variables like PATH may still contain user and system paths to make
  spack-build-env.txt sourceable. Variables containing paths are
  modified through prepending/appending, and if we don't apply these
  to the current environment variable, we end up with statements like
  `export PATH=/path/to/spack/bin` with system paths missing, meaning
  no system binaries are in the path, which is a bad user experience.

- Do write the full environment to spack-build-env.txt in the staging dir,
  but ensure it is readonly for the current user, to make it a bit safer
  on shared systems.
2021-10-11 09:07:45 -05:00
Harmen Stoppels
c0c9ab113e
Add spack env activate --temp (#25388)
Creates an environment in a temporary directory and activates it, which
is useful for a quick ephemeral environment:

```
$ spack env activate -p --temp
[spack-1a203lyg] $ spack add zlib
==> Adding zlib to environment /tmp/spack-1a203lyg
==> Updating view at /tmp/spack-1a203lyg/.spack-env/view
```
2021-10-11 06:56:03 -04:00
Harmen Stoppels
f28b08bf02
Remove unused --dependencies flag (#25731) 2021-10-11 10:16:11 +02:00
Massimiliano Culpo
2386630e10
Remove DB reindex during a read operation (#26601)
The DB should be what is trusted for certain operations.
If it is not present when read we should assume the
corresponding store is empty, rather than trying a
write operation during a read.

* Add a unit test
* Document what needs to be there in tests
2021-10-08 22:35:23 +00:00
Harmen Stoppels
7d89a95028
Fix leaky spack.binary_distribution.binary_index in tests (#26609)
* Fix issues with leaky binary index across tests

* More rigorous binary_index reset as now other tests are failing :(
2021-10-08 13:41:47 -04:00
Tamara Dahlgren
7f2611a960
Allow Version('') and map it to the empty tuple (#25953) 2021-10-08 10:36:54 +02:00
Daniel G Travieso
10de12c7d0
add hash field to spec on find --json and assert in test its there (#26443)
Co-authored-by: Daniel Travieso <daniel@dgtravieso.com>
2021-10-07 23:50:05 -07:00
Paul Ferrell
0b9914e2f5
Fix for license symlinking issue. (#26576)
When a symlink to a license file exists but is broken, the license symlink post-install hook fails
because os.path.exists() checks the existence of the target not the symlink itself.
os.path.lexists() is the proper function to use.
2021-10-07 19:18:35 +00:00
Scott Wittenburg
0561af1975
Pipelines: retry service job on system errors (#26508)
Retry rebuild-index, cleanup, and no-op jobs automatically if they fail
due to infrastructure-related problems.
2021-10-07 08:59:51 -06:00
Harmen Stoppels
05834e7c9d
Memoize the result of spack.platforms.host() (#26573) 2021-10-07 14:04:05 +02:00
Tamara Dahlgren
affd2236e6
Provide more info in SbangPathError to aid CI debugging (#26316) 2021-10-06 21:03:33 +02:00
Massimiliano Culpo
98ee00b977
Restore the correct computation of stores in environments (#26560)
Environments push/pop scopes upon activation. If some lazily
evaluated value depending on the current configuration was
computed and cached before the scopes are pushed / popped
there will be an inconsistency in the current state.

This PR fixes the issue for stores, but it would be better
to move away from global state.
2021-10-06 11:32:26 -07:00
Massimiliano Culpo
319ae9254e
Remove the spack.architecture module (#25986)
The `spack.architecture` module contains an `Arch` class that is very similar to `spack.spec.ArchSpec` but points to platform, operating system and target objects rather than "names". There's a TODO in the class since 2016:

abb0f6e27c/lib/spack/spack/architecture.py (L70-L75)

and this PR basically addresses that. Since there are just a few places where the `Arch` class was used, here we query the relevant platform objects where they are needed directly from `spack.platforms`. This permits to clean the code from vestigial logic.

Modifications:
- [x] Remove the `spack.architecture` module and replace its use by `spack.platforms`
- [x] Remove unneeded tests
2021-10-06 10:28:12 -07:00
Kevin Pedretti
47607dcac5
Use gnuconfig package for config file replacement for RISC-V. (#26364)
* Use gnuconfig package for config file replacement for RISC-V.

This extends the changes in #26035 to handle RISC-V. Before this change,
many packages fail to configure on riscv64 due to config.guess being too
old to know about RISC-V. This is seen out of the box when clingo fails
to build from source due to pkgconfig failing to configure, throwing
error: "configure: error: cannot guess build type; you must specify one".

* Add riscv64 architecture

* Update vendored archspec from upstream project.
These archspec updates include changes needed to support riscv64.

* Update archspec's __init__.py to reflect the commit hash of archspec being used.
2021-10-05 19:22:55 +00:00
Harmen Stoppels
d998ea1bd4
Move shell aware env into spack.environment.shell (#25608)
Cherry-picked from #25564 so this is standalone.

With this PR we can activate an environment in Spack itself, without computing changes to environment variables only necessary for "shell aware" env activation.

1. Activating an environment:
    
    ```python
    spack.environment.activate(Environment(xyz)) -> None
    ```
    this basically just sets `_active_environment` and modifies some config scopes.

2. Activating an environment **and** getting environment variable modifications for the shell:

    ```python
    spack.environment.shell.activate(Environment(xyz)) -> EnvironmentModifications
    ```

This should make it easier/faster to do unit tests and scripting with spack, without the cli interface.
2021-10-05 18:25:43 +00:00
Massimiliano Culpo
337b54fab0
Isolate bootstrap configuration from user configuration (#26071)
* Isolate bootstrap configuration from user configuration

* Search for build dependencies automatically if bootstrapping from sources

The bootstrapping logic will search for build dependencies
automatically if bootstrapping anything form sources. Any
external spec, if found, is written in a scope that is specific
to bootstrapping.

* Don't clean the bootstrap store with "spack clean -a"

* Copy bootstrap.yaml and config.yaml in the bootstrap area
2021-10-05 09:16:09 +02:00
Todd Gamblin
84c878b66a cc: make error messages more clear
- [x] Our wrapper error messages are sometimes hard to differentiate from other build
      output, so prefix all errors from `die()` with '[spack cc] ERROR:'

- [x] The error we raise when running, say, `fc` without a Fortran compiler was not
      clear enough. Clarify the message and the comment.
2021-10-04 18:30:19 -07:00
Todd Gamblin
052b2e1b08 cc: convert compiler wrapper to posix shell
This converts everything in cc to POSIX sh, except for the parts currently
handled with bash arrays. Tests are still passing.

This version tries to be as straightforward as possible. Specifically, most conversions
are kept simple -- convert ifs to ifs, handle indirect expansion the way we do in
`setup-env.sh`, only mess with the logic in `cc`, and don't mess with the python code at
all.

The big refactor is for arrays. We can't rely on bash's nice arrays and be ignorant of
separators anymore. So:

1. To avoid complicated separator logic, there are three types of lists. They are:

    * `$lsep`-separated lists, which end with `_list`. `lsep` is customizable, but we
      picked `^G` (alarm bell) for `$lsep` because it's ASCII and it's unlikely that it
      would actually appear in any arguments. If we need to get fancier (and I will lose
      faith in the world if we do) then we could consider XON or XOFF.
    * `:`-separated directory lists, which end with `_dirs`, `_DIRS`, `PATH`, or `PATHS`
    * Whitespace-separated lists (like flags), which can have any other name.

    Whitespace and colon-separated lists come with the territory with PATHs from env
    vars and lists of flags. `^G` separated lists are what we use for most internal
    variables, b/c it's more likely to work.

2. To avoid subshells, use a bunch of functions that do dirty `eval` stuff instead. This
   adds 3 functions to deal with lists:

    * `append LISTNAME ELEMENT [SEP]` will put `ELEMENT` at the end of the list called
      `LISTNAME`. You can optionally say what separator you expect to use. Note that we
      are taking advantage of everything being global and passing lists by name.

    * `prepend LISTNAME ELEMENT [SEP]` like append, but puts `ELEMENT` at the start of
      `LISTNAME`

    * `extend LISTNAME1 LISTNAME2 [PREFIX]` appends everything in LISTNAME2 to
       LISTNAME1, and optionally prepends `PREFIX` to every element (this is useful for
       things like `-I`, `-isystem `, etc.

    * `preextend LISTNAME1 LISTNAME2 [PREFIX]` prepends everything in LISTNAME2 to
       LISTNAME1 in order, and optionally prepends `PREFIX` to every element.

The routines determine the separator for each argument by its name, so we don't have to
pass around separators everywhere. Amazingly, as long as you do not expand variables'
values within an `eval` environment, you can do all this and still preserve quoting.
When iterating over lists, the user of this API still has to set and unset `IFS`
properly.

We ended up having to ignore shellcheck SC2034 (unused variable), because using evals
all over the place means that shellcheck doesn't notice that our list variables are
actually used.

So far this is looking pretty good. I took the most complex unit test I could find
(which runs a sample link line) and ran the same command line 200 times in a shell
script.  Times are roughly as follows:

For this invocation:

```console
$ bash -c 'time (for i in `seq 1 200`; do ~/test_cc.sh > /dev/null; done)'
```

I get the following performance numbers (the listed shells are what I put in `cc`'s
shebang):

**Original**
* Old version of `cc` with arrays and `bash v3.2.57` (macOS builtin): `4.462s` (`.022s` / call)
* Old version of `cc` with arrays and `bash v5.1.8` (Homebrew): `3.267s` (`.016s` / call)

**Using many subshells (#26408)**
*  with `bash v3.2.57`: `25.302s` (`.127s` / call)
*  with `bash v5.1.8`: `27.801s` (`.139s` / call)
*  with `dash`: `15.302s` (`.077s` / call)

This version didn't seem to work with zsh.

**This PR (no subshells)**
*  with `bash v3.2.57`: `4.973s` (`.025s` / call)
*  with `bash v5.1.8`: `4.984s` (`.025s` / call)
*  with `zsh`: `2.995s` (`.015s` / call)
*  with `dash`: `1.890s` (`.0095s` / call)

Dash, with the new posix design, is easily the winner.

So there are several interesting things to note here:

1. Running the posix version in `bash` is slower than using `bash` arrays. That is to be
   expected because it's doing a bunch of string processing where it likely did not have
   to before, at least in `bash`.

2. `zsh`, at least on macOS, is significantly faster than the ancient `bash` they ship
   with the system. Using `zsh` with the new version also makes the posix wrappers
   faster than `develop`. So it's worth preferring `zsh` if we have it. I suppose we
   should also try this with newer `bash` on Linux.

3. `bash v5.1.8` seems to be significantly faster than the old system `bash v3.2.57` for
   arrays. For straight POSIX stuff, it's a little slower. It did not seem to matter
   whether `--posix` was used.

4. `dash` is way faster than `bash` or `zsh`, so the real payoff just comes from being
   able to use it. I am not sure if that is mostly startup time, but it's significant.
   `dash` is ~2.4x faster than the original `bash` with arrays.

So, doing a lot of string stuff is slower than arrays, but converting to posix seems
worth it to be able to exploit `dash`.

- [x] Convert all but array-related portions to sh
- [x] Fix basic shellcheck issues.
- [x] Convert arrays to use a few convenience functions: `append` and `extend`
- [x] Get `cc` tests passing.
- [x] Add `cc` tests where needed passing.
- [x] Benchmarking.

Co-authored-by: Tom Scogland <scogland1@llnl.gov>
Co-authored-by: Danny McClanahan <1305167+cosmicexplorer@users.noreply.github.com>
2021-10-04 18:30:19 -07:00
Tamara Dahlgren
5a9e5ddb3d
Stand-alone tests: distinguish NO-TESTS from PASSED (#25880)
Co-authored-by: Seth R. Johnson <johnsonsr@ornl.gov>
2021-10-04 19:57:08 +00:00
Pedro Demarchi Gomes
90fa50d9df
Avoid replacing symlinked spack.yaml when concretizing an environment (#26428) 2021-10-04 14:59:03 +00:00
Andreas Baumbach
35dd474473
Improve an error message in stage.py (#23737) 2021-10-04 14:47:14 +02:00
Dylan Simon
9926799aeb
Fix NonVirtualInHierarchyError message format (#26008) 2021-10-04 10:38:09 +02:00
Massimiliano Culpo
69abc4d860
Build ppc64le docker images (#26442)
* Update archspec
* Add ppc64le to docker images
2021-10-04 09:34:53 +02:00
Massimiliano Culpo
e91815de7c
Update Spec.full_hash docstring (#26456)
The docstring is outdated since #21735
when the build hash has been included
in the full hash.
2021-10-04 07:33:22 +00:00
Jordan Galby
0d6a2381b2
Fix JSONDecodeError when using compiler modules (#25624)
When using modules for compiler (and/or external package), if a
package's `setup_[dependent_]build_environment` sets `PYTHONHOME`, it
can influence the python subprocess executed to gather module
information.

The error seen was:

```
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
```

But the actual hidden error happened in the `python -c 'import
json...'` subprocess, which made it return an empty string as json:

```
ModuleNotFoundError: No module named 'encodings'
```

This fix uses `python -E` to ignore `PYTHONHOME` and
`PYTHONPATH`. Should be safe here because the python subprocess code
only use packages built-in python.

The python subprocess in `environment.py` was also patched to be safe
and consistent.
2021-10-03 16:10:33 +02:00
Harmen Stoppels
b9e72557e8
Remove .99 from version ranges (#26422)
In most cases, .99 can be omitted thanks to #26402 .
2021-10-03 09:09:02 -04:00
Harmen Stoppels
d0e49ae4bb
Simplify setup_package in build environment (#26070)
* Remove redundant preserve environment code in build environment

* Remove fix for a bug in a module

See https://github.com/spack/spack/issues/3153#issuecomment-280460041,
this shouldn't be part of core spack.

* Don't module unload cray-libsci on all platforms
2021-10-01 19:41:30 -04:00
Cory Bloor
b6169c213d
Fix error message when test throws AttributeError (#25895)
Narrow the scope of the try/except block, to avoid a misleading
error message if fn() throws an AttributeError.
2021-10-01 19:40:24 -04:00
Harmen Stoppels
50feaae81c
Allow non-empty ranges 1.1.0:1.1 (#26402) 2021-10-01 12:23:26 -07:00
Harmen Stoppels
18760de972
Spack install: handle failed restore of backup (#25647)
Spack has logic to preserve an installation prefix when it is being
overwritten: if the new install fails, the old files are restored.
This PR adds error handling for when this backup restoration fails
(i.e. the new install fails, and then some unexpected error prevents
restoration from the backup).
2021-10-01 11:40:48 -07:00
Scott Wittenburg
4637c51c7f Service jobs do not need an active environment 2021-10-01 10:12:37 -07:00
Anna Masalskaya
8fc770608d
Add oneAPI packages from 2021.4 release (#26401) 2021-10-01 15:58:32 +02:00
Harmen Stoppels
5b9f60f9bb
bootstrapping: improve error messages (#26399) 2021-10-01 13:00:14 +02:00
Tamara Dahlgren
2d1ebbe0a2
Add info command tests to increase coverage (#26127) 2021-09-30 22:13:45 -04:00
Tamara Dahlgren
7aedeca764
Replace spec-related install_test asserts with exceptions; added unit tests (#25982) 2021-09-30 22:05:06 -04:00
Massimiliano Culpo
74d36076c2
ArchSpec: minor cleanup of a few methods (#26376)
* Remove vestigial code to be compatible with Spack v0.9.X
* ArchSpec: reworked __repr__ to be more adherent to common Python idioms
* ArchSpec: simplified __init__.py and copy()
2021-09-30 16:03:39 -07:00
Harmen Stoppels
1aa7758dbb
match .spack literal, not as a regex (#26374) 2021-09-30 14:54:57 +00:00
Harmen Stoppels
525aa11827
Bump version from v0.16.2 to v0.16.3 (#26372) 2021-09-30 11:54:48 +00:00
David Beckingsale
d31830eaf5
Move new CUDA conflicts inside when('~allow-unsupported-compilers') block (#26132)
* Move new CUDA conflicts inside when('~allow-unsupported-compilers') block

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
2021-09-30 00:22:26 +00:00
Harmen Stoppels
9d39a1bf42
Un-unset TERM and DISPLAY (#26326)
For interactive `spack build-env`'s this is undesired behavior
2021-09-29 16:28:32 +02:00
Massimiliano Culpo
aa8727f6f9
Move detection logic in its own package (#26119)
The logic to perform detection of already installed
packages has been extracted from cmd/external.py
and put into the spack.detection package.

In this way it can be reused programmatically for
other purposes, like bootstrapping.

The new implementation accounts for cases where the
executables are placed in a subdirectory within <prefix>/bin
2021-09-28 09:05:49 +02:00
Harmen Stoppels
87450f3688
Use gnuconfig package for config file replacement (#26035)
* Use gnuconfig package for config file replacement

Currently the autotools build system tries to pick up config.sub and
config.guess files from the system (in /usr/share) on arm and power.
This is introduces an implicit system dependency which we can avoid by
distributing config.guess and config.sub files in a separate package,
such as the new `gnuconfig` package which is very lightweight/text only
(unlike automake where we previously pulled these files from as a
backup). This PR adds `gnuconfig` as an unconditional build dependency
for arm and power archs.

In case the user needs a system version of config.sub and config.guess,
they are free to mark `gnuconfig` as an external package with the prefix
pointing to the directory containing the config files:

```yaml
    gnuconfig:
      externals:
      - spec: gnuconfig@master
        prefix: /tmp/tmp.ooBlkyAKdw/lol
      buildable: false
```

Apart from that, this PR gives some better instructions for users when
replacing config files goes wrong.

* Mock needs this package too now, because autotools adds a depends_on

* Add documentation

* Make patch_config_files a prop, fix the docs, add integrations tests

* Make macOS happy
2021-09-27 18:38:14 -04:00
psakievich
df9d1dd1cb
Correct path comparisons for fs view (#25891)
* Fix path comparisons in copy views

* Get correct permissions

* Set group id though os

Co-authored-by: Philip Sakievich <psakiev@sanida.gov>
2021-09-27 09:51:38 -07:00
bernhardkaindl
6ccda81368
log_parser.py: Find failed test case messages in error logs (#25694)
- Match failed autotest tests show the word "FAILED" near the end
- Match "FAIL: ", "FATAL: ", "failed ", "Failed test" of other suites
- autotest "   ok"$ means the test passed, independend of text before.
- autoconf messages showing missing tools are fatal later, show them.
2021-09-26 10:35:04 +02:00
bernhardkaindl
ff511e090a
autotools doc PR: No depends_on('m4') with depends_on('autoconf') (#26101)
* autotoolspackage.rst: No depends_on('m4') with depends_on('autoconf')
  - Remove `m4` from the example depends_on() lines for the autoreconf phase.
  - Change the branch used as example from develop to master as it is
    far more common in the packages of spack's builtin repo.
- Fix the wrong info that libtoolize and aclocal are run explicitly
  in the autoreconf phase by default. autoreconf calls these internally
  as needed, thus autotools.py also does not call them directly.
- Add that autoreconf() also adds -I<aclocal-prefix>/share/aclocal.
- Add an example how to set autoreconf_extra_args.
- Add an example of a custom autoreconf phase for running autogen.sh.

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
2021-09-25 10:15:03 +02:00
bernhardkaindl
cdbb586a93
autotools.py/autoreconf: Show the depends_on()s to add to the package (#26115)
This commit shows a template for cut-and-paste into the package to fix it:

```py
==> fast-global-file-status: Executing phase: 'autoreconf'
==> Error: RuntimeError: Cannot generate configure: missing dependencies autoconf, automake, libtool.

Please add the following lines to the package:

    depends_on('autoconf', type='build', when='@master')
    depends_on('automake', type='build', when='@master')
    depends_on('libtool', type='build', when='@master')

Update the version (when='@master') as needed.
```
    
Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
2021-09-24 09:17:07 -06:00
Harmen Stoppels
a6bb3a66ea
Remove centos:6 image references (#26095)
This was EOL November 30th, 2020. I believe the "builds" are failing on
develop because of it.
2021-09-24 09:47:49 +02:00
bernhardkaindl
979c355c99
spack/build_environment.py: Clean MAKEFLAGS, DISPLAY and TERM (#26092)
clean_environment(): Unset three more environment variables:

MAKEFLAGS: Affects make, can eg indirectly inhibit enabling parallel build
DISPLAY: Tests of GUI widget libraries might try to connect to an X server
TERM: Could make testsuites attempt to color their output
2021-09-22 00:23:10 +02:00
Tamara Dahlgren
c3cb863b82
Feature: Add deprecated versions section to spack info output (#25972) 2021-09-21 11:49:36 -07:00
Harmen Stoppels
58663692a4
Rename 'variant_name' to 'variant' and document it in autotools build system (#26064) 2021-09-21 11:27:41 +02:00
iarspider
ca8d16c9d1
Allow setting variant name in AutotoolsPackage._activate_or_not (#26054) 2021-09-20 10:54:24 +02:00
Adam J. Stewart
c0839b14d5
Python: use platform-specific site packages dir (#25998) 2021-09-19 00:37:50 +00:00
Massimiliano Culpo
b847bb72f0
Bootstrap should search for compilers after switching config scopes (#26029)
fixes #25992

Currently the bootstrapping process may need a compiler.

When bootstrapping from sources the need is obvious, while
when bootstrapping from binaries it's currently needed in
case patchelf is not on the system (since it will be then
bootstrapped from sources).

Before this PR we were searching for compilers as the
first operation, in case they were not declared in
the configuration. This fails in case we start
bootstrapping from within an environment.

The fix is to defer the search until we have swapped
configuration.
2021-09-17 18:28:48 -06:00
Michael Kuhn
2d34acf29e
cc: Use parameter expansion instead of basename (#24509)
While debugging #24508, I noticed that we call `basename` in `cc`. The
same can be achieved by using Bash's parameter expansion, saving one
external process per call.

Parameter expansion cannot replace basename for directories in some
cases, but is guaranteed to work for executables.
2021-09-16 16:25:49 +00:00
Michael Kuhn
d73fe19d93
Recommend Git's manyFiles feature (#25977)
Git 2.24 introduced a feature flag for repositories with many files, see:
https://github.blog/2019-11-03-highlights-from-git-2-24/#feature-macros

Since Spack's Git repository contains roughly 8,500 files, it can be
worthwhile to enable this, especially on slow file systems such as NFS:
```
$ hyperfine --warmup 3 'cd spack-default; git status' 'cd spack-manyfiles; git status'
Benchmark #1: cd spack-default; git status
  Time (mean ± σ):      3.388 s ±  0.095 s    [User: 256.2 ms, System: 625.8 ms]
  Range (min … max):    3.168 s …  3.535 s    10 runs

Benchmark #2: cd spack-manyfiles; git status
  Time (mean ± σ):     168.7 ms ±  10.9 ms    [User: 98.6 ms, System: 126.1 ms]
  Range (min … max):   144.8 ms … 188.0 ms    19 runs

Summary
  'cd spack-manyfiles; git status' ran
   20.09 ± 1.42 times faster than 'cd spack-default; git status'
```
2021-09-16 09:41:10 -06:00
Massimiliano Culpo
fa6366a7df
Add a deprecation warning when using the old concretizer (#25966) 2021-09-16 13:25:24 +02:00
Harmen Stoppels
ccfdac8402
Improve bootstrapping docs a hair (#25962) 2021-09-16 07:02:31 -04:00
Harmen Stoppels
abb0f6e27c
Fix NameError in foreground/background test (#25967) 2021-09-16 10:39:07 +02:00
Harmen Stoppels
3fe9b34362
Inform the user about bootstrapping (#25964) 2021-09-16 09:28:24 +02:00
Tamara Dahlgren
f0b4afe7db
Raise exception when 1+ stand-alone tests fail (#25857) 2021-09-15 08:04:59 -04:00
Massimiliano Culpo
c52426ea7a
Make clingo the default solver (#25502)
Modifications:
- [x] Change `defaults/config.yaml`
- [x] Add a fix for bootstrapping patchelf from sources if `compilers.yaml` is empty
- [x] Make `SPACK_TEST_SOLVER=clingo` the default for unit-tests
- [x] Fix package failures in the e4s pipeline

Caveats:
1. CentOS 6 still uses the original concretizer as it can't connect to the buildcache due to issues with `ssl` (bootstrapping from sources requires a C++14 capable compiler)
1. I had to update the image tag for GitlabCI in e699f14.  
1. libtool v2.4.2 has been deprecated and other packages received some update
2021-09-14 22:44:16 -07:00
Adam J. Stewart
0d0d438c11
Add a __reduce__ method to Environment (#25678)
* Add a __reduce__ method to Environment
* Add unit test
* Convert Path to str
2021-09-14 22:37:36 -07:00
Vanessasaurus
ef5ad4eb34
Adding ability to compare git references to spack install (#24639)
This will allow a user to (from anywhere a Spec is parsed including both name and version) refer to a git commit in lieu of 
a package version, and be able to make comparisons with releases in the history based on commits (or with other commits). We do this by way of:

 - Adding a property, is_commit, to a version, meaning I can always check if a version is a commit and then change some action.
 - Adding an attribute to the Version object which can lookup commits from a git repo and find the last known version before that commit, and the distance
 - Construct new Version comparators, which are tuples. For normal versions, they are unchanged. For commits with a previous version x.y.z, d commits away, the comparator is (x, y, z, '', d). For commits with no previous version, the comparator is ('', d) where d is the distance from the first commit in the repo.
 - Metadata on git commits is cached in the misc_cache, for quick lookup later.
 - Git repos are cached as bare repos in `~/.spack/git_repos`
 - In both caches, git repo urls are turned into file paths within the cache

If a commit cannot be found in the cached git repo, we fetch from the repo. If a commit is found in the cached metadata, we do not recompare to newly downloaded tags (assuming repo structure does not change). The cached metadata may be thrown out by using the `spack clean -m` option if you know the repo structure has changed in a way that invalidates existing entries. Future work will include automatic updates.

# Finding previous versions
Spack will search the repo for any tags that match the string of a version given by the `version` directive. Spack will also search for any tags that match `v + string` for any version string. Beyond that, Spack will search for tags that match a SEMVER regex (i.e., tags of the form x.y.z) and interpret those tags as valid versions as well. Future work will increase the breadth of tags understood by Spack

For each tag, Spack queries git to determine whether the tag is an ancestor of the commit in question or not. Spack then sorts the tags that are ancestors of the commit by commit-distance in the repo, and takes the nearest ancestor. The version represented by that tag is listed as the previous version for the commit.

Not all commits will find a previous version, depending on the package workflow. Future work may enable more tangential relationships between commits and versions to be discovered, but many commits in real world git repos require human knowledge to associate with a most recent previous version. Future work will also allow packages to specify commit/tag/version relationships manually for such situations.

# Version comparisons.
The empty string is a valid component of a Spack version tuple, and is in fact the lowest-valued component. It cannot be generated as part of any valid version. These two characteristics make it perfect for delineating previous versions from distances. For any version x.y.z, (x, y, z, '', _) will be less than any "real" version beginning x.y.z. This ensures that no distance from a release will cause the commit to be interpreted as "greater than" a version which is not an ancestor of it.

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

Co-authored-by: vsoch <vsoch@users.noreply.github.com>
Co-authored-by: Gregory Becker <becker33@llnl.gov>
Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2021-09-14 22:12:34 -07:00
Vanessasaurus
c6edfa3f31
Update spack monitor to support new spec (#25928)
This PR coincides with tiny changes to spack to support spack monitor using the new spec
the corresponding spack monitor PR is at https://github.com/spack/spack-monitor/pull/31.
Since there are no changes to the database we can actually update the current server
fairly easily, so either someone can test locally or we can just update and then
test from that (and update as needed).

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

Co-authored-by: vsoch <vsoch@users.noreply.github.com>
2021-09-14 08:02:04 -06:00
Greg Becker
dad69e7d7c
Fix environment reading from lockfile to trust written hashes (#25879)
#22845 revealed a long-standing bug that had never been triggered before, because the
hashing algorithm had been stable for multiple years while the bug was in production. The
bug was that when reading a concretized environment, Spack did not properly read in the
build hashes associated with the specs in the environment. Those hashes were recomputed
(and as long as we didn't change the algorithm, were recomputed identically). Spack's
policy, though, is never to recompute a hash. Once something is installed, we respect its
metadata hash forever -- even if internally Spack changes the hashing method. Put
differently, once something is concretized, it has a concrete hash, and that's it -- forever.

When we changed the hashing algorithm for performance in #22845 we exposed the bug.
This PR fixes the bug at its source, but properly reading in the cached build hash attributes
associated with the specs. I've also renamed some variables in the Environment class
methods to make a mistake of this sort more difficult to make in the future.

* ensure environment build hashes are never recomputed
* add comment clarifying reattachment of env build hashes
* bump lockfile version and include specfile version in env meta
* Fix unit-test for v1 to v2 conversion

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2021-09-13 15:25:48 -06:00
Massimiliano Culpo
e9f1cfdaaf
Avoid hidden circular dependencies in spack.architecture (#25873)
* Refactor platform etc. to avoid circular dependencies

All the base classes in spack.architecture have been
moved to the corresponding specialized subpackages,
e.g. Platform is now defined within spack.platforms.

This resolves a circular dependency where spack.architecture
was both:
- Defining the base classes for spack.platforms, etc.
- Collecting derived classes from spack.platforms, etc.
Now it dopes only the latter.

* Move a few platform related functions to "spack.platforms"

* Removed spack.architecture.sys_type()

* Fixup for docs

* Rename Python modules according to review
2021-09-13 11:04:42 -07:00
Tamara Dahlgren
a1d792af4c
Bugfix: Correct checksum's sha256 when retrieve from remote (#25831) 2021-09-13 08:08:00 +00:00
Tamara Dahlgren
5fa075f5b4
Bugfix: spack test debug requires Spack tty (#25897) 2021-09-13 08:57:16 +02:00
Stephen McDowell
3a9028427c
[docs] document official gfortran macOS precompiled binaries (#25818)
* document official gfortran macOS precompiled binaries

* compile without -vvv ;) {squash this}
2021-09-10 14:11:26 -05:00
Harmen Stoppels
729726d157
Remove dead code in installer (#24035)
Currently as part of installing a package, we lock a prefix, check if
it exists, and create it if not; the logic for creating the prefix
included a check for the existence of that prefix (and raised an
exception if it did), which was redundant.

This also includes removal of tests which were not verifying
anything (they pass with or without the modifications in this PR).
2021-09-10 11:32:46 -07:00
albestro
59d8031076
CUDA official GCC conflicts (#25054)
* update CUDA 11 / GCC compatibility range

* additional unofficial conflict

* minor changes to comments
2021-09-09 15:03:16 -07:00
Massimiliano Culpo
5fddd48f80
Refactor unit-tests in test/architecture.py (#25848)
Modifications:
- Export platforms from spack.platforms directly, so that client modules don't have to import submodules
- Use only plain imports in test/architecture.py
- Parametrized test in test/architecture.py and put most of the setup/teardown in fixtures
2021-09-09 09:34:47 -06:00
Nathan Hanford
d83f7110d5
specs: move to new spec.json format with build provenance (#22845)
This is a major rework of Spack's core core `spec.yaml` metadata format.  It moves from `spec.yaml` to `spec.json` for speed, and it changes the format in several ways. Specifically:

1. The spec format now has a `_meta` section with a version (now set to version `2`).  This will simplify major changes like this one in the future.
2. The node list in spec dictionaries is no longer keyed by name. Instead, it is a list of records with no required key. The name, hash, etc. are fields in the dictionary records like any other.
3. Dependencies can be keyed by any hash (`hash`, `full_hash`, `build_hash`).
4. `build_spec` provenance from #20262 is included in the spec format. This means that, for spliced specs, we preserve the *full* provenance of how to build, and we can reproduce a spliced spec from the original builds that produced it.

**NOTE**: Because we have switched the spec format, this PR changes Spack's hashing algorithm.  This means that after this commit, Spack will think a lot of things need rebuilds.

There are two major benefits this PR provides:
* The switch to JSON format speeds up Spack significantly, as Python's builtin JSON implementation is orders of magnitude faster than YAML. 
* The new Spec format will soon allow us to represent DAGs with potentially multiple versions of the same dependency -- e.g., for build dependencies or for compilers-as-dependencies.  This PR lays the necessary groundwork for those features.

The old `spec.yaml` format continues to be supported, but is now considered a legacy format, and Spack will opportunistically convert these to the new `spec.json` format.
2021-09-09 01:48:30 -07:00
Massimiliano Culpo
e47f0d486c Account for bootstrapping from sources niche case
This modification accounts for:
1. Bootstrapping from sources using system, non-standard Python
2. Using later an ABI compatible standard Python interpreter
2021-09-08 11:13:37 -07:00
Massimiliano Culpo
fd0884c273 Fix clingo bootstrapping on rhel + ppc64le
The system Python interpreter on rhel is patched to have
slightly different names for some architectures. This
makes it incompatible with manylinux generated extensions
for ppc64le.

To fix this issue when bootstrapping Spack we generate
on-the-fly symbolic links to the name expected by the
current interpreter if it differs from the default.

Links:
  https://github.com/pypa/manylinux/issues/687
  https://src.fedoraproject.org/fork/churchyard/rpms/python3/blame/00274-fix-arch-names.patch?identifier=test_email-mktime
2021-09-08 11:13:37 -07:00
Massimiliano Culpo
4033cc0250 Disable module generation during bootstrapping 2021-09-08 11:13:16 -07:00
Todd Gamblin
c309adb4b3
url stats: add --show-issues option (#25792)
* tests: make `spack url [stats|summary]` work on mock packages

Mock packages have historically had mock hashes, but this means they're also invalid
as far as Spack's hash detection is concerned.

- [x] convert all hashes in mock package to md5 or sha256
- [x] ensure that all mock packages have a URL
- [x] ignore some special cases with multiple VCS fetchers

* url stats: add `--show-issues` option

`spack url stats` tells us how many URLs are using what protocol, type of checksum,
etc., but it previously did not tell us which packages and URLs had the issues. This
adds a `--show-issues` option to show URLs with insecure (`http`) URLs or `md5` hashes
(which are now deprecated by NIST).
2021-09-08 07:59:06 -07:00
bernhardkaindl
4e4b199f16
lib/spack/env/cc: tolerate trailing / in elements of $PATH (#25733)
Fixes removal of SPACK_ENV_PATH from PATH in the presence of trailing
slashes in the elements of PATH:

The compiler wrapper has to ensure that it is not called nested like
it would happen when gcc's collect2 uses PATH to call the linker ld,
or else the compilation fails.

To prevent nested calls, the compiler wrapper removes the elements
of SPACK_ENV_PATH from PATH.

Sadly, the autotest framework appends a slash to each element
of PATH when adding AUTOTEST_PATH to the PATH for the tests,
and some tests like those of GNU bison run cc inside the test.

Thus, ensure that PATH cleanup works even with trailing slashes.

This fixes the autotest suite of bison, compiling hundreds of
bison-generated test cases in a autotest-generated testsuite.

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
2021-09-08 12:09:07 +02:00
Stephen McDowell
83298160cc
docs: minor grammar fix (#25814) 2021-09-07 09:51:14 +00:00
Harmen Stoppels
64407e253c Always disable leftover active environment after tests 2021-09-03 07:27:19 -07:00
Harmen Stoppels
de492e73d5 Don't error when removing scope that does not exist 2021-09-03 07:27:19 -07:00
Vanessasaurus
8e61f54260
start of work to add spack audit packages-https checker (#25670)
This PR will add a new audit, specifically for spack package homepage urls (and eventually
other kinds I suspect) to see if there is an http address that can be changed to https.

Usage is as follows:

```bash
$ spack audit packages-https <package>
```
And in list view:

```bash
$ spack audit list
generic:
  Generic checks relying on global variables

configs:
  Sanity checks on compilers.yaml
  Sanity checks on packages.yaml

packages:
  Sanity checks on specs used in directives

packages-https:
  Sanity checks on https checks of package urls, etc.
```

I think it would be unwise to include with packages, because when run for all, since we do requests it takes a long time. I also like the idea of more well scoped checks - likely there will be other addresses for http/https within a package that we eventually check. For now, there are two error cases - one is when an https url is tried but there is some SSL error (or other error that means we cannot update to https):

```bash
$ spack audit packages-https zoltan
PKG-HTTPS-DIRECTIVES: 1 issue found
1. Error with attempting https for "zoltan": 
    <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Hostname mismatch, certificate is not valid for 'www.cs.sandia.gov'. (_ssl.c:1125)>
```
This is either not fixable, or could be fixed with a change to the url or (better) contacting the site owners to ask about some certificate or similar.

The second case is when there is an http that needs to be https, which is a huge issue now, but hopefully not after this spack PR.

```bash
$ spack audit packages-https xman
Package "xman" uses http but has a valid https endpoint.
```

And then when a package is fixed:

```bash
$ spack audit packages-https zlib
PKG-HTTPS-DIRECTIVES: 0 issues found.
```
And that's mostly it. :)

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

Co-authored-by: vsoch <vsoch@users.noreply.github.com>
2021-09-02 08:46:27 +02:00
David Beckingsale
aabece46ba
Add variant to allow unsupported compiler & CUDA combinations (#19736)
Sometimes users need to be able to override the conflicts in `CudaPacakge`.  This introduces a variant to enable/disable them.
2021-09-01 11:34:20 -07:00
Harmen Stoppels
4c23059017
Speed-up two unit tests by using builtin.mock instead of builtin (#25544) 2021-09-01 11:58:29 +02:00
kwryankrattiger
9be81ac4d9
Add documentation on compiler environment (#25508) 2021-08-30 11:17:03 +02:00
Massimiliano Culpo
40788cf49a
Add a __reduce__ method to Spec (#25658)
* Add a __reduce__ method to Spec

fixes #23892

The recursion limit seems to be due to the default
way in which a Spec is serialized, following all
the attributes. It's still not clear to me why this
is related to being in an environment, but in any
case we already have methods to serialize Specs to
disk in JSON and YAML format. Here we use them to
pickle a Spec instance too.

* Downgrade to build-hash

Hopefully nothing will change the package in
between serializing the spec and sending it
to the child process.

* Add support for Python 2
2021-08-28 07:31:16 -07:00
Harmen Stoppels
f5ab3ad82a
Fix: --overwrite backs up old install dir, but it gets destroyed anyways (#25583)
* Make sure PackageInstaller does not remove the just-restored
  install dir after failure in spack install --overwrite
* Remove cryptic error message and rethrow actual error
2021-08-27 12:41:24 -07:00
Tamara Dahlgren
b5d3c48824
Load package environment prior to stand-alone/smoke test execution (#25619) 2021-08-27 18:46:26 +00:00
Jordan Galby
97ea57e59f
Add ld.gold and ld.lld compiler wrapper (#25626)
The gcc compiler can be configured to use `ld.gold` by default. It will
then call `ld.gold` explicitly when linking. When so, spack need to have
a ld.gold wrapper in PATH to inject rpaths link flags etc...

Also I wouldn't be surprised to see some package calling `ld.gold`
directly.

As for ld.gold, the argument could be made that we want to support any
package that could call ld.lld.
2021-08-27 13:16:26 +02:00
Massimiliano Culpo
c152e558e9
Make SpecBuildInterface pickleable (#25628)
* Add a __reduce__ method to SpecBuildInterface

This class was confusing pickle when being serialized,
due to its scary nature of being an object that disguise
as another type.

* Add more MacOS tests, switch them to clingo

* Fix condition syntax

* Remove Python v3.6 and v3.9 with macOS
2021-08-27 09:10:03 +00:00
Harmen Stoppels
74389472ab
Make env (de)activate error with -e, -E, -D flags (#25625)
* Make sure that spack -e. env activate b and spack -e. env deactivate error
* Add a test
2021-08-26 16:54:58 -07:00
Paul Kuberry
abfd8fa70b
Conditionally remove 'context' from kwargs in _urlopen (#25316)
* Conditionally remove 'context' from kwargs in _urlopen

Previously, 'context' is purged from kwargs in _urlopen to
conform to varying support for 'context' in different versions
of urllib. This fix tries to use 'context', and then removes
it if an exception is thrown and tries again.

* Specify error type in try statement in _urlopen

Specify TypeError when checking if 'context' is in kwargs
for _urlopen. Also, if try fails, check that 'context' is
in the error message before removing from kwargs.
2021-08-26 13:51:08 -07:00
Adam J. Stewart
6eb942cf45
Speedup environment activation, part 2 (#25633)
This is a direct followup to #13557 which caches additional attributes that were added in #24095 that are expensive to compute. I had to reopen #25556 in another PR to invalidate the GitLab CI cache, but see #25556 for prior discussion.

### Before

```console
$ time spack env activate .

real	2m13.037s
user	1m25.584s
sys	0m43.654s
$ time spack env view regenerate
==> Updating view at /Users/Adam/.spack/.spack-env/view

real	16m3.541s
user	10m28.892s
sys	4m57.816s
$ time spack env deactivate

real	2m30.974s
user	1m38.090s
sys	0m49.781s
```

### After
```console
$ time spack env activate .

real	0m8.937s
user	0m7.323s
sys	0m1.074s
$ time spack env view regenerate
==> Updating view at /Users/Adam/.spack/.spack-env/view

real	2m22.024s
user	1m44.739s
sys	0m30.717s
$ time spack env deactivate

real	0m10.398s
user	0m8.414s
sys	0m1.630s
```

Fixes #25555
Fixes #25541 

* Speedup environment activation, part 2
* Only query distutils a single time
* Fix KeyError bug
* Make vermin happy
* Manual memoize
* Add comment on cross-compiling
* Use platform-specific include directory
* Fix multiple bugs
* Fix python_inc discrepancy
* Fix import tests
2021-08-26 20:44:31 +00:00
Harmen Stoppels
23106ac0f5
Set pubkey trust to ultimate during gpg trust (#24976)
* Set pubkey trust to ultimate during `gpg trust`

Tries to solve the same problem as #24760 without surpressing stderr
from gpg commands.

This PR makes every imported key trusted in the gpg database.

Note: I've outlined
[here](https://github.com/spack/spack/pull/24760#issuecomment-883183175)
that gpg's trust model makes sense, since how can we trust a random
public key we download from a binary cache?

* Fix test
2021-08-26 12:59:44 -07:00
Massimiliano Culpo
29d1bc6546
Ensure environment are deactivated when bootstrapping (#25607)
Fixes #25603

This commit adds a new context manager to temporarily
deactivate active environments. This context manager
is used when setting up bootstrapping configuration to
make sure that the current environment is not affected
by operations on the bootstrap store.

* Preserve exit code 1 if nothing is found
* Use context manager for the environment
2021-08-26 12:20:05 -07:00
Tamara Dahlgren
8664abc178
Remove references to self.install_test_root from packaging guide (#25238) 2021-08-26 19:22:40 +02:00
Massimiliano Culpo
a3d8e95e76
Avoid double loop in subprocess_context.store_patches (#25621)
fixes #21643

As far as I can see the double loop is not needed, since
"patch" is never used and the items in the list are tuples
of three values.
2021-08-26 09:46:01 -07:00
Massimiliano Culpo
1ab6f30fdd
Remove fork_context from llnl.util.lang (#25620)
This object was introduced in #18124, and was later superseded by
#18205 and removed any use if the object.
2021-08-26 09:39:59 -07:00
Massimiliano Culpo
7dd3592eab
Regression test for version selection with preferences (#25602)
This commit adds a regression test for version selection
with preferences in `packages.yaml`. Before PR 25585 we
used negative weights in a minimization to select the
optimal version. This may lead to situations where a
dependency may make the version score of dependents
"better" if it is preferred in packages.yaml.
2021-08-26 09:28:47 -07:00
Harmen Stoppels
73005166ef
Bugfix: reinstalling updated develop specs (#25579)
PackageInstaller and Package.installed disagree over what it means
for a package to be installed: PackageInstaller believes it should be
enough for a database entry to exist, whereas Package.installed
requires a database entry & a prefix directory.

This leads to the following niche issue:

* a develop spec in an environment is successfully installed
* then somehow its install prefix is removed (e.g. through a bug fixed
  in #25583)
* you modify the sources and reinstall the environment
  1. spack checks pkg.installed and realizes the develop spec is NOT
     installed, therefore it doesn't need to have 'overwrite: true'
  2. the installer gets the build task and checks the database and
      realizes the spec IS installed, hence it doesn't have to install it.
  3. the develop spec is not rebuilt.

The solution is to make PackageInstaller and pkg.installed agree over
what it means to be installed, and this PR does that by dropping the
prefix directory check from pkg.installed, so that it only checks the
database.

As a result, spack will create a build task with overwrite: true for
the develop spec, and the installer in fact handles overwrite requests
fine even if the install prefix doesn't exist (it just does a normal
install).
2021-08-25 18:14:11 -07:00
Massimiliano Culpo
af2f07852c
environment: match concrete specs only if they have the same build hash (#25575)
see #25563

When we have a concrete environment and we ask to install a
concrete spec from a file, currently Spack returns a list of
specs that are all the one that match the argument DAG hash.

Instead we want to compare build hashes, which also account
for build-only dependencies.
2021-08-25 10:56:16 -07:00
Todd Gamblin
d27e0bff5a
installation: filter padding from binary installs, too (#25600)
#25303 filtered padding from build output, but it's still there in binary install/relocate output,
so our CI logs are still quite long and frequently hit the limit.

- [x] add context handler from #25303 to buildcache installation as well
2021-08-25 17:39:00 +02:00
Todd Gamblin
fafe1cb7e8
Make spack graph -i environment-aware (#25599)
This allows you to run `spack graph --installed` from within an environment and get a dot graph of
its concrete specs.

- [x] make `spack graph -i` environment-aware

- [x] add code to the generated dot graph to ensure roots have min rank (i.e., they're all at the
      top or left of the DAG)
2021-08-25 07:41:04 -07:00
Todd Gamblin
df10e88e97
bootstrap: use sys.exec_prefix to set up external python correctly (#25593)
Bootstrapping clingo on macOS on `develop` gives errors like this:

```
==> Error: RuntimeError: Unable to locate python command in /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/bin

/Users/gamblin2/Workspace/spack/var/spack/repos/builtin/packages/python/package.py:662, in command:
        659                return Executable(path)
        660        else:
        661            msg = 'Unable to locate {0} command in {1}'
  >>    662            raise RuntimeError(msg.format(self.name, self.prefix.bin))
```

On macOS, `python` is laid out differently. In particular, `sys.executable` is here:

```console
Python 2.7.16 (default, May  8 2021, 11:48:02)
[GCC Apple LLVM 12.0.5 (clang-1205.0.19.59.6) [+internal-os, ptrauth-isa=deploy on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python'
```

Based on that, you'd think that
`/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents` would be
where you'd look for a `bin` directory, but you (and Spack) would be wrong:

```console
$ ls /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/
Info.plist      MacOS/          PkgInfo         Resources/      _CodeSignature/ version.plist
```

You need to look in `sys.exec_prefix`

```
>>> sys.exec_prefix
'/System/Library/Frameworks/Python.framework/Versions/2.7'
```

Which looks much more like a standard prefix, with understandable `bin`, `lib`, and `include`
directories:

```console
$ ls /System/Library/Frameworks/Python.framework/Versions/2.7
Extras/         Mac/            Resources/      bin/            lib/
Headers@        Python*         _CodeSignature/ include/
$ ls -l /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
lrwxr-xr-x  1 root  wheel     7B Jan  1  2020 /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python@ -> python2
```

- [x] change `bootstrap.py` to use the `sys.exec_prefix` as the external prefix, instead of just
      getting the parent directory of the executable.
2021-08-24 21:44:26 -07:00
Tamara Dahlgren
99076660d4
bugfix: Correct source of PID for -ddd installation outputs (#25596) 2021-08-25 00:21:48 +00:00
Todd Gamblin
80713e234c
bootstrap: fix printing for python 2 (#25592) 2021-08-24 21:31:30 +00:00
Todd Gamblin
1374fea5d9
locks: only open lockfiles once instead of for every lock held (#24794)
This adds lockfile tracking to Spack's lock mechanism, so that we ensure that there
is only one open file descriptor per inode.

The `fcntl` locks that Spack uses are associated with an inode and a process.
This is convenient, because if a process exits, it releases its locks.
Unfortunately, this also means that if you close a file, *all* locks associated
with that file's inode are released, regardless of whether the process has any
other open file descriptors on it.

Because of this, we need to track open lock files so that we only close them when
a process no longer needs them.  We do this by tracking each lockfile by its
inode and process id.  This has several nice properties:

1. Tracking by pid ensures that, if we fork, we don't inadvertently track the parent
   process's lockfiles. `fcntl` locks are not inherited across forks, so we'll
   just track new lockfiles in the child.
2. Tracking by inode ensures that referencs are counted per inode, and that we don't
   inadvertently close a file whose inode still has open locks.
3. Tracking by both pid and inode ensures that we only open lockfiles the minimum
   number of times necessary for the locks we have.

Note: as mentioned elsewhere, these locks aren't thread safe -- they're designed to
work in Python and assume the GIL.

Tasks:
- [x] Introduce an `OpenFileTracker` class to track open file descriptors by inode.
- [x] Reference-count open file descriptors and only close them if they're no longer
      needed (this avoids inadvertently releasing locks that should not be released).
2021-08-24 14:08:34 -07:00
Harmen Stoppels
73208f5835
Fix bindist network issues (#25587)
* Fix bindist network issues

* Another one using the network
2021-08-24 12:09:23 -05:00
Massimiliano Culpo
31dcdf7262
ASP-based solver: rework version facts (#25585)
This commit rework version facts so that:
1. All the information on versions is collected
   before emitting the facts
2. The same kind of atom is emitted for versions
   stemming from different origins (package.py
   vs. packages.yaml)

In the end all the possible versions for a given
package are totally ordered and they are given
different and increasing weights staring from zero.

This refactor allow us to avoid using negative
weights, which in some configurations may make
parent node score "better" and lead to unexpected
"optimal" results.
2021-08-24 09:24:18 -07:00
Paul Spencer
01cbf3b81c
Spelling fixes (#25570) 2021-08-23 21:29:20 +02:00
Adam J. Stewart
1212847eee
Document how to handle changing build systems (#25174) 2021-08-21 11:05:42 -07:00
Paul Spencer
caed90fcf2
Fix spelling mistake in the word "monitor" (#25486) 2021-08-20 13:52:02 +00:00
Scott Wittenburg
84100afc91
Pipelines: use shared pr mirror for pipeline generation and builds (#25529)
Once PR binary graduation is deployed, the shared PR mirror will
contain binaries just built by a merged PR, before the subsequent
develop pipeline has had time to finish.  Using the shared PR mirror
as a source of binaries will reduce the number of times we have to
rebuild the same full hash.
2021-08-20 07:45:23 -06:00
Harmen Stoppels
d52a1b8279
Fix broken develop as CI didn't run on latest merge commit (#25531)
* CI for #25439 was not run on the latest merge commit, and fails after #25470
* Make it consistent
2021-08-20 08:06:47 +00:00
Harmen Stoppels
220a87812c
New spack.environment.active_environment api, and make spack.environment not depend on spack.cmd. (#25439)
* Refactor active environment getters

- Make `spack.environment.active_environment` a trivial getter for the active
environment, replacing `spack.environment.get_env` when the arguments are
not needed
- New method `spack.cmd.require_active_environment(cmd_name)` for 
commands that require an environment (rather than abusing 
get_env/active_environment)
- Clean up calling code to call spack.environment.active_environment or
spack.cmd.require_active_environment as appropriate
- Remove the `-e` parsing from `active_environment`, because `main.py` is
responsible for processing `-e` and already activates the environment.
- Move `spack.environment.find_environment` to
`spack.cmd.find_environment`, to avoid having spack.environment aware
of argparse.
- Refactor `spack install` command so argument parsing is all handled in the
command, no argparse in spack.environment or spack.installer
- Update documentation

* Python 2: toplevel import errors only with 'as ev'

In two files, `import spack.environment as ev` leads to errors
These errors are not well understood ("'module' object has no attribute
'environment'"). All other files standardize on the above syntax.
2021-08-19 19:01:37 -07:00
Scott Wittenburg
350372e3bf
buildcache: Add environment-aware buildcache sync command (#25470) 2021-08-19 12:15:40 -06:00
Massimiliano Culpo
4318ceb2b3
Bootstrap clingo from binaries (#22720)
* Bootstrap clingo from binaries

* Move information on clingo binaries to a JSON file

* Add support to bootstrap on Cray

Bootstrapping on Cray requires, at the moment, to
swap the platform when looking for binaries - due
to #22800.

* Add SHA256 verification for bootstrapped software

Use sha256 verification for binaries necessary to bootstrap
the concretizer and gpg for signature verification

* patchelf: use Spec._old_concretize() to bootstrap

As noted in #24450 we may happen to need the
concretizer when bootstrapping clingo. In that case
only the old concretizer is available.

* Add a schema for bootstrapping methods

Two fields have been added to bootstrap.yaml:
  "sources" which lists the methods available for
       bootstrapping software
  "trusted" which records if a source is trusted or not

A subcommand has been added to "spack bootstrap" to list
the sources currently available.

* Methods used for bootstrapping are configurable from bootstrap:sources

The function that tries to ensure a given Python module
is importable now tries bootstrapping methods in the same
order as they are defined in `bootstrap.yaml`

* Permit to trust/untrust bootstrapping methods

* Add binary tests for MacOS, Ubuntu

* Add documentation

* Add a note on bash
2021-08-18 11:14:02 -07:00
Harmen Stoppels
b22728d55c
Support older py-pygments (#25456)
`markdown` is only supported since py-pygments@2.8.0:, see
9647d2ae50

Let's allow old versions too again.
2021-08-18 09:49:51 +02:00
Erik Schnetter
c869f3639d
cmake.py: Improve documentation (#25467)
Add missing `self.` prefixes when calling `define_from_variant`
2021-08-17 23:30:55 +02:00
psakievich
d00fc55e41
Add link_type documentation (#25451) 2021-08-17 09:47:26 -07:00
Massimiliano Culpo
09378f56c0
Use a patched argparse only in Python 2.X (#25376)
Spack is internally using a patched version of `argparse` mainly to backport Python 3 functionality
into Python 2. This PR makes it such that for the supported Python 3 versions we use `argparse`
from the standard Python library. This PR has been extracted from #25371 where it was needed
to be able to use recent versions of `pytest`.

* Fixed formatting issues when using a pristine argparse.py
* Fix error message for Python 3.X when missing positional arguments
* Account for the change of API in Python 3.7
* Layout multi-valued args into columns in error messages
* Seamless transition in develop if argparse.pyc is in external
* Be more defensive in case we can't remove the file.
2021-08-17 08:52:51 -07:00
psakievich
a81ec88c6c
Allow environment views to be sym/hard link and copy types (#24832)
Add link type to spack.yaml format

Add tests to verify link behavior is correct for installed files
for all three view types

Co-authored-by: vsoch <vsoch@users.noreply.github.com>
2021-08-16 19:21:57 -07:00
robgics
657a5c85cc
Improve license err msg (#24117)
* Add to the error message to help determine failure source.

* Break up long line to keep under 80 chars.

Co-authored-by: Rob Groner <rug262@psu.edu>
2021-08-16 14:25:41 -07:00
Massimiliano Culpo
f0875b2fef
Remove handling for deprecated module commands (#25411)
The commands have been deprecated in #7098, and have
been failing with an error message since then.

Cleaning the code since it is unlikely that somebody
is still using them.
2021-08-13 07:51:56 -07:00
Harmen Stoppels
920f695d1d
Mention bash in prerequisites (#25379)
Isn't installed on Alpine.
2021-08-13 07:28:29 -07:00