@@ -2561,6 +2561,39 @@ fn test_linux(target: &str) {
2561
2561
} ) ;
2562
2562
2563
2563
cfg. skip_const ( move |name| {
2564
+ if !gnu {
2565
+ // Skip definitions from the kernel on non-glibc Linux targets.
2566
+ // They're libc-independent, so we only need to check them on one
2567
+ // libc. We don't want to break CI if musl or another libc doesn't
2568
+ // have the definitions yet. (We do still want to check them on
2569
+ // every glibc target, though, as some of them can vary by
2570
+ // architecture.)
2571
+ //
2572
+ // This is not an exhaustive list of kernel constants, just a list
2573
+ // of prefixes of all those that have appeared here or that get
2574
+ // updated regularly and seem likely to cause breakage.
2575
+ if name. starts_with ( "AF_" )
2576
+ || name. starts_with ( "ARPHRD_" )
2577
+ || name. starts_with ( "EPOLL" )
2578
+ || name. starts_with ( "F_" )
2579
+ || name. starts_with ( "FALLOC_FL_" )
2580
+ || name. starts_with ( "IFLA_" )
2581
+ || name. starts_with ( "MS_" )
2582
+ || name. starts_with ( "MSG_" )
2583
+ || name. starts_with ( "P_" )
2584
+ || name. starts_with ( "PF_" )
2585
+ || name. starts_with ( "RLIMIT_" )
2586
+ || name. starts_with ( "SOL_" )
2587
+ || name. starts_with ( "STATX_" )
2588
+ || name. starts_with ( "SW_" )
2589
+ || name. starts_with ( "SYS_" )
2590
+ || name. starts_with ( "TCP_" )
2591
+ || name. starts_with ( "UINPUT_" )
2592
+ || name. starts_with ( "VMADDR_" )
2593
+ {
2594
+ return true ;
2595
+ }
2596
+ }
2564
2597
match name {
2565
2598
// These constants are not available if gnu headers have been included
2566
2599
// and can therefore not be tested here
@@ -2580,25 +2613,9 @@ fn test_linux(target: &str) {
2580
2613
| "F_SEAL_GROW"
2581
2614
| "F_SEAL_WRITE" => true ,
2582
2615
2583
- // The musl-sanitized kernel headers used in CI
2584
- // target the Linux kernel 4.4 and do not contain the
2585
- // following constants:
2586
- //
2587
- // Requires Linux kernel 4.9
2588
- | "FALLOC_FL_UNSHARE_RANGE"
2589
- //
2590
- // Require Linux kernel 5.x:
2591
- | "MSG_COPY"
2592
- if musl => true ,
2593
2616
// Require Linux kernel 5.1:
2594
2617
"F_SEAL_FUTURE_WRITE" => true ,
2595
2618
2596
- // The musl version 1.1.24 used in CI does not
2597
- // contain these glibc constants yet:
2598
- | "RLIMIT_RTTIME" // should be in `resource.h`
2599
- | "TCP_COOKIE_TRANSACTIONS" // should be in the `netinet/tcp.h` header
2600
- if musl => true ,
2601
-
2602
2619
// FIXME: deprecated: not available in any header
2603
2620
// See: https://github.com/rust-lang/libc/issues/1356
2604
2621
"ENOATTR" => true ,
@@ -2629,33 +2646,13 @@ fn test_linux(target: &str) {
2629
2646
| "IPPROTO_MAX"
2630
2647
| "IPPROTO_MPTCP" => true ,
2631
2648
2632
- // Defined in kernel headers but musl removes it; need musl 1.2 for definition in musl
2633
- // headers.
2634
- "P_PIDFD" => true ,
2635
-
2636
2649
// FIXME: Not currently available in headers
2650
+ "P_PIDFD" if mips => true ,
2637
2651
"SYS_pidfd_open" if mips => true ,
2638
2652
2639
2653
// FIXME: Not currently available in headers on MIPS
2640
2654
// Not yet implemented on sparc64
2641
- // FIXME: available in musl headers since musl 1.2.0
2642
- "SYS_clone3" if mips | sparc64 | musl => true ,
2643
-
2644
- // Missing from musl's kernel headers
2645
- | "IFLA_GSO_MAX_SEGS"
2646
- | "IFLA_GSO_MAX_SIZE"
2647
- | "IFLA_PAD"
2648
- | "IFLA_XDP"
2649
- | "IFLA_EVENT"
2650
- | "IFLA_NEW_NETNSID"
2651
- | "IFLA_IF_NETNSID"
2652
- | "IFLA_TARGET_NETNSID"
2653
- | "IFLA_CARRIER_UP_COUNT"
2654
- | "IFLA_CARRIER_DOWN_COUNT"
2655
- | "IFLA_NEW_IFINDEX"
2656
- | "IFLA_MIN_MTU"
2657
- | "IFLA_MAX_MTU"
2658
- if musl => true ,
2655
+ "SYS_clone3" if mips | sparc64 => true ,
2659
2656
2660
2657
// Requires more recent kernel headers:
2661
2658
| "IFLA_PROP_LIST"
@@ -2668,23 +2665,14 @@ fn test_linux(target: &str) {
2668
2665
| "CAN_RAW_FILTER_MAX"
2669
2666
| "CAN_NPROTO" => true ,
2670
2667
2671
- "MS_RMT_MASK" if uclibc => true , // updated in glibc 2.22 and musl 1.1.13
2672
-
2673
- // These are not defined in uclibc but will be passed through to the kernel
2674
- // so they will be supported if the kernel supports them. Otherwise the
2675
- // kernel will return runtime errors. Since they're required for tokio
2676
- // support, we except them from the tests here.
2677
- // See https://github.com/rust-lang/libc/pull/2019#issuecomment-754351482
2678
- "EPOLLEXCLUSIVE" | "EPOLLWAKEUP" if uclibc => true ,
2679
-
2680
2668
// FIXME: Requires recent kernel headers (5.8):
2681
2669
"STATX_MNT_ID" => true ,
2682
2670
2683
2671
// FIXME: requires more recent kernel headers on CI
2684
2672
| "UINPUT_VERSION"
2685
2673
| "SW_MAX"
2686
2674
| "SW_CNT"
2687
- if musl || mips || ppc64 || riscv64 || sparc64 => true ,
2675
+ if mips || ppc64 || riscv64 || sparc64 => true ,
2688
2676
2689
2677
_ => false ,
2690
2678
}
0 commit comments