Repository: spack/spack

Issue:
Installation issue: parsec 3.0.2012: Unknown CMake command "FLEX_TARGET"
### Steps to reproduce the issue

`parsec` fails at CMake stage using:
* `spack@develop` (81be31aee091a6d108a40e0f3dc7ff3bdfa93f26 from `Mon Aug 9 16:07:39 2021 +0200`)
* Ubuntu 20.04, GCC 9.3.0

Concrete spec: [parsec.spec.yaml.txt](https://github.com/spack/spack/files/6963572/parsec.spec.yaml.txt)

Using DockerHub container image `ecpe4s/ubuntu20.04-runner-x86_64:2021-07-01` for reproducer below:

```
$> git clone https://github.com/spack/spack
$> (cd spack && git checkout 81be31aee091)
$> . spack/share/spack/setup-env.sh

$> spack mirror add E4S https://cache.e4s.io
$> spack buildcache keys -it

$> spack install -f ./parsec.spec.yaml
...
==> Installing parsec-3.0.2012-27wbe2dfa5kf66pjltlewvhujxhplok4
==> No binary for parsec-3.0.2012-27wbe2dfa5kf66pjltlewvhujxhplok4 found: installing from source
==> Using cached archive: /spack/var/spack/cache/_source-cache/archive/f5/f565bcfffe106be8237b6aea3e83a5770607b7236606414b6f270244fa6ec3bc.tar.bz2
==> No patches needed for parsec
==> parsec: Executing phase: 'cmake'
==> Error: ProcessError: Command exited with status 1:
    'cmake' '-G' 'Unix Makefiles' '-DCMAKE_INSTALL_PREFIX:STRING=/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/parsec-3.0.2012-27wbe2dfa5kf66pjltlewvhujxhplok4' '-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo' '-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF' '-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON' '-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=OFF' '-DCMAKE_INSTALL_RPATH:STRING=/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/parsec-3.0.2012-27wbe2dfa5kf66pjltlewvhujxhplok4/lib;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/parsec-3.0.2012-27wbe2dfa5kf66pjltlewvhujxhplok4/lib64;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/libxml2-2.9.10-qlt5ajqqmtin3atqcycnv67oex63cvny/lib;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/libiconv-1.16-w6zptbclncs3jsnl3i4qtg72fgheiwdf/lib;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/xz-5.2.5-ynkyqliadxgrqpk4mavevv3onehjrdco/lib;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/zlib-1.2.11-p7dmb5pqi6svirhovljrkp3uyfiytz3m/lib;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/hwloc-2.4.1-eeigvjc57oehl37canx4h5lfganpvdq2/lib;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/libpciaccess-0.16-ux5xkhgfhhmitpkxfuf5h6ooudsiwhd4/lib;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/ncurses-6.2-n5vhymfigwg6e45k7thdfyeswuhxojtx/lib;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/mpich-3.4.2-z3qvcplqpvri2tliohtqp7ei2lnvqsf3/lib;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/libfabric-1.12.1-lgug4cxazbl24jdtmttovd5qpnr6os7z/lib;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/cuda-11.4.0-vklb4yvqfk6r4n4ezstwd65ytmigvfed/lib64' '-DCMAKE_PREFIX_PATH:STRING=/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/python-3.8.10-4hkgzkkd2svggorn2u2yvtiwrb6ndwfl;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/mpich-3.4.2-z3qvcplqpvri2tliohtqp7ei2lnvqsf3;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/libfabric-1.12.1-lgug4cxazbl24jdtmttovd5qpnr6os7z;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/hwloc-2.4.1-eeigvjc57oehl37canx4h5lfganpvdq2;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/libpciaccess-0.16-ux5xkhgfhhmitpkxfuf5h6ooudsiwhd4;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/cuda-11.4.0-vklb4yvqfk6r4n4ezstwd65ytmigvfed;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/libxml2-2.9.10-qlt5ajqqmtin3atqcycnv67oex63cvny;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/xz-5.2.5-ynkyqliadxgrqpk4mavevv3onehjrdco;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/cmake-3.20.5-zyz2eldbrcih3f6l37dyvdxmyoiyvhv5;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/zlib-1.2.11-p7dmb5pqi6svirhovljrkp3uyfiytz3m;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/libiconv-1.16-w6zptbclncs3jsnl3i4qtg72fgheiwdf;/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/ncurses-6.2-n5vhymfigwg6e45k7thdfyeswuhxojtx' '-DBUILD_SHARED_LIBS:BOOL=ON' '-DPARSEC_GPU_WITH_CUDA:BOOL=ON' '-DPARSEC_PROF_TRACE:BOOL=OFF' '-DPARSEC_DEBUG_HISTORY:BOOL=OFF' '-DPARSEC_DEBUG_PARANOID:BOOL=OFF' '/tmp/root/spack-stage/spack-stage-parsec-3.0.2012-27wbe2dfa5kf66pjltlewvhujxhplok4/spack-src'

1 error found in build log:
     181    -- Looking for cudaDeviceCanAccessPeer
     182    -- Looking for cudaDeviceCanAccessPeer - found
     183    -- Looking for shm_open
     184    -- Looking for shm_open - not found
     185    -- Looking for shm_open in rt
     186    -- Looking for shm_open in rt - found
  >> 187    CMake Error at parsec/CMakeLists.txt:39 (FLEX_TARGET):
     188      Unknown CMake command "FLEX_TARGET".
     189
     190
     191    -- Configuring incomplete, errors occurred!
     192    See also "/tmp/root/spack-stage/spack-stage-parsec-3.0.2012-27wbe2dfa5kf66pjltlewvhujxhplok4/spack-build-27wbe2d/CMakeFiles/CMakeOutput.log".
     193    See also "/tmp/root/spack-stage/spack-stage-parsec-3.0.2012-27wbe2dfa5kf66pjltlewvhujxhplok4/spack-build-27wbe2d/CMakeFiles/CMakeError.log".

See build log for details:
  /tmp/root/spack-stage/spack-stage-parsec-3.0.2012-27wbe2dfa5kf66pjltlewvhujxhplok4/spack-build-out.txt
```

### Information on your system

* **Spack:** 0.13.3-9086-c5229a3913
* **Python:** 3.8.5
* **Platform:** linux-ubuntu20.04-cascadelake
* **Concretizer:** original

### Additional information

Build log: [parsec-build-out.txt](https://github.com/spack/spack/files/6963587/parsec-build-out.txt)
CMake log: [parsec-01-cmake-out.txt](https://github.com/spack/spack/files/6963585/parsec-01-cmake-out.txt)

@abouteiller @bosilca @herault

### 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:
Thanks, the spack recipe is missing a build-dependency on flex (and probably also bison). I'll add it asap. 
I guess we have multiple issues here. First, we are using the CMake FLEX_TARGET when Flex support was not available, which is incorrect. Second, as the FLEX dependency is optional (only some DSL needs it), the rest of the runtime should compile correctly.

Right, but the other changes have to happen on the Parsec side. For Parsec 4.x we have a branch that completely removes dependencies on flex/bison, but we will need to keep supporting 3.x builds in Spack for a while. 

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/parsec/package.py b/var/spack/repos/builtin/packages/parsec/package.py
--- a/var/spack/repos/builtin/packages/parsec/package.py
+++ b/var/spack/repos/builtin/packages/parsec/package.py
@@ -39,6 +39,8 @@ class Parsec(CMakePackage, CudaPackage):
 
     depends_on('cmake@3.16:', type='build')
     depends_on('python', type='build')
+    depends_on('flex', type='build')
+    depends_on('bison', type='build')
     depends_on('hwloc')
     depends_on('mpi')
     depends_on('papi', when='+profile')


Test patch: