diff --git a/libc-test/build.rs b/libc-test/build.rs
index 680136170f83f69c00114569fd896f1c152f5bb5..50082d8e2f68a292a20d8b5e7a48bc597541ee25 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -2260,6 +2260,17 @@ fn test_linux(target: &str) {
     // FIXME: still necessary?
     cfg.flag("-Wno-deprecated-declarations");
 
+    // note: aio.h must be included before sys/mount.h
+    if !uclibc {
+        assert!(gnu || musl);
+        // optionally included in uclibc
+        headers! { cfg:
+                   "sys/xattr.h",
+                   "sys/sysinfo.h",
+                   "aio.h",
+        }
+    }
+
     headers! { cfg:
                "ctype.h",
                "dirent.h",
@@ -2395,16 +2406,6 @@ fn test_linux(target: &str) {
         }
     }
 
-    if !uclibc {
-        assert!(gnu || musl);
-        // optionally included in uclibc
-        headers! { cfg:
-                   "sys/xattr.h",
-                   "sys/sysinfo.h",
-                   "aio.h",
-        }
-    }
-
     // DCCP support
     if !uclibc && !musl {
         assert!(gnu);