diff --git a/var/spack/repos/builtin/packages/wget/package.py b/var/spack/repos/builtin/packages/wget/package.py index cb3f64cf3e..511ab1375a 100644 --- a/var/spack/repos/builtin/packages/wget/package.py +++ b/var/spack/repos/builtin/packages/wget/package.py @@ -53,6 +53,16 @@ class Wget(AutotoolsPackage, GNUMirrorPackage): build_directory = 'spack-build' + def flag_handler(self, name, flags): + # gcc11 defaults to c17, which breaks compilation with older + # glibc versions as shipped with rhel7 and likely other OS + # versions too, feel free to add as necessary + older_glibc = self.spec.satisfies('os=rhel7') or \ + self.spec.satisfies('os=centos7') + if self.spec.satisfies('%gcc@11:') and older_glibc and name.lower() == 'cflags': + flags.append(self.compiler.c11_flag) + return (None, None, flags) + def configure_args(self): spec = self.spec