diff --git a/var/spack/repos/builtin/packages/cctools/package.py b/var/spack/repos/builtin/packages/cctools/package.py
index 452df0d613d1051e6cb8d540d19a3b68466dd564..165d684a9ff51f6f5e3a10af594bffcbd1f64781 100644
--- a/var/spack/repos/builtin/packages/cctools/package.py
+++ b/var/spack/repos/builtin/packages/cctools/package.py
@@ -44,6 +44,18 @@ class Cctools(AutotoolsPackage):
     # depends_on('xrootd')
     depends_on('zlib')
 
+    # Generally SYS_foo is defined to __NR_foo (sys/syscall.h) which
+    # is then defined to a syscall number (asm/unistd_64.h).  Certain
+    # CentOS systems have SYS_memfd_create defined to
+    # __NR_memfd_create but are missing the second definition.
+    # This is a belt and suspenders solution to the problem.
+    def patch(self):
+        before = '#if defined(__linux__) && defined(SYS_memfd_create)'
+        after = '#if defined(__linux__) && defined(SYS_memfd_create) && defined(__NR_memfd_create)'  # noqa: E501
+        f = 'dttools/src/memfdexe.c'
+        kwargs = {'ignore_absent': False, 'backup': True, 'string': True}
+        filter_file(before, after, f, **kwargs)
+
     def configure_args(self):
         args = []
         # disable these bits