diff setup.py @ 31622:2243ba216f66

statfs: change Linux feature detection Previously we check three things: "statfs" function, "linux/magic.h" and "sys/vfs.h" headers. But we didn't check "struct statfs" or the "f_type" field. That means if a system has "statfs" but "struct statfs" is not defined in the two header files we check, or defined without the "f_type" field, the compilation will fail. This patch combines the checks (2 headers + 1 function + 1 field) together and sets "HAVE_LINUX_STATFS". It makes setup.py faster (less checks), and more reliable (immutable to the issue above).
author Jun Wu <quark@fb.com>
date Fri, 24 Mar 2017 14:59:19 -0700
parents ab51a2b18f87
children efcaf6ab86f4
line wrap: on
line diff
--- a/setup.py	Fri Mar 24 16:20:10 2017 -0700
+++ b/setup.py	Fri Mar 24 14:59:19 2017 -0700
@@ -591,24 +591,21 @@
 osutil_ldflags = []
 
 # platform specific macros
-for plat, func in [('bsd', 'setproctitle'), ('bsd|darwin|linux', 'statfs')]:
+for plat, func in [('bsd', 'setproctitle')]:
     if re.search(plat, sys.platform) and hasfunction(new_compiler(), func):
         osutil_cflags.append('-DHAVE_%s' % func.upper())
 
-for plat, header in [
-    ('linux', 'linux/magic.h'),
-    ('linux', 'sys/vfs.h'),
-]:
-    if re.search(plat, sys.platform) and hasheader(new_compiler(), header):
-        macro = header.replace('/', '_').replace('.', '_').upper()
-        osutil_cflags.append('-DHAVE_%s' % macro)
-
 for plat, macro, code in [
     ('bsd|darwin', 'BSD_STATFS', '''
      #include <sys/param.h>
      #include <sys/mount.h>
      int main() { struct statfs s; return sizeof(s.f_fstypename); }
      '''),
+    ('linux', 'LINUX_STATFS', '''
+     #include <linux/magic.h>
+     #include <sys/vfs.h>
+     int main() { struct statfs s; return sizeof(s.f_type); }
+     '''),
 ]:
     if re.search(plat, sys.platform) and cancompile(new_compiler(), code):
         osutil_cflags.append('-DHAVE_%s' % macro)