Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add support for loongarch64-unknown-linux-musl #4092

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/full_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ jobs:
- i686-linux-android
- i686-unknown-linux-musl
- loongarch64-unknown-linux-gnu
- loongarch64-unknown-linux-musl
- powerpc-unknown-linux-gnu
- powerpc64-unknown-linux-gnu
- powerpc64le-unknown-linux-gnu
Expand Down
14 changes: 14 additions & 0 deletions ci/docker/loongarch64-unknown-linux-musl/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ubuntu:24.04

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl gcc git libc6-dev make qemu-user xz-utils

COPY install-musl-cross.sh /
RUN sh /install-musl-cross.sh loongarch64-unknown-linux-musl

ENV CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_MUSL_LINKER=loongarch64-unknown-linux-musl-gcc \
CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_MUSL_RUNNER="qemu-loongarch64" \
CC_loongarch64_unknown_linux_musl=loongarch64-unknown-linux-musl-gcc \
CFLAGS_loongarch64_unknown_linux_musl="-mabi=lp64d -fPIC" \
QEMU_LD_PREFIX=/loongarch64-unknown-linux-musl/loongarch64-unknown-linux-musl/sysroot \
PATH=$PATH:/loongarch64-unknown-linux-musl/bin:/rust/bin
10 changes: 10 additions & 0 deletions ci/install-musl-cross.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
#
# Install musl cross toolchain

set -ex

MUSL_CROSS_VER=20241103
MUSL_CROSS_URL=https://github.com/musl-cross/musl-cross/releases/download/$MUSL_CROSS_VER/$1.tar.xz

curl -L --retry 5 "$MUSL_CROSS_URL" | tar -xJf - -C /
10 changes: 5 additions & 5 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4489,14 +4489,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") ||
heiher marked this conversation as resolved.
Show resolved Hide resolved
// 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