From d8390ee2fb42f2b7c45df1333810751907472523 Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 30 Apr 2021 15:04:06 -0700 Subject: HDF5: Suppress promoted warning that causes build failure on clang and gcc (#23354) * simplify compiler flag logic and suppress warning that gets promoted to an error on certain files in gcc/clang --- var/spack/repos/builtin/packages/hdf5/package.py | 37 ++++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/hdf5/package.py b/var/spack/repos/builtin/packages/hdf5/package.py index d4c8b916ac..b51e5d9167 100644 --- a/var/spack/repos/builtin/packages/hdf5/package.py +++ b/var/spack/repos/builtin/packages/hdf5/package.py @@ -298,22 +298,6 @@ class Hdf5(AutotoolsPackage): extra_args.append('--disable-shared') extra_args.append('--enable-static-exec') - if '+pic' in self.spec: - # use global spack compiler flags - _flags = self.compiler.cc_pic_flag - _flags += " " + ' '.join(self.spec.compiler_flags['cflags']) - extra_args.append('CFLAGS={0}'.format(_flags)) - - if '+cxx' in self.spec: - _flags = self.compiler.cxx_pic_flag - _flags += " " + ' '.join(self.spec.compiler_flags['cxxflags']) - extra_args.append('CXXFLAGS={0}'.format(_flags)) - - if '+fortran' in self.spec: - _flags = self.compiler.fc_pic_flag - _flags += " " + ' '.join(self.spec.compiler_flags['fflags']) - extra_args.append('FCFLAGS={0}'.format(_flags)) - # Fujitsu Compiler does not add Fortran runtime in rpath. if '+fortran %fj' in self.spec: extra_args.append('LDFLAGS=-lfj90i -lfj90f -lfjsrcinfo -lelf') @@ -333,6 +317,27 @@ class Hdf5(AutotoolsPackage): if '+fortran' in self.spec: extra_args.append('FC=%s' % self.spec['mpi'].mpifc) + # Append package specific compiler flags to the global ones + cflags = ' '.join(self.spec.compiler_flags['cflags']) + cxxflags = ' '.join(self.spec.compiler_flags['cxxflags']) + fflags = ' '.join(self.spec.compiler_flags['fflags']) + + if '+pic' in self.spec: + cflags += " " + self.compiler.cc_pic_flag + cxxflags += " " + self.compiler.cxx_pic_flag + fflags += " " + self.compiler.fc_pic_flag + + # Quiet warnings/errors about implicit declaration of functions in C99 + if "clang" in self.compiler.cc or "gcc" in self.compiler.cc: + cflags += " -Wno-implicit-function-declaration" + + if cflags: + extra_args.append('CFLAGS={0}'.format(cflags)) + if cxxflags and '+cxx' in self.spec: + extra_args.append('CXXFLAGS={0}'.format(cxxflags)) + if fflags and '+fortran' in self.spec: + extra_args.append('FCFLAGS={0}'.format(fflags)) + return extra_args @run_after('configure') -- cgit v1.2.3-70-g09d2