Repository: spack/spack

Issue:
Installation issue: metis - metis not building with %nvhpc
When attempting to build metis using %nvhpc the compilation fails due to various minor compilation warnings (e.g. unused
variables, etc), which get promoted to errors because of the  compilation -Werror flag.

### Steps to reproduce the issue

```console
$ spack install metis@5.1.0%nvhpc
...
"/tmp/spackswinst/spack-stage/spack-stage-metis-5.1.0-3y4wrhkglwd5ekzn2qxtqchhudb4of2c/spack-src/GKlib/fs.c", line 190: error: variable "endptr" was set but never used
    char *endptr, *tmp;
          ^

1 error detected in the compilation of "/tmp/spackswinst/spack-stage/spack-stage-metis-
```
The above is only the first such instance of such an error encountered in the compilation of metis; I found about a dozen files have these and similar errors ( e.g.
* variable "foo" was set but never used
* variable "foo" was declared but never referenced
* statement is unreachable
* enumerated type mixed with another type
)

### Information on your system

```console
$spack debug report
* **Spack:** 0.16.1-2429-f5e6c32495
* **Python:** 3.6.8
* **Platform:** linux-rhel8-x86_64
* **Concretizer:** original
```

My nvhpc is is @21.5, setup as an external package in Spack, and the compiler definition in Spack adds the flag
'--noswitcherror' to cflags, cxxflags, and fcflags (to reduce the number of failed packages due to nvhpc not recognizing flags gcc and icc recognize).


### 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/6856540/spack-build-out.txt)
* [spack-build-env.txt](https://github.com/spack/spack/files/6856541/spack-build-env.txt)

No maintainers for metis

### 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:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/metis/package.py b/var/spack/repos/builtin/packages/metis/package.py
--- a/var/spack/repos/builtin/packages/metis/package.py
+++ b/var/spack/repos/builtin/packages/metis/package.py
@@ -53,6 +53,17 @@ def setup_build_environment(self, env):
         # Ignore warnings/errors re unrecognized omp pragmas on %intel
         if '%intel@14:' in self.spec:
             env.append_flags('CFLAGS', '-diag-disable 3180')
+        # Ignore some warnings to get it to compile with %nvhpc
+        #   111: statement is unreachable
+        #   177: variable "foo" was declared but never referenced
+        #   188: enumerated type mixed with another type
+        #   550: variable "foo" was set but never used
+        if '%nvhpc' in self.spec:
+            env.append_flags('CFLAGS', '--display_error_number')
+            env.append_flags('CFLAGS', '--diag_suppress 111')
+            env.append_flags('CFLAGS', '--diag_suppress 177')
+            env.append_flags('CFLAGS', '--diag_suppress 188')
+            env.append_flags('CFLAGS', '--diag_suppress 550')
 
     @when('@5:')
     def patch(self):


Test patch: