Repository: spack/spack

Issue:
Installation issue: openmpi
### Steps to reproduce the issue

```console
$ spack install openmpi@3.1.5 %gcc@8.4.0
[...]
==> Error: KeyError: 'No spec with name psm2 in openmpi@3.1.5%gcc@8.4.0+atomics~cuda+cxx+cxx_exceptions~gpfs~java+legacylaunchers~memchecker+pmi+runpath~sqlite3+static+thread_multiple+vt fabrics=libfabric,psm2,ucx,verbs scheduler
s=slurm arch=linux-rhel7-haswell ^autoconf@2.69%gcc@8.4.0 arch=linux-rhel7-haswell ^autoconf-archive@2019.01.06%gcc@8.4.0 arch=linux-rhel7-haswell ^automake@1.16.2%gcc@8.4.0 arch=linux-rhel7-haswell ^bison@3.4.2%gcc@8.4.0 patches
=89aa362716d898edd0b5c6ae4208dc1b6992887774848a09e8021afd676f7d61 arch=linux-rhel7-haswell ^bzip2@1.0.8%gcc@8.4.0+shared arch=linux-rhel7-haswell ^cmake@3.16.5%gcc@8.4.0+doc+ncurses+openssl+ownlibs~qt patches=1c540040c7e203dd8e27
aa20345ecb07fe06570d56410a24a266ae570b1c4c39 arch=linux-rhel7-haswell ^curl@7.68.0%gcc@8.4.0~darwinssl~gssapi~libssh~libssh2~nghttp2 arch=linux-rhel7-haswell ^diffutils@3.7%gcc@8.4.0 arch=linux-rhel7-haswell ^expat@2.2.9%gcc@8.4.
0+libbsd arch=linux-rhel7-haswell ^findutils@4.6.0%gcc@8.4.0 patches=84b916c0bf8c51b7e7b28417692f0ad3e7030d1f3c248ba77c42ede5c1c5d11e,bd9e4e5cc280f9753ae14956c4e4aa17fe7a210f55dd6c84aa60b12d106d47a2 arch=linux-rhel7-haswell ^flex
@2.6.4%gcc@8.4.0+lex patches=09c22e5c6fef327d3e48eb23f0d610dcd3a35ab9207f12e0f875701c677978d3 arch=linux-rhel7-haswell ^gawk@5.0.1%gcc@8.4.0 arch=linux-rhel7-haswell ^gdbm@1.18.1%gcc@8.4.0 arch=linux-rhel7-haswell ^gettext@0.20.2
%gcc@8.4.0+bzip2+curses+git~libunistring+libxml2+tar+xz arch=linux-rhel7-haswell ^glib@2.64.3%gcc@8.4.0~libmount patches=63e5a3efbdaf67cfb9707a20fd6e21e8826d1c785b20c6ec326f6d2b116950fc tracing=none arch=linux-rhel7-haswell ^gmp@
6.1.2%gcc@8.4.0 arch=linux-rhel7-haswell ^help2man@1.47.11%gcc@8.4.0 arch=linux-rhel7-haswell ^hwloc@1.11.11%gcc@8.4.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml+pci+shared arch=linux-rhel7-haswell ^json-c@0.13.1%gcc@8.4.0 arch=li
nux-rhel7-haswell ^libbsd@0.10.0%gcc@8.4.0 arch=linux-rhel7-haswell ^libevent@2.1.8%gcc@8.4.0+openssl arch=linux-rhel7-haswell ^libfabric@1.9.1%gcc@8.4.0~kdreg fabrics=sockets,tcp,udp arch=linux-rhel7-haswell ^libffi@3.3%gcc@8.4.
0 arch=linux-rhel7-haswell ^libgcrypt@1.8.5%gcc@8.4.0 arch=linux-rhel7-haswell ^libgpg-error@1.37%gcc@8.4.0 arch=linux-rhel7-haswell ^libiconv@1.16%gcc@8.4.0 arch=linux-rhel7-haswell ^libnl@3.3.0%gcc@8.4.0 arch=linux-rhel7-haswel
l ^libpciaccess@0.13.5%gcc@8.4.0 arch=linux-rhel7-haswell ^libsigsegv@2.12%gcc@8.4.0 arch=linux-rhel7-haswell ^libtool@2.4.6%gcc@8.4.0 arch=linux-rhel7-haswell ^libxml2@2.9.10%gcc@8.4.0~python arch=linux-rhel7-haswell ^lz4@1.9.2%
gcc@8.4.0 arch=linux-rhel7-haswell ^m4@1.4.18%gcc@8.4.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linux-rhel7-haswell ^m
eson@0.54.2%gcc@8.4.0 patches=45c35fce59361a994c49f8d3f5fd2595fc1b181ba4b5e219b7563752dd879a3b arch=linux-rhel7-haswell ^mpfr@4.0.2%gcc@8.4.0 patches=8f15fd27ab65341a60d724d594897d32f4597ddf642d0dc121995e2150181b0c arch=linux-rhe
l7-haswell ^munge@0.5.14%gcc@8.4.0 localstatedir=PREFIX/var arch=linux-rhel7-haswell ^ncurses@6.2%gcc@8.4.0~symlinks+termlib arch=linux-rhel7-haswell ^ninja@1.10.0%gcc@8.4.0 arch=linux-rhel7-haswell ^numactl@2.0.12%gcc@8.4.0 arch
=linux-rhel7-haswell ^openssl@1.1.1g%gcc@8.4.0+systemcerts arch=linux-rhel7-haswell ^pcre@8.44%gcc@8.4.0~jit+multibyte+utf arch=linux-rhel7-haswell ^perl@5.30.1%gcc@8.4.0+cpanm+shared+threads arch=linux-rhel7-haswell ^pkgconf@1.6
.3%gcc@8.4.0 arch=linux-rhel7-haswell ^pmix@3.1.3%gcc@8.4.0+pmi_backwards_compatibility arch=linux-rhel7-haswell ^py-alabaster@0.7.12%gcc@8.4.0 arch=linux-rhel7-haswell ^py-babel@2.7.0%gcc@8.4.0 arch=linux-rhel7-haswell ^py-certi
fi@2019.9.11%gcc@8.4.0 arch=linux-rhel7-haswell ^py-chardet@3.0.4%gcc@8.4.0 arch=linux-rhel7-haswell ^py-docutils@0.15.2%gcc@8.4.0 arch=linux-rhel7-haswell ^py-idna@2.8%gcc@8.4.0 arch=linux-rhel7-haswell ^py-imagesize@1.1.0%gcc@8
.4.0 arch=linux-rhel7-haswell ^py-jinja2@2.10.3%gcc@8.4.0 arch=linux-rhel7-haswell ^py-markupsafe@1.1.1%gcc@8.4.0 arch=linux-rhel7-haswell ^py-packaging@19.2%gcc@8.4.0 arch=linux-rhel7-haswell ^py-pygments@2.6.1%gcc@8.4.0 arch=li
nux-rhel7-haswell ^py-pyparsing@2.4.2%gcc@8.4.0 arch=linux-rhel7-haswell ^py-pytest-runner@5.1%gcc@8.4.0 arch=linux-rhel7-haswell ^py-pytz@2019.3%gcc@8.4.0 arch=linux-rhel7-haswell ^py-requests@2.22.0%gcc@8.4.0 arch=linux-rhel7-h
aswell ^py-setuptools@46.1.3%gcc@8.4.0 arch=linux-rhel7-haswell ^py-setuptools-scm@3.3.3%gcc@8.4.0 arch=linux-rhel7-haswell ^py-six@1.14.0%gcc@8.4.0 arch=linux-rhel7-haswell ^py-snowballstemmer@2.0.0%gcc@8.4.0 arch=linux-rhel7-ha
swell ^py-sphinx@3.0.0%gcc@8.4.0 arch=linux-rhel7-haswell ^py-sphinxcontrib-applehelp@1.0.1%gcc@8.4.0 arch=linux-rhel7-haswell ^py-sphinxcontrib-devhelp@1.0.1%gcc@8.4.0 arch=linux-rhel7-haswell ^py-sphinxcontrib-htmlhelp@1.0.2%gc
c@8.4.0 arch=linux-rhel7-haswell ^py-sphinxcontrib-jsmath@1.0.1%gcc@8.4.0 arch=linux-rhel7-haswell ^py-sphinxcontrib-qthelp@1.0.2%gcc@8.4.0 arch=linux-rhel7-haswell ^py-sphinxcontrib-serializinghtml@1.1.3%gcc@8.4.0 arch=linux-rhe
l7-haswell ^py-urllib3@1.25.6%gcc@8.4.0~secure~socks arch=linux-rhel7-haswell ^python@3.7.7%gcc@8.4.0+bz2+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tix~tkinter~ucs4~uuid+zli
b arch=linux-rhel7-haswell ^rdma-core@20%gcc@8.4.0 build_type=RelWithDebInfo arch=linux-rhel7-haswell ^readline@8.0%gcc@8.4.0 arch=linux-rhel7-haswell ^slurm@19-05-5-1%gcc@8.4.0~gtk~hdf5~hwloc~mariadb+pmix+readline sysconfdir=PRE
FIX/etc arch=linux-rhel7-haswell ^sqlite@3.31.1%gcc@8.4.0+column_metadata+fts~functions~rtree arch=linux-rhel7-haswell ^tar@1.32%gcc@8.4.0 arch=linux-rhel7-haswell ^texinfo@6.5%gcc@8.4.0 patches=12f6edb0c6b270b8c8dba2ce17998c580d
b01182d871ee32b7b6e4129bd1d23a,1732115f651cff98989cb0215d8f64da5e0f7911ebf0c13b064920f088f2ffe1 arch=linux-rhel7-haswell ^ucx@1.8.0%gcc@8.4.0~assertions~cuda~debug~gdrcopy~java~logging~optimizations~parameter_checking+pic+thread_
multiple cuda_arch=none arch=linux-rhel7-haswell ^util-macros@1.19.1%gcc@8.4.0 arch=linux-rhel7-haswell ^xz@5.2.5%gcc@8.4.0 arch=linux-rhel7-haswell ^zlib@1.2.11%gcc@8.4.0+optimize+pic+shared arch=linux-rhel7-haswell'

/curc/admin/spack/lib/spack/spack/build_systems/autotools.py:440, in _activate_or_not:
        437                            )
        438                        return line
        439                    return '--{0}-{1}'.format(deactivation_word, option_value)
  >>    440                line_generator = _default_generator
        441            args.append(line_generator(activated))
        442        return args

See build log for details:
  /scratch/local/rcops/spack-stage-openmpi-3.1.5-jxgglenos2s636rrvb4e5xwztwo5iisv/spack-build-out.txt
```

### Information on your system

This package is being installed as part of a spack envornment. That environment can be found at

https://github.com/ResearchComputing/core-software/tree/sprint-ending-2020-05-11/spack/environments/spring2020

Notably, there is a `packages.yaml` file here:

https://github.com/ResearchComputing/core-software/blob/sprint-ending-2020-05-11/spack/environments/spring2020/packages.yaml

When I am attempting to build I am using

```
packages:
  openmpi:
    variants: fabrics=psm2 schedulers=slurm +pmi +cxx +cxx_exceptions +atomics +thread_multiple +legacylaunchers ~gpfs
```

[spack-install-openmpi.log](https://github.com/spack/spack/files/4704951/spack-install-openmpi.log)

```
[spring2020] [rcops@shas0137 spring2020]$ spack debug report
* **Spack:** 0.14.2-1265-9d1f71e
* **Python:** 3.6.8
* **Platform:** linux-rhel7-haswell
```

### Additional information

- [spack-build-out.txt](https://github.com/spack/spack/files/4704954/spack-build-out.txt)
- [spack-build-env.txt](https://github.com/spack/spack/files/4704955/spack-build-env.txt)

@hppritcha 

### General information

- [x] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [x] I have run `spack maintainers <name-of-the-package>` and @mentioned any maintainers
- [x] I have uploaded the build log and environment files
- [x] I have searched the issues of this repo and believe this is not a duplicate



Discussion:
I'm happy to provide any further information I can / help debug from our environment. I'll be checking in over the weekend. If I'm doing something wrong, please let me know; but in any case I don't think it should TB like that.
I tried adding `depends_on('opa-psm2', when='fabrics=psm2')` to the `openmpi` package, but I got the same error. `opa-psm2` did appear in the spec; but presumably since it's not literally called `psm2` it isn't being seen.
I think I've got this fixed on our side. The package is building now.

I'm also going to fix the TODO to document `with_or_without` and `enable_or_disable`, since I had to figure them out to fix this.

I've got a couple more tests I want to run to make sure I didn't do anything unnecessarily; but so far it appears to be working.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/openmpi/package.py b/var/spack/repos/builtin/packages/openmpi/package.py
--- a/var/spack/repos/builtin/packages/openmpi/package.py
+++ b/var/spack/repos/builtin/packages/openmpi/package.py
@@ -247,6 +247,7 @@ class Openmpi(AutotoolsPackage):
     depends_on('ucx +thread_multiple', when='fabrics=ucx +thread_multiple')
     depends_on('ucx +thread_multiple', when='@3.0.0: fabrics=ucx')
     depends_on('libfabric', when='fabrics=libfabric')
+    depends_on('opa-psm2', when='fabrics=psm2')
     depends_on('mxm', when='fabrics=mxm')
     depends_on('binutils+libiberty', when='fabrics=mxm')
     depends_on('rdma-core', when='fabrics=verbs')
@@ -330,6 +331,11 @@ def with_or_without_tm(self, activated):
             return '--without-tm'
         return '--with-tm={0}'.format(self.spec['openpbs'].prefix)
 
+    def with_or_without_psm2(self, activated):
+        if not activated:
+            return '--without-psm2'
+        return '--with-psm2={0}'.format(self.spec['opa-psm2'].prefix)
+
     @run_before('autoreconf')
     def die_without_fortran(self):
         # Until we can pass variants such as +fortran through virtual


Test patch: