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
==> Installing hpctoolkit-2021.03.01-cu24uuwungpo3s52tki4m3qqf6kf4ag7
==> No binary for hpctoolkit-2021.03.01-cu24uuwungpo3s52tki4m3qqf6kf4ag7 found: installing from source
==> Using cached archive: /home/eschnetter/src/CarpetX/spack/var/spack/cache/_source-cache/git//HPCToolkit/hpctoolkit.git/68a051044c952f0f4dac459d9941875c700039e7.tar.gz
==> Warning: Fetching from mirror without a checksum!
  This package is normally checked out from a version control system, but it has been archived on a spack mirror.  This means we cannot know a checksum for the tarball in advance. Be sure that your connection to this mirror is secure!
==> Using cached archive: /home/eschnetter/src/CarpetX/spack/var/spack/cache/_source-cache/archive/f8/f8507c3ce9672c70c2db9f9deb5766c8120ea06e20866d0f553a17866e810b91
Reversed (or previously applied) patch detected!  Assume -R? [n]
Apply anyway? [n]
1 out of 1 hunk ignored -- saving rejects to file src/tool/hpcrun/gpu/gpu-metrics.h.rej
==> Patch https://github.com/blue42u/hpctoolkit/commit/b3f6f9e4846d9256cf0d841465ff89d78c6bf422.patch failed.
==> Error: ProcessError: Command exited with status 1:
    '/usr/bin/patch' '-s' '-p' '1' '-i' '/tmp/eschnetter/spack-stage/spack-stage-n4_0zhk7/b3f6f9e4846d9256cf0d841465ff89d78c6bf422.patch' '-d' '.'
```

### Information on your system

<!-- Please include the output of `spack debug report` -->
```
spack debug report
* **Spack:** 0.16.1-2176-85e70600ed
* **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]()
* [spack-build-env.txt]()

I could not find these files – maybe they were not yet generated?
```
$ ls /tmp/eschnetter/spack-stage/*
/tmp/eschnetter/spack-stage/spack-stage-hpctoolkit-2021.03.01-cu24uuwungpo3s52tki4m3qqf6kf4ag7:
68a051044c952f0f4dac459d9941875c700039e7.tar.gz  spack-src
```

<!-- 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   Let me guess, you're using gcc 10.x ?

There was an ill-advised commit (#22864) that added a patch to
hpctoolkit for gcc 10.  (The didn't tell me.)  The problem is that the
patch is applied unconditionally to all revs but should be applied
only to an old rev.

Try removing the patch from hpctoolkit/package.py and I'll submit a PR
to fix the recipe.

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
@@ -113,12 +113,8 @@ class Hpctoolkit(AutotoolsPackage):
     conflicts('^binutils@2.35:2.35.1',
               msg='avoid binutils 2.35 and 2.35.1 (spews errors)')
 
-    # Fixes multiple definition error with GCC 10.
-    # https://github.com/HPCToolkit/hpctoolkit/issues/309
-    patch('https://github.com/blue42u/hpctoolkit/commit/'
-          'b3f6f9e4846d9256cf0d841465ff89d78c6bf422.patch',
-          when='%gcc@10',
-          sha256='f8507c3ce9672c70c2db9f9deb5766c8120ea06e20866d0f553a17866e810b91')
+    # Fix the build for old revs with gcc 10.x.
+    patch('gcc10-enum.patch', when='@2020.01.01:2020.08.99 %gcc@10.0:')
 
     flag_handler = AutotoolsPackage.build_system_flags
 


Test patch: