Repository: spack/spack

Issue:
Installation issue: superlu-dist
`superlu-dist 5.4.0` with `intel-mkl` fails to build.

### Steps to reproduce the issue

```console
$ spack install -v superlu-dist@5.4.0%gcc@9.4.0 ^intel-mkl

  >> 471    make[2]: *** No rule to make target '/vast/home/quellyn/Scratch/spack/opt/spack/linux-c
            entos8-haswell/gcc-9.4.0/intel-mkl-2020.4.304-gqu4mdbaiwbyygxawbetqnpc4wiqmuib/compiler
            s_and_libraries_2020.4.304/linux/mkl/lib/intel64/libmkl_intel_lp64.so /vast/home/quelly
            n/Scratch/spack/opt/spack/linux-centos8-haswell/gcc-9.4.0/intel-mkl-2020.4.304-gqu4mdba
            iwbyygxawbetqnpc4wiqmuib/compilers_and_libraries_2020.4.304/linux/mkl/lib/intel64/libmk
            l_sequential.so /vast/home/quellyn/Scratch/spack/opt/spack/linux-centos8-haswell/gcc-9.
            4.0/intel-mkl-2020.4.304-gqu4mdbaiwbyygxawbetqnpc4wiqmuib/compilers_and_libraries_2020.
            4.304/linux/mkl/lib/intel64/libmkl_core.so /lib64/libpthread.so /lib64/libm.so /lib64/l
            ibdl.so', needed by 'SRC/libsuperlu_dist.so.5.4.0'.  Stop.
```

I believe this error was introduced with #28658. If I revert the `superlu-dist` recipe file back to the version before that PR was merged, my build succeeds as usual.

### Information on your system

```
$ spack debug report
* **Spack:** 0.17.1-1109-d4ca803fc5
* **Python:** 3.6.8
* **Platform:** linux-centos8-haswell
* **Concretizer:** clingo
```

I loaded software modules from the system for `gcc` and `openmpi`, and added a stanza for `openmpi` at the bottom of `etc/spack/defaults/packages.yaml`:
```console
  openmpi:
    buildable: False
    externals:
    - spec: 'openmpi@3.1.6-gcc_9.4.0'
      modules:
      - 'openmpi/3.1.6-gcc_9.4.0'
```


### Additional information

[spack-build-env.txt](https://github.com/spack/spack/files/8028142/spack-build-env.txt)
[spack-build-out.txt](https://github.com/spack/spack/files/8028143/spack-build-out.txt)

Maintainers for `superlu-dist` include:
@balay 
@gchavez2 
@liuyangzhuan 
@pghysels 
@xiaoye


### 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 don't see how https://github.com/spack/spack/pull/28658 is related to this error. @sethrj 

But one thing suspicious from your error is that 
/vast/home/quellyn/Scratch/spack/opt/spack/linux-centos8-haswell/gcc-9.4.0/intel-mkl-2020.4.304-gqu4mdbaiwbyygxawbetqnpc4wiqmuib/compilers_and_libraries_2020.4.304/linux/mkl/lib/intel64/libmkl_intel_lp64.so

shouldn't it be libmkl_gf_lp64.so instead?
Maybe try spack install -v superlu-dist@5.4.0^intel-mkl%gcc@9.4.0 ?





The problem is the BLAS library argument:
```
'-DTPL_BLAS_LIBRARIES:STRING=/vast/home/quellyn/Scratch/spack/opt/spack/linux-centos8-haswell/gcc-9.4.0/intel-mkl-2020.4.304-gqu4mdbaiwbyygxawbetqnpc4wiqmuib/compilers_and_libraries_2020.4.304/linux/mkl/lib/intel64/libmkl_intel_lp64.so /vast/home/quellyn/Scratch/spack/opt/spack/linux-centos8-haswell/gcc-9.4.0/intel-mkl-2020.4.304-gqu4mdbaiwbyygxawbetqnpc4wiqmuib/compilers_and_libraries_2020.4.304/linux/mkl/lib/intel64/libmkl_sequential.so /vast/home/quellyn/Scratch/spack/opt/spack/linux-centos8-haswell/gcc-9.4.0/intel-mkl-2020.4.304-gqu4mdbaiwbyygxawbetqnpc4wiqmuib/compilers_and_libraries_2020.4.304/linux/mkl/lib/intel64/libmkl_core.so /lib64/libpthread.so /lib64/libm.so /lib64/libdl.so'
```
These should be semicolon-separated, not space-separated. I think the issue is that CMakePackage.define checks for `isinstance(list, tuple)`, but `spec.libs` returns a `LibraryList` which is-a Sequence not a `list`. This is indeed my fault and I will open a fix.

Resolving patch:
diff --git a/lib/spack/spack/build_systems/cmake.py b/lib/spack/spack/build_systems/cmake.py
--- a/lib/spack/spack/build_systems/cmake.py
+++ b/lib/spack/spack/build_systems/cmake.py
@@ -10,6 +10,9 @@
 import re
 from typing import List  # novm
 
+import six
+
+from llnl.util.compat import Sequence
 from llnl.util.filesystem import working_dir
 
 import spack.build_environment
@@ -222,7 +225,7 @@ def define(cmake_var, value):
             value = "ON" if value else "OFF"
         else:
             kind = 'STRING'
-            if isinstance(value, (list, tuple)):
+            if isinstance(value, Sequence) and not isinstance(value, six.string_types):
                 value = ";".join(str(v) for v in value)
             else:
                 value = str(value)


Test patch:
diff --git a/lib/spack/spack/test/build_systems.py b/lib/spack/spack/test/build_systems.py
--- a/lib/spack/spack/test/build_systems.py
+++ b/lib/spack/spack/test/build_systems.py
@@ -313,6 +313,9 @@ def test_define(self):
             arg = pkg.define('MULTI', cls(['right', 'up']))
             assert arg == '-DMULTI:STRING=right;up'
 
+        arg = pkg.define('MULTI', fs.FileList(['/foo', '/bar']))
+        assert arg == '-DMULTI:STRING=/foo;/bar'
+
         arg = pkg.define('ENABLE_TRUTH', False)
         assert arg == '-DENABLE_TRUTH:BOOL=OFF'
         arg = pkg.define('ENABLE_TRUTH', True)