Skip to content

Commit

Permalink
Fix libc-tests for loongarch64-linux-musl
Browse files Browse the repository at this point in the history
(backport <rust-lang#4092>)
(cherry picked from commit bfdc370)
  • Loading branch information
heiher authored and tgross35 committed Nov 19, 2024
1 parent 7f53c72 commit 91989b6
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 50 deletions.
10 changes: 5 additions & 5 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4555,14 +4555,14 @@ fn test_linux(target: &str) {
(struct_ == "iw_encode_ext" && field == "key") ||
// the `tcpi_snd_rcv_wscale` map two bitfield fields stored in a u8
(struct_ == "tcp_info" && field == "tcpi_snd_rcv_wscale") ||
// the `tcpi_delivery_rate_app_limited` field is a bitfield on musl
(musl && struct_ == "tcp_info" && field == "tcpi_delivery_rate_app_limited") ||
// the `tcpi_fast_open_client_fail` field is a bitfield on musl
(musl && struct_ == "tcp_info" && field == "tcpi_fast_open_client_fail") ||
// the `tcpi_delivery_fastopen_bitfields` map two bitfield fields stored in a u8
(musl && struct_ == "tcp_info" && field == "tcpi_delivery_fastopen_bitfields") ||
// either fsid_t or int[2] type
(struct_ == "fanotify_event_info_fid" && field == "fsid") ||
// `handle` is a VLA
(struct_ == "fanotify_event_info_fid" && field == "handle")
(struct_ == "fanotify_event_info_fid" && field == "handle") ||
// invalid application of 'sizeof' to incomplete type 'long unsigned int[]'
(musl && struct_ == "mcontext_t" && field == "__extcontext" && loongarch64)
});

