@@ -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.
@@ -3660,18 +3662,26 @@ fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) {
3660
3662
}
3661
3663
3662
3664
fn test_linux ( target : & str ) {
3663
- assert ! ( target. contains( "linux" ) ) ;
3665
+ assert ! ( target. contains( "linux" ) || target. contains( "l4re" ) ) ;
3666
+
3667
+ // target_os
3668
+ let linux = target. contains ( "linux" ) ;
3669
+ let l4re = target. contains ( "l4re" ) ;
3664
3670
3665
3671
// target_env
3666
3672
let gnu = target. contains ( "gnu" ) ;
3667
3673
let musl = target. contains ( "musl" ) || target. contains ( "ohos" ) ;
3668
3674
let uclibc = target. contains ( "uclibc" ) ;
3669
3675
3670
- match ( gnu, musl, uclibc) {
3671
- ( true , false , false ) => ( ) ,
3672
- ( false , true , false ) => ( ) ,
3673
- ( false , false , true ) => ( ) ,
3674
- ( _, _, _) => panic ! ( "linux target lib is gnu: {gnu}, musl: {musl}, uclibc: {uclibc}" ) ,
3676
+ match ( linux, gnu, musl, uclibc) {
3677
+ ( true , true , false , false ) => ( ) ,
3678
+ ( true , false , true , false ) => ( ) ,
3679
+ ( true , false , false , true ) => ( ) ,
3680
+ ( false , false , false , true ) => ( ) ,
3681
+ ( _, _, _, _) => panic ! (
3682
+ "{} target lib is gnu: {gnu}, musl: {musl}, uclibc: {uclibc}" ,
3683
+ if linux { "linux" } else { "l4re" }
3684
+ ) ,
3675
3685
}
3676
3686
3677
3687
let arm = target. contains ( "arm" ) ;
@@ -3703,8 +3713,10 @@ fn test_linux(target: &str) {
3703
3713
// deprecated since glibc >= 2.29. This allows Rust binaries to link against
3704
3714
// glibc versions older than 2.29.
3705
3715
cfg. define ( "__GLIBC_USE_DEPRECATED_SCANF" , None ) ;
3706
-
3707
3716
config_gnu_bits ( target, & mut cfg) ;
3717
+ if l4re {
3718
+ cfg. flag ( "-Wno-unused-function" ) ;
3719
+ }
3708
3720
3709
3721
headers ! { cfg:
3710
3722
"ctype.h" ,
@@ -3723,11 +3735,12 @@ fn test_linux(target: &str) {
3723
3735
"libgen.h" ,
3724
3736
"limits.h" ,
3725
3737
"link.h" ,
3726
- "linux/sysctl.h" ,
3738
+ [ uclibc] : "linux/if_ether.h" ,
3739
+ [ !l4re] : "linux/sysctl.h" ,
3727
3740
"locale.h" ,
3728
3741
"malloc.h" ,
3729
3742
"mntent.h" ,
3730
- "mqueue.h" ,
3743
+ [ !l4re ] : "mqueue.h" ,
3731
3744
"net/ethernet.h" ,
3732
3745
"net/if.h" ,
3733
3746
"net/if_arp.h" ,
@@ -3737,6 +3750,7 @@ fn test_linux(target: &str) {
3737
3750
"netinet/ip.h" ,
3738
3751
"netinet/tcp.h" ,
3739
3752
"netinet/udp.h" ,
3753
+ [ l4re] : "netpacket/packet.h" ,
3740
3754
"poll.h" ,
3741
3755
"pthread.h" ,
3742
3756
"pty.h" ,
@@ -3747,43 +3761,44 @@ fn test_linux(target: &str) {
3747
3761
"semaphore.h" ,
3748
3762
"shadow.h" ,
3749
3763
"signal.h" ,
3750
- "spawn.h" ,
3751
- "stddef.h" ,
3764
+ [ !l4re ] : "spawn.h" ,
3765
+ [ !l4re ] : "stddef.h" ,
3752
3766
"stdint.h" ,
3753
3767
"stdio.h" ,
3754
3768
"stdlib.h" ,
3755
3769
"string.h" ,
3756
- "sys/epoll.h" ,
3757
- "sys/eventfd.h" ,
3770
+ [ l4re] : "sys/auxv.h" ,
3771
+ [ !l4re] : "sys/epoll.h" ,
3772
+ [ !l4re] : "sys/eventfd.h" ,
3758
3773
"sys/file.h" ,
3759
- "sys/fsuid.h" ,
3760
- "sys/klog.h" ,
3761
- "sys/inotify.h" ,
3774
+ [ !l4re ] : "sys/fsuid.h" ,
3775
+ [ !l4re ] : "sys/klog.h" ,
3776
+ [ !l4re ] : "sys/inotify.h" ,
3762
3777
"sys/ioctl.h" ,
3763
3778
"sys/ipc.h" ,
3764
3779
"sys/mman.h" ,
3765
3780
"sys/mount.h" ,
3766
- "sys/msg.h" ,
3767
- "sys/personality.h" ,
3781
+ [ !l4re ] : "sys/msg.h" ,
3782
+ [ !l4re ] : "sys/personality.h" ,
3768
3783
"sys/prctl.h" ,
3769
- "sys/ptrace.h" ,
3770
- "sys/quota.h" ,
3771
- "sys/random.h" ,
3772
- "sys/reboot.h" ,
3784
+ [ !l4re ] : "sys/ptrace.h" ,
3785
+ [ !l4re ] : "sys/quota.h" ,
3786
+ [ !l4re ] : "sys/random.h" ,
3787
+ [ !l4re ] : "sys/reboot.h" ,
3773
3788
"sys/resource.h" ,
3774
3789
"sys/sem.h" ,
3775
- "sys/sendfile.h" ,
3790
+ [ !l4re ] : "sys/sendfile.h" ,
3776
3791
"sys/shm.h" ,
3777
- "sys/signalfd.h" ,
3792
+ [ !l4re ] : "sys/signalfd.h" ,
3778
3793
"sys/socket.h" ,
3779
3794
"sys/stat.h" ,
3780
3795
"sys/statvfs.h" ,
3781
- "sys/swap.h" ,
3796
+ [ !l4re ] : "sys/swap.h" ,
3782
3797
"sys/syscall.h" ,
3783
3798
"sys/time.h" ,
3784
- "sys/timerfd.h" ,
3799
+ [ !l4re ] : "sys/timerfd.h" ,
3785
3800
"sys/times.h" ,
3786
- "sys/timex.h" ,
3801
+ [ !l4re ] : "sys/timex.h" ,
3787
3802
"sys/types.h" ,
3788
3803
"sys/uio.h" ,
3789
3804
"sys/un.h" ,
@@ -3805,12 +3820,12 @@ fn test_linux(target: &str) {
3805
3820
// ARM: https://bugzilla.redhat.com/show_bug.cgi?id=1116162
3806
3821
// Also unavailable on gnueabihf with glibc 2.30.
3807
3822
// https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=6b33f373c7b9199e00ba5fbafd94ac9bfb4337b1
3808
- [ ( x86_64 || x86_32 || arm) && !gnueabihf] : "sys/io.h" ,
3823
+ [ ( x86_64 || x86_32 || arm) && !gnueabihf && !l4re ] : "sys/io.h" ,
3809
3824
// `sys/reg.h` is only available on x86 and x86_64
3810
- [ x86_64 || x86_32] : "sys/reg.h" ,
3825
+ [ ( x86_64 || x86_32) && !l4re ] : "sys/reg.h" ,
3811
3826
// sysctl system call is deprecated and not available on musl
3812
3827
// It is also unsupported in x32, deprecated since glibc 2.30:
3813
- [ !( x32 || musl || gnu) ] : "sys/sysctl.h" ,
3828
+ [ !( x32 || musl || gnu || l4re ) ] : "sys/sysctl.h" ,
3814
3829
// <execinfo.h> is not supported by musl:
3815
3830
// https://www.openwall.com/lists/musl/2015/04/09/3
3816
3831
// <execinfo.h> is not present on uclibc.
@@ -3820,11 +3835,11 @@ fn test_linux(target: &str) {
3820
3835
// Include linux headers at the end:
3821
3836
headers ! {
3822
3837
cfg:
3823
- [ loongarch64 || riscv64] : "asm/hwcap.h" ,
3824
- "asm/mman.h" ,
3838
+ [ ( loongarch64 || riscv64) && !l4re ] : "asm/hwcap.h" ,
3839
+ [ !l4re ] : "asm/mman.h" ,
3825
3840
}
3826
3841
3827
- if !wasm32 {
3842
+ if !wasm32 && !l4re {
3828
3843
headers ! { cfg:
3829
3844
[ gnu] : "linux/aio_abi.h" ,
3830
3845
"linux/can.h" ,
@@ -3842,7 +3857,6 @@ fn test_linux(target: &str) {
3842
3857
"linux/if.h" ,
3843
3858
"linux/if_addr.h" ,
3844
3859
"linux/if_alg.h" ,
3845
- "linux/if_ether.h" ,
3846
3860
"linux/if_packet.h" ,
3847
3861
"linux/if_tun.h" ,
3848
3862
"linux/if_xdp.h" ,
@@ -3889,7 +3903,6 @@ fn test_linux(target: &str) {
3889
3903
"linux/wait.h" ,
3890
3904
"linux/wireless.h" ,
3891
3905
"sys/fanotify.h" ,
3892
- // <sys/auxv.h> is not present on uclibc
3893
3906
[ !uclibc] : "sys/auxv.h" ,
3894
3907
[ gnu || musl] : "linux/close_range.h" ,
3895
3908
}
@@ -3898,7 +3911,7 @@ fn test_linux(target: &str) {
3898
3911
// note: aio.h must be included before sys/mount.h
3899
3912
headers ! {
3900
3913
cfg:
3901
- "sys/xattr.h" ,
3914
+ [ !l4re ] : "sys/xattr.h" ,
3902
3915
"sys/sysinfo.h" ,
3903
3916
// AIO is not supported by uclibc:
3904
3917
[ !uclibc] : "aio.h" ,
@@ -3911,12 +3924,14 @@ fn test_linux(target: &str) {
3911
3924
| "Elf64_Shdr" | "Elf32_Sym" | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr"
3912
3925
| "Elf32_Chdr" | "Elf64_Chdr" => ty. to_string ( ) ,
3913
3926
3914
- "Ioctl" if gnu => "unsigned long" . to_string ( ) ,
3927
+ "Ioctl" if gnu || uclibc => "unsigned long" . to_string ( ) ,
3915
3928
"Ioctl" => "int" . to_string ( ) ,
3916
3929
3917
3930
// LFS64 types have been removed in musl 1.2.4+
3918
3931
"off64_t" if musl => "off_t" . to_string ( ) ,
3919
3932
3933
+ "fsword_t" if uclibc => "__SWORD_TYPE" . to_string ( ) ,
3934
+
3920
3935
// typedefs don't need any keywords
3921
3936
t if t. ends_with ( "_t" ) => t. to_string ( ) ,
3922
3937
// put `struct` in front of all structs:.
@@ -4177,6 +4192,12 @@ fn test_linux(target: &str) {
4177
4192
} ) ;
4178
4193
4179
4194
cfg. skip_const ( move |name| {
4195
+ // L4Re requires a min stack size of 64k; that isn't defined in uClibc, but
4196
+ // somewhere in the core libraries. uClibc wants 16k, but that's not enough.
4197
+ if l4re && name == "PTHREAD_STACK_MIN" {
4198
+ return true ;
4199
+ }
4200
+
4180
4201
if !gnu {
4181
4202
// Skip definitions from the kernel on non-glibc Linux targets.
4182
4203
// They're libc-independent, so we only need to check them on one
@@ -4356,7 +4377,7 @@ fn test_linux(target: &str) {
4356
4377
4357
4378
// FIXME(musl): on musl the pthread types are defined a little differently
4358
4379
// - these constants are used by the glibc implementation.
4359
- n if musl && n. contains ( "__SIZEOF_PTHREAD" ) => true ,
4380
+ n if ( musl || uclibc ) && n. contains ( "__SIZEOF_PTHREAD" ) => true ,
4360
4381
4361
4382
// FIXME(linux): It was extended to 4096 since glibc 2.31 (Linux 5.4).
4362
4383
// We should do so after a while.
@@ -4933,7 +4954,9 @@ fn test_linux(target: &str) {
4933
4954
4934
4955
cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "main.rs" ) ;
4935
4956
4936
- test_linux_like_apis ( target) ;
4957
+ if !l4re {
4958
+ test_linux_like_apis ( target) ;
4959
+ }
4937
4960
}
4938
4961
4939
4962
// This function tests APIs that are incompatible to test when other APIs
0 commit comments