summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Henning <40867327+pjh40@users.noreply.github.com>2021-07-08 13:17:44 -0600
committerGitHub <noreply@github.com>2021-07-08 15:17:44 -0400
commit620836a80960396487b5eeba41c2a57c0b4674d2 (patch)
tree398fead7c88806c776b47da0cfe22935968325a8
parent0c5402ea5cf1e28c392aa455ca432040de9a830a (diff)
downloadspack-620836a80960396487b5eeba41c2a57c0b4674d2.tar.gz
spack-620836a80960396487b5eeba41c2a57c0b4674d2.tar.bz2
spack-620836a80960396487b5eeba41c2a57c0b4674d2.tar.xz
spack-620836a80960396487b5eeba41c2a57c0b4674d2.zip
hdf5: Fix compiler identification for warning flags (#24627)
* Fix compiler test Use `self.spec.satisfies` on compiler to determine if a flag should be applied or not. This approach avoids issues with the strings `gcc` or `clang` appearing in the full path to the compiler executables, as happens with spack-installed compilers (e.g. `nvhpc%gcc`). * Limit compiler name search to last path component @skosukhin pointed out that the cflag modification should happen for any clang or gcc compiler, regardless of what compiler spec provides them. This commit reverts to searching for a compiler name containing "gcc" or "clang", but limits the search to the last path component, which avoids matching spack-installed compilers built with gcc (e.g. `nvhpc%gcc`), which will have "gcc" in the compiler path. * Use `os.path` rather than `pathlib` Co-authored-by: Paul Henning <phenning@lanl.gov>
-rw-r--r--var/spack/repos/builtin/packages/hdf5/package.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/var/spack/repos/builtin/packages/hdf5/package.py b/var/spack/repos/builtin/packages/hdf5/package.py
index adc0510f43..e2910bfb5c 100644
--- a/var/spack/repos/builtin/packages/hdf5/package.py
+++ b/var/spack/repos/builtin/packages/hdf5/package.py
@@ -187,7 +187,8 @@ class Hdf5(CMakePackage):
cmake_flags = []
if name == "cflags":
- if "clang" in self.compiler.cc or "gcc" in self.compiler.cc:
+ cc_name = os.path.basename(self.compiler.cc)
+ if "clang" in cc_name or "gcc" in cc_name:
# Quiet warnings/errors about implicit declaration of functions
# in C99:
cmake_flags.append("-Wno-implicit-function-declaration")