cfg.skip_roundtrip(move |s| match s {
Expand Down
15 changes: 15 additions & 0 deletions libc-test/semver/linux-gnu-loongarch64.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
KEYCTL_CAPABILITIES
KEYCTL_CAPS0_BIG_KEY
KEYCTL_CAPS0_CAPABILITIES
KEYCTL_CAPS0_DIFFIE_HELLMAN
KEYCTL_CAPS0_INVALIDATE
KEYCTL_CAPS0_MOVE
KEYCTL_CAPS0_PERSISTENT_KEYRINGS
KEYCTL_CAPS0_PUBLIC_KEY
KEYCTL_CAPS0_RESTRICT_KEYRING
KEYCTL_CAPS1_NS_KEYRING_NAME
KEYCTL_CAPS1_NS_KEY_TAG
KEYCTL_MOVE
MADV_SOFT_OFFLINE
PTRACE_GETFPREGS
PTRACE_GETFPXREGS
PTRACE_GETREGS
PTRACE_SETFPREGS
PTRACE_SETFPXREGS
PTRACE_SETREGS
PTRACE_SYSEMU
PTRACE_SYSEMU_SINGLESTEP
15 changes: 0 additions & 15 deletions libc-test/semver/linux-loongarch64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,11 @@ BPF_XOR
CIBAUD
FICLONE
FICLONERANGE
KEYCTL_CAPABILITIES
KEYCTL_CAPS0_BIG_KEY
KEYCTL_CAPS0_CAPABILITIES
KEYCTL_CAPS0_DIFFIE_HELLMAN
KEYCTL_CAPS0_INVALIDATE
KEYCTL_CAPS0_MOVE
KEYCTL_CAPS0_PERSISTENT_KEYRINGS
KEYCTL_CAPS0_PUBLIC_KEY
KEYCTL_CAPS0_RESTRICT_KEYRING
KEYCTL_CAPS1_NS_KEYRING_NAME
KEYCTL_CAPS1_NS_KEY_TAG
KEYCTL_MOVE
MADV_SOFT_OFFLINE
MAP_SYNC
NFT_MSG_DELOBJ
NFT_MSG_GETOBJ
NFT_MSG_GETOBJ_RESET
NFT_MSG_NEWOBJ
PTRACE_SYSEMU
PTRACE_SYSEMU_SINGLESTEP
SCM_TIMESTAMPNS
SCM_WIFI_STATUS
SIGSTKFLT
Expand Down
3 changes: 3 additions & 0 deletions src/unix/linux_like/linux/arch/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,10 @@ cfg_if! {
pub const RLIMIT_RTPRIO: ::c_int = 14;
pub const RLIMIT_RTTIME: ::c_int = 15;
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
#[cfg(not(target_arch = "loongarch64"))]
pub const RLIM_NLIMITS: ::c_int = 15;
#[cfg(target_arch = "loongarch64")]
pub const RLIM_NLIMITS: ::c_int = 16;
#[allow(deprecated)]
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
pub const RLIMIT_NLIMITS: ::c_int = RLIM_NLIMITS;
Expand Down
32 changes: 7 additions & 25 deletions src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ pub type __u64 = ::c_ulonglong;
pub type __s64 = ::c_longlong;

s! {
pub struct pthread_attr_t {
__size: [::c_ulong; 7],
}

pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
Expand Down Expand Up @@ -59,21 +55,6 @@ s! {
__unused: [::c_int; 2],
}

pub struct statfs {
pub f_type: ::c_long,
pub f_bsize: ::c_long,
pub f_blocks: ::fsblkcnt_t,
pub f_bfree: ::fsblkcnt_t,
pub f_bavail: ::fsblkcnt_t,
pub f_files: ::fsfilcnt_t,
pub f_ffree: ::fsfilcnt_t,
pub f_fsid: ::fsid_t,
pub f_namelen: ::c_long,
pub f_frsize: ::c_long,
pub f_flags: ::c_long,
pub f_spare: [::c_long; 4],
}

pub struct statfs64 {
pub f_type: ::c_long,
pub f_bsize: ::c_long,
Expand All @@ -96,7 +77,7 @@ s! {
pub cuid: ::uid_t,
pub cgid: ::gid_t,
pub mode: ::c_uint,
pub __seq: ::c_ushort,
pub __seq: ::c_int,
__pad2: ::c_ushort,
__unused1: ::c_ulong,
__unused2: ::c_ulong,
Expand Down Expand Up @@ -126,10 +107,10 @@ s! {

#[repr(align(16))]
pub struct mcontext_t {
pub __pc: ::c_ulonglong,
pub __gregs: [::c_ulonglong; 32],
pub __pc: ::c_ulong,
pub __gregs: [::c_ulong; 32],
pub __flags: ::c_uint,
pub __extcontext: [::c_ulonglong; 0],
pub __extcontext: [::c_ulong; 0],
}

#[repr(align(8))]
Expand Down Expand Up @@ -467,7 +448,7 @@ pub const SYS_futex_requeue: ::c_long = 456;
pub const O_APPEND: ::c_int = 1024;
pub const O_DIRECT: ::c_int = 0x4000;
pub const O_DIRECTORY: ::c_int = 0x10000;
pub const O_LARGEFILE: ::c_int = 0;
pub const O_LARGEFILE: ::c_int = 0o0100000;
pub const O_NOFOLLOW: ::c_int = 0x20000;
pub const O_CREAT: ::c_int = 64;
pub const O_EXCL: ::c_int = 128;
Expand All @@ -476,7 +457,7 @@ pub const O_NONBLOCK: ::c_int = 2048;
pub const O_SYNC: ::c_int = 1052672;
pub const O_RSYNC: ::c_int = 1052672;
pub const O_DSYNC: ::c_int = 4096;
pub const O_ASYNC: ::c_int = 4096;
pub const O_ASYNC: ::c_int = 0o20000;

pub const SIGSTKSZ: ::size_t = 16384;
pub const MINSIGSTKSZ: ::size_t = 4096;
Expand Down Expand Up @@ -660,6 +641,7 @@ pub const ECHOPRT: ::tcflag_t = 0x00000400;
pub const ECHOCTL: ::tcflag_t = 0x00000200;
pub const ISIG: ::tcflag_t = 0x00000001;
pub const ICANON: ::tcflag_t = 0x00000002;
pub const XCASE: ::tcflag_t = 0x00000004;
pub const PENDIN: ::tcflag_t = 0x00004000;
pub const NOFLSH: ::tcflag_t = 0x00000080;
pub const CIBAUD: ::tcflag_t = 0o02003600000;
Expand Down
26 changes: 21 additions & 5 deletions src/unix/linux_like/linux/musl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,16 @@ s! {
pub tcpi_backoff: u8,
pub tcpi_options: u8,
/*
* FIXME(musl): when musl headers are more up to date
* FIXME(musl): enable on all targets once musl headers are more up to date
*/
/// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`.
/// Each is 4 bits.
#[cfg(target_arch = "loongarch64")]
pub tcpi_snd_rcv_wscale: u8,
/// This contains the bitfields `tcpi_delivery_rate_app_limited` (1 bit) and
/// `tcpi_fastopen_client_fail` (2 bits).
#[cfg(target_arch = "loongarch64")]
pub tcpi_delivery_fastopen_bitfields: u8,
*/
pub tcpi_rto: u32,
pub tcpi_ato: u32,
pub tcpi_snd_mss: u32,
Expand Down Expand Up @@ -407,9 +409,11 @@ s! {
pub tcpi_bytes_retrans: u64,
pub tcpi_dsack_dups: u32,
pub tcpi_reord_seen: u32,
// FIXME(musl): to uncomment once CI musl is updated
//pub tcpi_rcv_ooopack: u32,
//pub tcpi_snd_wnd: u32,
// FIXME(musl): enable on all targets once CI musl is updated
#[cfg(target_arch = "loongarch64")]
pub tcpi_rcv_ooopack: u32,
#[cfg(target_arch = "loongarch64")]
pub tcpi_snd_wnd: u32,
}
}

Expand Down Expand Up @@ -449,8 +453,17 @@ s_no_extra_traits! {
pub ut_exit: __exit_status,

#[cfg(target_env = "musl")]
#[cfg(not(target_arch = "loongarch64"))]
pub ut_session: ::c_long,

#[cfg(target_env = "musl")]
#[cfg(target_arch = "loongarch64")]
pub ut_session: ::c_int,

#[cfg(target_env = "musl")]
#[cfg(target_arch = "loongarch64")]
__ut_pad2: ::c_int,

#[cfg(target_env = "ohos")]
#[cfg(target_endian = "little")]
pub ut_session: ::c_int,
Expand Down Expand Up @@ -712,7 +725,10 @@ pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;

#[cfg(not(target_arch = "loongarch64"))]
pub const CPU_SETSIZE: ::c_int = 128;
#[cfg(target_arch = "loongarch64")]
pub const CPU_SETSIZE: ::c_int = 1024;

pub const PTRACE_TRACEME: ::c_int = 0;
pub const PTRACE_PEEKTEXT: ::c_int = 1;
Expand Down

0 comments on commit 91989b6

Please sign in to comment.