@@ -57,6 +57,7 @@ fn do_ctest() {
57
57
t if t. contains ( "emscripten" ) => test_emscripten ( t) ,
58
58
t if t. contains ( "freebsd" ) => test_freebsd ( t) ,
59
59
t if t. contains ( "haiku" ) => test_haiku ( t) ,
60
+ t if t. contains ( "l4re" ) => test_linux ( t) ,
60
61
t if t. contains ( "linux" ) => test_linux ( t) ,
61
62
t if t. contains ( "netbsd" ) => test_netbsd ( t) ,
62
63
t if t. contains ( "openbsd" ) => test_openbsd ( t) ,
@@ -96,9 +97,10 @@ fn do_semver() {
96
97
// NOTE: Android doesn't include the unix file (or the Linux file) because
97
98
// there are some many definitions missing it's actually easier just to
98
99
// maintain a file for Android.
99
- // NOTE: AIX doesn't include the unix file because there are definitions
100
- // missing on AIX. It is easier to maintain a file for AIX.
101
- if family != os && !matches ! ( os. as_str( ) , "android" | "aix" ) {
100
+ // NOTE: AIX and L4Re do not include the unix file because there are
101
+ // definitions missing on these systems. It is easier to maintain separate
102
+ // files for them.
103
+ if family != os && !matches ! ( os. as_str( ) , "android" | "aix" | "l4re" ) {
102
104
process_semver_file ( & mut output, & mut semver_root, & family) ;
103
105
}
104
106
// We don't do semver for unknown targets.
@@ -3653,18 +3655,26 @@ fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) {
3653
3655
}
3654
3656
3655
3657
fn test_linux ( target : & str ) {
3656
- assert ! ( target. contains( "linux" ) ) ;
3658
+ assert ! ( target. contains( "linux" ) || target. contains( "l4re" ) ) ;
3659
+
3660
+ // target_os
3661
+ let linux = target. contains ( "linux" ) ;
3662
+ let l4re = target. contains ( "l4re" ) ;
3657
3663
3658
3664
// target_env
3659
3665
let gnu = target. contains ( "gnu" ) ;
3660
3666
let musl = target. contains ( "musl" ) || target. contains ( "ohos" ) ;
3661
3667
let uclibc = target. contains ( "uclibc" ) ;
3662
3668
3663
- match ( gnu, musl, uclibc) {
3664
- ( true , false , false ) => ( ) ,
3665
- ( false , true , false ) => ( ) ,
3666
- ( false , false , true ) => ( ) ,
3667
- ( _, _, _) => panic ! ( "linux target lib is gnu: {gnu}, musl: {musl}, uclibc: {uclibc}" ) ,
3669
+ match ( linux, gnu, musl, uclibc) {
3670
+ ( true , true , false , false ) => ( ) ,
3671
+ ( true , false , true , false ) => ( ) ,
3672
+ ( true , false , false , true ) => ( ) ,
3673
+ ( false , false , false , true ) => ( ) ,
3674
+ ( _, _, _, _) => panic ! (
3675
+ "{} target lib is gnu: {gnu}, musl: {musl}, uclibc: {uclibc}" ,
3676
+ if linux { "linux" } else { "l4re" }
3677
+ ) ,
3668
3678
}
3669
3679
3670
3680
let arm = target. contains ( "arm" ) ;
@@ -3696,8 +3706,10 @@ fn test_linux(target: &str) {
3696
3706
// deprecated since glibc >= 2.29. This allows Rust binaries to link against
3697
3707
// glibc versions older than 2.29.
3698
3708
cfg. define ( "__GLIBC_USE_DEPRECATED_SCANF" , None ) ;
3699
-
3700
3709
config_gnu_bits ( target, & mut cfg) ;
3710
+ if l4re {
3711
+ cfg. flag ( "-Wno-unused-function" ) ;
3712
+ }
3701
3713
3702
3714
headers ! { cfg:
3703
3715
"ctype.h" ,
@@ -3716,11 +3728,12 @@ fn test_linux(target: &str) {
3716
3728
"libgen.h" ,
3717
3729
"limits.h" ,
3718
3730
"link.h" ,
3719
- "linux/sysctl.h" ,
3731
+ [ uclibc] : "linux/if_ether.h" ,
3732
+ [ linux] : "linux/sysctl.h" ,
3720
3733
"locale.h" ,
3721
3734
"malloc.h" ,
3722
3735
"mntent.h" ,
3723
- "mqueue.h" ,
3736
+ [ linux ] : "mqueue.h" ,
3724
3737
"net/ethernet.h" ,
3725
3738
"net/if.h" ,
3726
3739
"net/if_arp.h" ,
@@ -3730,6 +3743,7 @@ fn test_linux(target: &str) {
3730
3743
"netinet/ip.h" ,
3731
3744
"netinet/tcp.h" ,
3732
3745
"netinet/udp.h" ,
3746
+ [ l4re] : "netpacket/packet.h" ,
3733
3747
"poll.h" ,
3734
3748
"pthread.h" ,
3735
3749
"pty.h" ,
@@ -3740,43 +3754,44 @@ fn test_linux(target: &str) {
3740
3754
"semaphore.h" ,
3741
3755
"shadow.h" ,
3742
3756
"signal.h" ,
3743
- "spawn.h" ,
3744
- "stddef.h" ,
3757
+ [ linux ] : "spawn.h" ,
3758
+ [ linux ] : "stddef.h" ,
3745
3759
"stdint.h" ,
3746
3760
"stdio.h" ,
3747
3761
"stdlib.h" ,
3748
3762
"string.h" ,
3749
- "sys/epoll.h" ,
3750
- "sys/eventfd.h" ,
3763
+ [ l4re] : "sys/auxv.h" ,
3764
+ [ linux] : "sys/epoll.h" ,
3765
+ [ linux] : "sys/eventfd.h" ,
3751
3766
"sys/file.h" ,
3752
- "sys/fsuid.h" ,
3753
- "sys/klog.h" ,
3754
- "sys/inotify.h" ,
3767
+ [ linux ] : "sys/fsuid.h" ,
3768
+ [ linux ] : "sys/klog.h" ,
3769
+ [ linux ] : "sys/inotify.h" ,
3755
3770
"sys/ioctl.h" ,
3756
3771
"sys/ipc.h" ,
3757
3772
"sys/mman.h" ,
3758
3773
"sys/mount.h" ,
3759
- "sys/msg.h" ,
3760
- "sys/personality.h" ,
3774
+ [ linux ] : "sys/msg.h" ,
3775
+ [ linux ] : "sys/personality.h" ,
3761
3776
"sys/prctl.h" ,
3762
- "sys/ptrace.h" ,
3763
- "sys/quota.h" ,
3764
- "sys/random.h" ,
3765
- "sys/reboot.h" ,
3777
+ [ linux ] : "sys/ptrace.h" ,
3778
+ [ linux ] : "sys/quota.h" ,
3779
+ [ linux ] : "sys/random.h" ,
3780
+ [ linux ] : "sys/reboot.h" ,
3766
3781
"sys/resource.h" ,
3767
3782
"sys/sem.h" ,
3768
- "sys/sendfile.h" ,
3783
+ [ linux ] : "sys/sendfile.h" ,
3769
3784
"sys/shm.h" ,
3770
- "sys/signalfd.h" ,
3785
+ [ linux ] : "sys/signalfd.h" ,
3771
3786
"sys/socket.h" ,
3772
3787
"sys/stat.h" ,
3773
3788
"sys/statvfs.h" ,
3774
- "sys/swap.h" ,
3789
+ [ linux ] : "sys/swap.h" ,
3775
3790
"sys/syscall.h" ,
3776
3791
"sys/time.h" ,
3777
- "sys/timerfd.h" ,
3792
+ [ linux ] : "sys/timerfd.h" ,
3778
3793
"sys/times.h" ,
3779
- "sys/timex.h" ,
3794
+ [ linux ] : "sys/timex.h" ,
3780
3795
"sys/types.h" ,
3781
3796
"sys/uio.h" ,
3782
3797
"sys/un.h" ,
@@ -3798,12 +3813,12 @@ fn test_linux(target: &str) {
3798
3813
// ARM: https://bugzilla.redhat.com/show_bug.cgi?id=1116162
3799
3814
// Also unavailable on gnueabihf with glibc 2.30.
3800
3815
// https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=6b33f373c7b9199e00ba5fbafd94ac9bfb4337b1
3801
- [ ( x86_64 || x86_32 || arm) && !gnueabihf] : "sys/io.h" ,
3816
+ [ ( x86_64 || x86_32 || arm) && !gnueabihf && !l4re ] : "sys/io.h" ,
3802
3817
// `sys/reg.h` is only available on x86 and x86_64
3803
- [ x86_64 || x86_32] : "sys/reg.h" ,
3818
+ [ ( x86_64 || x86_32) && !l4re ] : "sys/reg.h" ,
3804
3819
// sysctl system call is deprecated and not available on musl
3805
3820
// It is also unsupported in x32, deprecated since glibc 2.30:
3806
- [ !( x32 || musl || gnu) ] : "sys/sysctl.h" ,
3821
+ [ !( x32 || musl || gnu || l4re ) ] : "sys/sysctl.h" ,
3807
3822
// <execinfo.h> is not supported by musl:
3808
3823
// https://www.openwall.com/lists/musl/2015/04/09/3
3809
3824
// <execinfo.h> is not present on uclibc.
@@ -3813,11 +3828,11 @@ fn test_linux(target: &str) {
3813
3828
// Include linux headers at the end:
3814
3829
headers ! {
3815
3830
cfg:
3816
- [ loongarch64 || riscv64] : "asm/hwcap.h" ,
3817
- "asm/mman.h" ,
3831
+ [ ( loongarch64 || riscv64) && !l4re ] : "asm/hwcap.h" ,
3832
+ [ linux ] : "asm/mman.h" ,
3818
3833
}
3819
3834
3820
- if !wasm32 {
3835
+ if !wasm32 && !l4re {
3821
3836
headers ! { cfg:
3822
3837
[ gnu] : "linux/aio_abi.h" ,
3823
3838
"linux/can.h" ,
@@ -3835,7 +3850,6 @@ fn test_linux(target: &str) {
3835
3850
"linux/if.h" ,
3836
3851
"linux/if_addr.h" ,
3837
3852
"linux/if_alg.h" ,
3838
- "linux/if_ether.h" ,
3839
3853
"linux/if_packet.h" ,
3840
3854
"linux/if_tun.h" ,
3841
3855
"linux/if_xdp.h" ,
@@ -3881,7 +3895,6 @@ fn test_linux(target: &str) {
3881
3895
"linux/wait.h" ,
3882
3896
"linux/wireless.h" ,
3883
3897
"sys/fanotify.h" ,
3884
- // <sys/auxv.h> is not present on uclibc
3885
3898
[ !uclibc] : "sys/auxv.h" ,
3886
3899
[ gnu || musl] : "linux/close_range.h" ,
3887
3900
}
@@ -3890,7 +3903,7 @@ fn test_linux(target: &str) {
3890
3903
// note: aio.h must be included before sys/mount.h
3891
3904
headers ! {
3892
3905
cfg:
3893
- "sys/xattr.h" ,
3906
+ [ linux ] : "sys/xattr.h" ,
3894
3907
"sys/sysinfo.h" ,
3895
3908
// AIO is not supported by uclibc:
3896
3909
[ !uclibc] : "aio.h" ,
@@ -3903,12 +3916,14 @@ fn test_linux(target: &str) {
3903
3916
| "Elf64_Shdr" | "Elf32_Sym" | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr"
3904
3917
| "Elf32_Chdr" | "Elf64_Chdr" => ty. to_string ( ) ,
3905
3918
3906
- "Ioctl" if gnu => "unsigned long" . to_string ( ) ,
3919
+ "Ioctl" if gnu || uclibc => "unsigned long" . to_string ( ) ,
3907
3920
"Ioctl" => "int" . to_string ( ) ,
3908
3921
3909
3922
// LFS64 types have been removed in musl 1.2.4+
3910
3923
"off64_t" if musl => "off_t" . to_string ( ) ,
3911
3924
3925
+ "fsword_t" if uclibc => "__SWORD_TYPE" . to_string ( ) ,
3926
+
3912
3927
// typedefs don't need any keywords
3913
3928
t if t. ends_with ( "_t" ) => t. to_string ( ) ,
3914
3929
// put `struct` in front of all structs:.
@@ -3956,6 +3971,8 @@ fn test_linux(target: &str) {
3956
3971
return true ;
3957
3972
}
3958
3973
match ty {
3974
+ t if t. starts_with ( "l4_" ) => true ,
3975
+
3959
3976
// FIXME(sighandler): `sighandler_t` type is incorrect, see:
3960
3977
// https://github.com/rust-lang/libc/issues/1359
3961
3978
"sighandler_t" => true ,
@@ -3990,6 +4007,10 @@ fn test_linux(target: &str) {
3990
4007
} ) ;
3991
4008
3992
4009
cfg. skip_struct ( move |ty| {
4010
+ if ty. starts_with ( "l4_" ) {
4011
+ return true ;
4012
+ }
4013
+
3993
4014
if ty. starts_with ( "__c_anonymous_" ) {
3994
4015
return true ;
3995
4016
}
@@ -4169,6 +4190,12 @@ fn test_linux(target: &str) {
4169
4190
} ) ;
4170
4191
4171
4192
cfg. skip_const ( move |name| {
4193
+ // L4Re requires a min stack size of 64k; that isn't defined in uClibc, but
4194
+ // somewhere in the core libraries. uClibc wants 16k, but that's not enough.
4195
+ if name == "PTHREAD_STACK_MIN" {
4196
+ return true ;
4197
+ }
4198
+
4172
4199
if !gnu {
4173
4200
// Skip definitions from the kernel on non-glibc Linux targets.
4174
4201
// They're libc-independent, so we only need to check them on one
@@ -4343,7 +4370,7 @@ fn test_linux(target: &str) {
4343
4370
4344
4371
// FIXME(musl): on musl the pthread types are defined a little differently
4345
4372
// - these constants are used by the glibc implementation.
4346
- n if musl && n. contains ( "__SIZEOF_PTHREAD" ) => true ,
4373
+ n if ( musl || uclibc ) && n. contains ( "__SIZEOF_PTHREAD" ) => true ,
4347
4374
4348
4375
// FIXME(linux): It was extended to 4096 since glibc 2.31 (Linux 5.4).
4349
4376
// We should do so after a while.
@@ -4655,6 +4682,8 @@ fn test_linux(target: &str) {
4655
4682
cfg. skip_fn ( move |name| {
4656
4683
// skip those that are manually verified
4657
4684
match name {
4685
+ n if n. starts_with ( "l4_" ) => true ,
4686
+
4658
4687
// There are two versions of the sterror_r function, see
4659
4688
//
4660
4689
// https://linux.die.net/man/3/strerror_r
@@ -4920,7 +4949,9 @@ fn test_linux(target: &str) {
4920
4949
4921
4950
cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "main.rs" ) ;
4922
4951
4923
- test_linux_like_apis ( target) ;
4952
+ if linux {
4953
+ test_linux_like_apis ( target) ;
4954
+ }
4924
4955
}
4925
4956
4926
4957
// This function tests APIs that are incompatible to test when other APIs
0 commit comments