Repository: spack/spack

Issue:
Installation issue: perl%nvhpc
<!-- Explain, in a clear and concise way, the command you ran and the result you were trying to achieve.
Example: "I ran `spack find` to list all the installed packages and ..." -->

### Steps to reproduce the issue

```console
$ spack install netcdf-c%nvhpc@20.11  
...
```

### Error Message

<!-- If Spack reported an error, provide the error message. If it did not report an error but the output appears incorrect, provide the incorrect output. If there was no error message and no output but the result is incorrect, describe how it does not match what you expect. -->
```console
File Configure is read-only; trying to patch anyway
File cflags.SH is read-only; trying to patch anyway
1 out of 3 hunks FAILED -- saving rejects to file cflags.SH.rej
File ext/XS-APItest/Makefile.PL is read-only; trying to patch anyway
File Makefile.SH is read-only; trying to patch anyway
==> Patch /data_1/spack/var/spack/repos/builtin/packages/perl/nvhpc.patch failed.
==> Error: ProcessError: Command exited with status 1:
    '/usr/bin/patch' '-s' '-p' '1' '-i' '/data_1/spack/var/spack/repos/builtin/packages/perl/nvhpc.patch' '-d' '.'
==> Warning: Skipping build of autoconf-2.69-wzqetfhypa5kynawjfrftuwlywnwuyv2 since perl-5.32.0-75lpxu3syhzqmfoohlhr7cq2sadzanrq failed
==> Warning: Skipping build of automake-1.16.3-jxzqssyewlg4nr7a6ztrx4xv3kyoyfqu since autoconf-2.69-wzqetfhypa5kynawjfrftuwlywnwuyv2 failed
==> Warning: Skipping build of numactl-2.0.14-hoql3ryprljvmi6s2qtlbu5balu44yt4 since automake-1.16.3-jxzqssyewlg4nr7a6ztrx4xv3kyoyfqu failed
==> Warning: Skipping build of openmpi-4.0.5-qh76slw67wov5aavh5rt4v6s45zssupx since numactl-2.0.14-hoql3ryprljvmi6s2qtlbu5balu44yt4 failed
==> Warning: Skipping build of netcdf-c-4.7.4-j2i5og7wwexnhrlanx7ivytn6tpn4wzo since openmpi-4.0.5-qh76slw67wov5aavh5rt4v6s45zssupx failed
==> Warning: Skipping build of hdf5-1.10.7-azqlzmx7ddgurbxumdkvzvgcikbspkpo since openmpi-4.0.5-qh76slw67wov5aavh5rt4v6s45zssupx failed
==> Warning: Skipping build of openssl-1.1.1i-vdi34eptp464lb2l5nifgmit3rhchajo since perl-5.32.0-75lpxu3syhzqmfoohlhr7cq2sadzanrq failed
==> Warning: Skipping build of libevent-2.1.8-yvt52dg3bbukcuzac7ytsroczcj4x6sq since openssl-1.1.1i-vdi34eptp464lb2l5nifgmit3rhchajo failed

```

### Information on your system

* **Spack:** 0.16.0
* **Python:** 3.7.7
* **Platform:** linux-ubuntu20.04-skylake
* **Concretizer:** original


### Additional 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 searched the issues of this repo and believe this is not a duplicate
- [x] I have run the failing commands in debug mode and reported the output

<!-- 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!

If you want to ask a question about the tool (how to use it, what it can currently do, etc.), try the `#general` channel on our Slack first. We have a welcoming community and chances are you'll get your reply faster and without opening an issue.

Other than that, thanks for taking the time to contribute to Spack! -->



Discussion:
@samcmill can you take a look at this? You added this `%nvhpc` patch in #19452, and a more recent PR changed the default version of Perl. You should check which versions of Perl your patch works for and restrict it to those versions. You may need to create a new patch for 5.32.0+ if it hasn't been patched upstream yet.
Yes, I'll take a look.
There are 2 issues:
1. The current patch does not apply cleanly to 5.32.0
2. Even with the patch issues resolved, the NV compiler 20.11 has trouble with Perl 5.32.0

Unless there are objections, I will submit a PR that:
1. Restricts the current patch to 5.30.x
2. Sets a conflict for 5.32 and `%nvhpc`

As a workaround, you can use `spack install netcdf-c%nvhpc@20.11 ^perl@5.30.3`
> There are 2 issues:
> 
>     1. The current patch does not apply cleanly to 5.32.0
> 
>     2. Even with the patch issues resolved, the NV compiler 20.11 has trouble with Perl 5.32.0
> 
> 
> Unless there are objections, I will submit a PR that:
> 
>     1. Restricts the current patch to 5.30.x
> 
>     2. Sets a conflict for 5.32 and `%nvhpc`
> 
> 
> As a workaround, you can use `spack install netcdf-c%nvhpc@20.11 ^perl@5.30.3`

@samcmill It works. Thank you!

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/perl/package.py b/var/spack/repos/builtin/packages/perl/package.py
--- a/var/spack/repos/builtin/packages/perl/package.py
+++ b/var/spack/repos/builtin/packages/perl/package.py
@@ -77,7 +77,9 @@ class Perl(Package):  # Perl doesn't use Autotools, it should subclass Package
     patch('macos-11-version-check.patch', when='@5.24.1:5.32.0 platform=darwin')
 
     # Enable builds with the NVIDIA compiler
-    patch('nvhpc.patch', when='%nvhpc')
+    patch('nvhpc-5.30.patch', when='@5.30.0:5.30.99 %nvhpc')
+    conflicts('@5.32.0:', when='%nvhpc',
+              msg='The NVIDIA compilers are incompatible with version 5.32 and later')
 
     # Installing cpanm alongside the core makes it safe and simple for
     # people/projects to install their own sets of perl modules.  Not


Test patch: