hdf5: fix compiler detection in flag_handler (#24451)

The original implementation of `flag_handler` searched the
`self.compiler.cc` string for `clang` or `gcc` in order to add a flag
for those compilers.  This approach fails when using a spack-installed
compiler that was itself built with gcc or clang, as those strings will
appear in the fully-qualified compiler executable paths.  This commit
switches to searching for `%gcc` or `%clang` in `self.spec`.

Co-authored-by: Paul Henning <phenning@lanl.gov>
This commit is contained in:
Paul Henning 2021-06-22 00:36:28 -06:00 committed by GitHub
parent 5e48d2c16f
commit 3039237a0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -185,7 +185,7 @@ def flag_handler(self, name, flags):
# Quiet warnings/errors about implicit declaration of functions in C99
if name == "cflags":
if "clang" in self.compiler.cc or "gcc" in self.compiler.cc:
if "%clang" in self.spec or "%gcc" in self.spec:
flags.append("-Wno-implicit-function-declaration")
return (None, None, flags)