Repository: spack/spack

Issue:
Installation issue: tau@2.24.1 %gcc@8.2.0
### Steps to reproduce the issue

I am trying to build TAU 2.24.1 but am coming up with an error.  It seems like Spack is trying to pass the -elf option to the TAU configure file (in the stage directory).  In other words, the offending command is this:

```console
./configure ... 
'-elf=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libelf-0.8.13-hi2dy6yq6fbjrczfmijelxybgvocjnyw'
```
But the configure script does not list elf as one of the valid options, so this is choking the build.

Also note: this appears to be an issue with tau@2.25, tau@2.26, tau@2.27.

### Steps to reproduce the issue

```console
$spack install tau@2.24.1 %gcc@8.2.0 openmp=True

==> Error: ProcessError: Command exited with status 1:
    './configure' '-prefix=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/tau-2.24.1-pi3q24bzp4hh4ulmmgkap3evgsxmguuo' '-iowrapper' '-pdt=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/pdt-3.25.1-aiq6klkadf355cevkygoi2q52cgd3csa' '-pthread' '-papi=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/papi-5.7.0-hivmizmucgpfq6k4dqnxqv4o4fkrilfh' '-openmp' '-bfd=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/binutils-2.31.1-o6ek6dwekia6bpx36t35k5w5ltpbwcyl' '-dwarf=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libdwarf-20180129-vvf4silzyz7v3v22icizpe6udakngwjx' '-elf=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libelf-0.8.13-hi2dy6yq6fbjrczfmijelxybgvocjnyw' '-unwind=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libunwind-1.2.1-zluaacildojpx3gjlkbqoi4aaejgvy3i' '-otf=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/otf2-2.1.1-miwrbx3gkfjrm5vdfmy26fvvnezfik5y' '-c++=/n/sw/helmod/apps/centos7/Core/gcc/8.2.0-fasrc01/bin/g++' '-cc=/n/sw/helmod/apps/centos7/Core/gcc/8.2.0-fasrc01/bin/gcc' '-fortran=gfortran' '-useropt=-O2 -g -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/tau-2.24.1-pi3q24bzp4hh4ulmmgkap3evgsxmguuo/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/tau-2.24.1-pi3q24bzp4hh4ulmmgkap3evgsxmguuo/lib64 -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/papi-5.7.0-hivmizmucgpfq6k4dqnxqv4o4fkrilfh/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/pdt-3.25.1-aiq6klkadf355cevkygoi2q52cgd3csa/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/otf2-2.1.1-miwrbx3gkfjrm5vdfmy26fvvnezfik5y/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libunwind-1.2.1-zluaacildojpx3gjlkbqoi4aaejgvy3i/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libelf-0.8.13-hi2dy6yq6fbjrczfmijelxybgvocjnyw/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/binutils-2.31.1-o6ek6dwekia6bpx36t35k5w5ltpbwcyl/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libdwarf-20180129-vvf4silzyz7v3v22icizpe6udakngwjx/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/binutils-2.31.1-o6ek6dwekia6bpx36t35k5w5ltpbwcyl/lib64'
See build log for details:
  /n/home09/ryantosca/spack/var/spack/stage/tau-2.24.1-pi3q24bzp4hh4ulmmgkap3evgsxmguuo/spack-build.txt

```
### Error output

The build log says
```console

==> Executing phase: 'install'
==> [2019-06-25-17:13:51.496478] FILTER FILE: configure [replacing "^s@([^@]*)@(.*)@[gIp]$"]
==> [2019-06-25-17:13:51.548631] FILTER FILE: configure [replacing "'s@((?:\\'|[^@'])*)@((?:\\'|[^'])*)@[gIp]?'"]
==> [2019-06-25-17:13:51.585205] FILTER FILE: configure [replacing ""s@((?:\\"|[^@"])*)@((?:\\"|[^"])*)@[gIp]?""]
==> [2019-06-25-17:13:51.615722] FILTER FILE: utils/FixMakefile [replacing "^s@([^@]*)@(.*)@[gIp]$"]
==> [2019-06-25-17:13:51.622387] FILTER FILE: utils/FixMakefile [replacing "'s@((?:\\'|[^@'])*)@((?:\\'|[^'])*)@[gIp]?'"]
==> [2019-06-25-17:13:51.627646] FILTER FILE: utils/FixMakefile [replacing ""s@((?:\\"|[^@"])*)@((?:\\"|[^"])*)@[gIp]?""]
==> [2019-06-25-17:13:51.633157] FILTER FILE: utils/FixMakefile.sed.default [replacing "^s@([^@]*)@(.*)@[gIp]$"]
==> [2019-06-25-17:13:51.634256] FILTER FILE: utils/FixMakefile.sed.default [replacing "'s@((?:\\'|[^@'])*)@((?:\\'|[^'])*)@[gIp]?'"]
==> [2019-06-25-17:13:51.634770] FILTER FILE: utils/FixMakefile.sed.default [replacing ""s@((?:\\"|[^@"])*)@((?:\\"|[^"])*)@[gIp]?""]
==> [2019-06-25-17:13:51.651690] './configure' '-prefix=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/tau-2.24.1-pi3q24bzp4hh4ulmmgkap3evgsxmguuo' '-iowrapper' '-pdt=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/pdt-3.25.1-aiq6klkadf355cevkygoi2q52cgd3csa' '-pthread' '-papi=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/papi-5.7.0-hivmizmucgpfq6k4dqnxqv4o4fkrilfh' '-openmp' '-bfd=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/binutils-2.31.1-o6ek6dwekia6bpx36t35k5w5ltpbwcyl' '-dwarf=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libdwarf-20180129-vvf4silzyz7v3v22icizpe6udakngwjx' '-elf=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libelf-0.8.13-hi2dy6yq6fbjrczfmijelxybgvocjnyw' '-unwind=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libunwind-1.2.1-zluaacildojpx3gjlkbqoi4aaejgvy3i' '-otf=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/otf2-2.1.1-miwrbx3gkfjrm5vdfmy26fvvnezfik5y' '-c++=/n/sw/helmod/apps/centos7/Core/gcc/8.2.0-fasrc01/bin/g++' '-cc=/n/sw/helmod/apps/centos7/Core/gcc/8.2.0-fasrc01/bin/gcc' '-fortran=gfortran' '-useropt=-O2 -g -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/tau-2.24.1-pi3q24bzp4hh4ulmmgkap3evgsxmguuo/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/tau-2.24.1-pi3q24bzp4hh4ulmmgkap3evgsxmguuo/lib64 -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/papi-5.7.0-hivmizmucgpfq6k4dqnxqv4o4fkrilfh/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/pdt-3.25.1-aiq6klkadf355cevkygoi2q52cgd3csa/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/otf2-2.1.1-miwrbx3gkfjrm5vdfmy26fvvnezfik5y/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libunwind-1.2.1-zluaacildojpx3gjlkbqoi4aaejgvy3i/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libelf-0.8.13-hi2dy6yq6fbjrczfmijelxybgvocjnyw/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/binutils-2.31.1-o6ek6dwekia6bpx36t35k5w5ltpbwcyl/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libdwarf-20180129-vvf4silzyz7v3v22icizpe6udakngwjx/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/binutils-2.31.1-o6ek6dwekia6bpx36t35k5w5ltpbwcyl/lib64'
Unset ParaProf's cubeclasspath...
Unset Perfdmf cubeclasspath...
ERROR: Command line switch `-elf=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libelf-0.8.13-hi2dy6yq6fbjrczfmijelxybgvocjnyw' not recognized
Run configure with -help to see a list of options
```
### Platform and user environment

Please report your OS here:
```commandline
$ uname -a 
Linux holyjacob01.rc.fas.harvard.edu 3.10.0-957.12.1.el7.x86_64 #1 SMP Mon Apr 29 14:59:59 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -d
Description:    CentOS Linux release 7.6.1810 (Core)
``` 
[packages.yaml.txt](https://github.com/spack/spack/files/3327344/packages.yaml.txt)
[compilers.yaml.txt](https://github.com/spack/spack/files/3327289/compilers.yaml.txt)

### Additional information
```console
$ spack spec --install-status tau@2.24.1
Input spec
--------------------------------
 -   tau@2.24.1

Concretized
--------------------------------
 -   tau@2.24.1%gcc@8.2.0~bgq+binutils~comm~craycnl~cuda~gasnet+libdwarf+libelf+libunwind~likwid~mpi~ompt~opari~openmp+otf2+papi+pdt~phase~ppc64le+pthreads~python~scorep~shmem arch=linux-centos7-x86_64
[+]      ^binutils@2.31.1%gcc@8.2.0+gold+headers+libiberty~nls~plugins arch=linux-centos7-x86_64
[+]          ^zlib@1.2.11%gcc@8.2.0+optimize+pic+shared arch=linux-centos7-x86_64
[+]      ^libdwarf@20180129%gcc@8.2.0 arch=linux-centos7-x86_64
[+]          ^libelf@0.8.13%gcc@8.2.0 arch=linux-centos7-x86_64
[+]      ^libunwind@1.2.1%gcc@8.2.0~xz arch=linux-centos7-x86_64
[+]      ^otf2@2.1.1%gcc@8.2.0 arch=linux-centos7-x86_64
[+]      ^papi@5.7.0%gcc@8.2.0 arch=linux-centos7-x86_64
[+]      ^pdt@3.25.1%gcc@8.2.0 arch=linux-centos7-x86_64
```

Also, here is the tail end of the traceback:
```console
Traceback (most recent call last):
  File "/n/home09/ryantosca/spack/lib/spack/spack/build_environment.py", line 765, in child_process
    return_value = function()
  File "/n/home09/ryantosca/spack/lib/spack/spack/package.py", line 1577, in build_process
    phase(self.spec, self.prefix)
  File "/n/home09/ryantosca/spack/lib/spack/spack/package.py", line 99, in phase_wrapper
    phase(spec, prefix)
  File "/n/home09/ryantosca/spack/var/spack/repos/builtin/packages/tau/package.py", line 216, in install
    make("install")
  File "/n/home09/ryantosca/spack/lib/spack/spack/util/executable.py", line 189, in __call__
    proc.returncode, long_msg)
ProcessError: Command exited with status 1:
    './configure' '-prefix=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/tau-2.24.1-cwnhh3o2mwkm3wkkvkav7yqjepxf37cb' '-iowrapper' '-pdt=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/pdt-3.25.1-aiq6klkadf355cevkygoi2q52cgd3csa' '-pthread' '-papi=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/papi-5.7.0-hivmizmucgpfq6k4dqnxqv4o4fkrilfh' '-bfd=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/binutils-2.31.1-o6ek6dwekia6bpx36t35k5w5ltpbwcyl' '-dwarf=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libdwarf-20180129-vvf4silzyz7v3v22icizpe6udakngwjx' '-elf=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libelf-0.8.13-hi2dy6yq6fbjrczfmijelxybgvocjnyw' '-unwind=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libunwind-1.2.1-zluaacildojpx3gjlkbqoi4aaejgvy3i' '-otf=/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/otf2-2.1.1-miwrbx3gkfjrm5vdfmy26fvvnezfik5y' '-c++=/n/sw/helmod/apps/centos7/Core/gcc/8.2.0-fasrc01/bin/g++' '-cc=/n/sw/helmod/apps/centos7/Core/gcc/8.2.0-fasrc01/bin/gcc' '-fortran=gfortran' '-useropt=-O2 -g -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/tau-2.24.1-cwnhh3o2mwkm3wkkvkav7yqjepxf37cb/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/tau-2.24.1-cwnhh3o2mwkm3wkkvkav7yqjepxf37cb/lib64 -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/papi-5.7.0-hivmizmucgpfq6k4dqnxqv4o4fkrilfh/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/pdt-3.25.1-aiq6klkadf355cevkygoi2q52cgd3csa/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/otf2-2.1.1-miwrbx3gkfjrm5vdfmy26fvvnezfik5y/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libunwind-1.2.1-zluaacildojpx3gjlkbqoi4aaejgvy3i/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libelf-0.8.13-hi2dy6yq6fbjrczfmijelxybgvocjnyw/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/binutils-2.31.1-o6ek6dwekia6bpx36t35k5w5ltpbwcyl/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/libdwarf-20180129-vvf4silzyz7v3v22icizpe6udakngwjx/lib -Wl,-rpath,/n/home09/ryantosca/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/binutils-2.31.1-o6ek6dwekia6bpx36t35k5w5ltpbwcyl/lib64'
```



Discussion:
@sameershende @khuck: this looks like an issue with the TAU package.  Does the ability to specify `-elf` only apply to specific versions?  If so that should probably be encoded in the package as a conflict.
Yes, it does apply to TAU v2.28.1+. We will fix this as a conflict. 
@yantosca, would you please try installing TAU with Spack with TAU v2.28.1? 2.24.1 is very old and several new features have been incorporated in TAU since 2.24.1. Are there any specific features of TAU v2.24.1 that you are trying to use?
FWIW, and in @sameershende's defense, the real problem is that we don't currently support `when` clauses on variants.  The workaround for now is to add a conflict.

There's another issue here, which is that the `elf` defaults to `True` unconditionally, and so you'll get a conflict _unless_ you explicitly say `~elf`.  The conflict will add an error telling the user what to do, but I realize that this is annoying, since Spack technically "knows" what to do.  We'll have a fix for this in the new concretizer.
@tgamblin is this the right fix?

```
    conflicts('+libelf', when='@:2.28.0')  # Elf only required from 2.28.1 on
    conflicts('+libdwarf', when='@:2.28.0')  # dwarf only required from 2.28.1 on
```

@sameershende Is there any reason to have spack support for TAU versions _that_ old?

btw, this is referenced in #9740

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/tau/package.py b/var/spack/repos/builtin/packages/tau/package.py
--- a/var/spack/repos/builtin/packages/tau/package.py
+++ b/var/spack/repos/builtin/packages/tau/package.py
@@ -80,6 +80,10 @@ class Tau(Package):
     depends_on('cuda', when='+cuda')
     depends_on('gasnet', when='+gasnet')
 
+    # Elf only required from 2.28.1 on
+    conflicts('+libelf', when='@:2.28.0')
+    conflicts('+libdwarf', when='@:2.28.0')
+
     filter_compiler_wrappers('tau_cc.sh', 'Makefile.tau', relative_root='bin')
 
     def set_compiler_options(self):


Test patch: