From 8e5434c51cf9824fa394dab192aea1f579323714 Mon Sep 17 00:00:00 2001 From: SteveLauC Date: Mon, 18 Nov 2024 10:58:53 +0800 Subject: [PATCH] ci: add CI for Linux/aarch64/musl and fix its build (#2510) * ci: add CI for Linux/aarch64/musl * fix: enable RegisterSet and RegisterSetValue for aarch64/musl * fix: cfg * fix: cfg * style: make clippy happy --- .cirrus.yml | 8 +++++- src/sys/ptrace/linux.rs | 61 +++++++++++++++++++++++++++++------------ test/sys/test_ptrace.rs | 15 ++++++---- 3 files changed, 60 insertions(+), 24 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 69012b576f..4f4cc76690 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -68,12 +68,18 @@ task: # Tasks for Linux aarch64 native builds task: matrix: - - name: Linux aarch64 + - name: Linux aarch64 gnu arm_container: image: rust:1.69.0 cpu: 1 env: TARGET: aarch64-unknown-linux-gnu + - name: Linux aarch64 musl + arm_container: + image: rust:1.69.0 + cpu: 1 + env: + TARGET: aarch64-unknown-linux-musl setup_script: - rustup target add $TARGET - rustup component add clippy diff --git a/src/sys/ptrace/linux.rs b/src/sys/ptrace/linux.rs index 762b337687..1cebb37dfa 100644 --- a/src/sys/ptrace/linux.rs +++ b/src/sys/ptrace/linux.rs @@ -173,13 +173,21 @@ libc_enum! { #[cfg(all( target_os = "linux", - target_env = "gnu", any( - target_arch = "x86_64", - target_arch = "x86", - target_arch = "aarch64", - target_arch = "riscv64", - ) + all( + target_env = "gnu", + any( + target_arch = "x86_64", + target_arch = "x86", + target_arch = "aarch64", + target_arch = "riscv64", + ) + ), + all( + target_env = "musl", + target_arch = "aarch64", + ) + ), ))] libc_enum! { #[repr(i32)] @@ -196,13 +204,21 @@ libc_enum! { #[cfg(all( target_os = "linux", - target_env = "gnu", any( - target_arch = "x86_64", - target_arch = "x86", - target_arch = "aarch64", - target_arch = "riscv64", - ) + all( + target_env = "gnu", + any( + target_arch = "x86_64", + target_arch = "x86", + target_arch = "aarch64", + target_arch = "riscv64", + ) + ), + all( + target_env = "musl", + target_arch = "aarch64", + ) + ), ))] /// Represents register set areas, such as general-purpose registers or /// floating-point registers. @@ -219,15 +235,24 @@ pub unsafe trait RegisterSet { type Regs; } + #[cfg(all( target_os = "linux", - target_env = "gnu", any( - target_arch = "x86_64", - target_arch = "x86", - target_arch = "aarch64", - target_arch = "riscv64", - ) + all( + target_env = "gnu", + any( + target_arch = "x86_64", + target_arch = "x86", + target_arch = "aarch64", + target_arch = "riscv64", + ) + ), + all( + target_env = "musl", + target_arch = "aarch64", + ) + ), ))] /// Register sets used in [`getregset`] and [`setregset`] pub mod regset { diff --git a/test/sys/test_ptrace.rs b/test/sys/test_ptrace.rs index 2e3e809ee8..5635346eac 100644 --- a/test/sys/test_ptrace.rs +++ b/test/sys/test_ptrace.rs @@ -179,12 +179,17 @@ fn test_ptrace_interrupt() { // ptrace::{setoptions, getregs} are only available in these platforms #[cfg(all( target_os = "linux", - target_env = "gnu", any( - target_arch = "x86_64", - target_arch = "x86", - target_arch = "aarch64", - target_arch = "riscv64", + all( + target_env = "gnu", + any( + target_arch = "x86_64", + target_arch = "x86", + target_arch = "aarch64", + target_arch = "riscv64" + ) + ), + all(target_env = "musl", target_arch = "aarch64") ) ))] #[test]