Repository: spack/spack

Issue:
Installation issue: hpctoolkit
<!-- Thanks for taking the time to report this build failure. To proceed with the report please:

1. Title the issue "Installation issue: <name-of-the-package>".
2. Provide the information required below.

We encourage you to try, as much as possible, to reduce your problem to the minimal example that still reproduces the issue. That would help us a lot in fixing it quickly and effectively! -->

### Steps to reproduce the issue

<!-- Fill in the exact spec you are trying to build and the relevant part of the error message -->
```console
$ spack install hpctoolkit %gcc @11.1.0 target=skylake_avx512
```

I receive errors of the kind
```
     2175    /home/eschnetter/src/CarpetX/spack/opt/spack/linux-ubuntu18.04-skylake_avx512/gcc-10.1.0/gcc-11.1.0-vvn67u5lrxu5r6ygab
             l722234lfcdix7/include/c++/11.1.0/tr1/riemann_zeta.tcc: In function '_Tp std::__detail::__hurwitz_zeta_glob(_Tp, _Tp)'
             :
  >> 2176    /tmp/eschnetter/spack-stage/spack-stage-hpctoolkit-2021.03.01-ugmvtghcrx5xkf4764yw4xj6igxubt2j/spack-src/src/lib/prof/
             Metric-AExpr.hpp:100:18: error: expected unqualified-id before '(' token
     2177      100 | #define epsilon  (0.000001)
```

Building with `gcc @10.3.0 target=skylake_avx512` works fine.

### Information on your system

<!-- Please include the output of `spack debug report` -->
```
$ spack debug report
* **Spack:** 0.16.1-2651-fc392d2f56
* **Python:** 3.6.9
* **Platform:** linux-ubuntu18.04-skylake_avx512
* **Concretizer:** original
```

<!-- If you have any relevant configuration detail (custom `packages.yaml` or `modules.yaml`, etc.) you can add that here as well. -->

### Additional information

<!-- Please upload the following files. They should be present in the stage directory of the failing build. Also upload any config.log or similar file if one exists. -->
* [spack-build-out.txt](https://github.com/spack/spack/files/6489735/spack-build-out.txt)
* [spack-build-env.txt](https://github.com/spack/spack/files/6489736/spack-build-env.txt)

<!-- Some packages have maintainers who have volunteered to debug build failures. Run `spack maintainers <name-of-the-package>` and @mention them here if they exist. -->

@mwkrentel

### General information

<!-- These boxes can be checked by replacing [ ] with [x] or by clicking them after submitting the issue. -->
- [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:
@eschnett This kind of error usually is the result of a newer gcc/g++ becoming
more strict on some type of usage.  However, in this case, the error is,
"expected unqualified-id before '(' token" and the offending line is:

```
#define epsilon  (0.000001)
```

I guess I don't see what the problem is here.

Anyway, I'll compile up 11.x and see if I get the same error.

Thanks for reporting this.
I can confirm the build error with gcc 11.x.  The C++ header file
<limits> uses the name 'epsilon' in some templates which I think is
the real conflict, although the error message doesn't report that.

It's easy enough to fix (change epsilon to a different name).  But
fixing this exposed several other C++ usages that gcc 11.x didn't
like.  So, it may take a few days to clean them out with 11.x.

We were planning on a new release in the next few days and we thought
we were just about ready.  But now we'll hold the release to fix these
issues.
@eschnett I fixed the build issues with gcc 11.x.  If you'd like to try it out,
you should be able to install `hpctoolkit@master %gcc@11.1.0`.

We're planning on a new release in a few days.  I'll update the
hpctoolkit recipe at that time.
I confirm that the master branch builds with GCC 11.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/hpctoolkit/package.py b/var/spack/repos/builtin/packages/hpctoolkit/package.py
--- a/var/spack/repos/builtin/packages/hpctoolkit/package.py
+++ b/var/spack/repos/builtin/packages/hpctoolkit/package.py
@@ -4,7 +4,6 @@
 # SPDX-License-Identifier: (Apache-2.0 OR MIT)
 
 from spack import *
-from spack.util.environment import SetEnv
 
 
 class Hpctoolkit(AutotoolsPackage):
@@ -21,6 +20,7 @@ class Hpctoolkit(AutotoolsPackage):
 
     version('develop', branch='develop')
     version('master',  branch='master')
+    version('2021.05.15', commit='004ea0c2aea6a261e7d5d216c24f8a703fc6c408')
     version('2021.03.01', commit='68a051044c952f0f4dac459d9941875c700039e7')
     version('2020.08.03', commit='d9d13c705d81e5de38e624254cf0875cce6add9a')
     version('2020.07.21', commit='4e56c780cffc53875aca67d6472a2fb3678970eb')
@@ -61,6 +61,11 @@ class Hpctoolkit(AutotoolsPackage):
             description='Support ROCM on AMD GPUs, requires ROCM as '
             'external packages (2021.03.01 or later).')
 
+    variant('debug', default=False,
+            description='Build in debug (develop) mode.')
+
+    variant('viewer', default=True, description='Include hpcviewer.')
+
     boost_libs = (
         '+atomic +chrono +date_time +filesystem +system +thread +timer'
         ' +graph +regex +shared +multithreaded visibility=global'
@@ -87,9 +92,11 @@ class Hpctoolkit(AutotoolsPackage):
 
     depends_on('cuda', when='+cuda')
     depends_on('intel-xed', when='target=x86_64:')
+    depends_on('memkind', type=('build', 'run'), when='@2021.05.01:')
     depends_on('papi', when='+papi')
     depends_on('libpfm4', when='~papi')
     depends_on('mpi', when='+mpi')
+    depends_on('hpcviewer', type='run', when='+viewer')
 
     depends_on('hip', when='+rocm')
     depends_on('rocm-dbgapi', when='+rocm')
@@ -116,6 +123,10 @@ class Hpctoolkit(AutotoolsPackage):
     # Fix the build for old revs with gcc 10.x.
     patch('gcc10-enum.patch', when='@2020.01.01:2020.08.99 %gcc@10.0:')
 
+    patch('https://github.com/HPCToolkit/hpctoolkit/commit/511afd95b01d743edc5940c84e0079f462b2c23e.patch',
+          sha256='fd0fd7419f66a1feba8046cff9df7f27abce8629ee2708b8a9daa12c1b51243c',
+          when='@2019.08.01:2021.03.99 %gcc@11.0:')
+
     flag_handler = AutotoolsPackage.build_system_flags
 
     def configure_args(self):
@@ -144,7 +155,10 @@ def configure_args(self):
         if spec.target.family == 'x86_64':
             args.append('--with-xed=%s' % spec['intel-xed'].prefix)
 
-        if '+papi' in spec:
+        if spec.satisfies('@2021.05.01:'):
+            args.append('--with-memkind=%s' % spec['memkind'].prefix)
+
+        if spec.satisfies('+papi'):
             args.append('--with-papi=%s' % spec['papi'].prefix)
         else:
             args.append('--with-perfmon=%s' % spec['libpfm4'].prefix)
@@ -168,19 +182,20 @@ def configure_args(self):
         if '+all-static' in spec:
             args.append('--enable-all-static')
 
+        if spec.satisfies('+debug'):
+            args.append('--enable-develop')
+
         return args
 
-    # Remove setenv of ROCM, HIP, etc from the module file.  Loading
-    # the hpctoolkit module is not relevant to building a GPU app and
-    # some variables (HIP_PATH) intefere with building the app.
+    # We only want hpctoolkit and hpcviewer paths and man paths in the
+    # module file.  The run dependencies are all curried into hpctoolkit
+    # and we don't want to risk exposing a package if the application
+    # uses a different version of the same package.
     def setup_run_environment(self, env):
-        keeplist = []
-        for elt in env.env_modifications:
-            if not (isinstance(elt, SetEnv)
-                    and (elt.name.find('ROCM') >= 0
-                         or elt.name.find('HIP') >= 0
-                         or elt.name.find('CUDA') >= 0)):
-                keeplist.append(elt)
-
+        spec = self.spec
         env.clear()
-        env.env_modifications = keeplist
+        env.prepend_path('PATH', spec.prefix.bin)
+        env.prepend_path('MANPATH', spec.prefix.share.man)
+        if '+viewer' in spec:
+            env.prepend_path('PATH', spec['hpcviewer'].prefix.bin)
+            env.prepend_path('MANPATH', spec['hpcviewer'].prefix.share.man)


Test patch: