Skip to content

Start update to musl v1.2.3 #4443

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
12 changes: 12 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,18 @@ jobs:
env:
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64
artifact-tag: offset-bits64
- target: aarch64-unknown-linux-musl
env:
RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1
- target: arm-unknown-linux-musleabihf
env:
RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1
- target: i686-unknown-linux-musl
env:
RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1
- target: loongarch64-unknown-linux-musl
env:
RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1
# FIXME(ppc): SIGILL running tests, see
# https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713
# - target: powerpc-unknown-linux-gnu
Expand Down
8 changes: 8 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const ALLOWED_CFGS: &[&str] = &[
"libc_ctest",
// Corresponds to `__USE_TIME_BITS64` in UAPI
"linux_time_bits64",
"musl_v1_2_3"
];

// Extra values to allow for check-cfg.
Expand Down Expand Up @@ -85,6 +86,13 @@ fn main() {
_ => (),
}

let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok();
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3");
// loongarch64 and ohos have already updated
if musl_v1_2_3 || target_os == "loongarch64" || target_env == "ohos" {
// FIXME(musl): enable time64 api as well
set_cfg("musl_v1_2_3");
}
let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok();
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64");
if linux_time_bits64 {
Expand Down
4 changes: 2 additions & 2 deletions ci/install-musl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ case ${1} in
musl_version=1.2.5
;;
*)
musl_version=1.1.24
[ -n "${RUST_LIBC_UNSTABLE_MUSL_V1_2_3:-}" ] && musl_version=1.2.3 || musl_version=1.1.24
;;
esac

musl="musl-${musl_version}"

# Download, configure, build, and install musl:
curl --retry 5 https://www.musl-libc.org/releases/${musl}.tar.gz | tar xzf -
curl --retry 5 "https://www.musl-libc.org/releases/${musl}.tar.gz" | tar xzf -

cd "$musl"
case ${1} in
Expand Down
38 changes: 27 additions & 11 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3648,15 +3648,20 @@ fn test_linux(target: &str) {
let x32 = target.contains("x32");
let x86_32 = target.contains("i686");
let x86_64 = target.contains("x86_64");
let aarch64_musl = aarch64 && musl;
let gnueabihf = target.contains("gnueabihf");
let x86_64_gnux32 = target.contains("gnux32") && x86_64;
let riscv64 = target.contains("riscv64");
let loongarch64 = target.contains("loongarch64");
let wasm32 = target.contains("wasm32");
let uclibc = target.contains("uclibc");

let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok();
let old_musl = musl && !musl_v1_2_3;

let mut cfg = ctest_cfg();
if musl_v1_2_3 {
cfg.cfg("musl_v1_2_3", None);
}
cfg.define("_GNU_SOURCE", None);
// This macro re-defines fscanf,scanf,sscanf to link to the symbols that are
// deprecated since glibc >= 2.29. This allows Rust binaries to link against
Expand Down Expand Up @@ -4125,6 +4130,9 @@ fn test_linux(target: &str) {
// FIXME(linux): Requires >= 6.4 kernel headers.
"ptrace_sud_config" => true,

// Struct has changed for new musl versions
"tcp_info" if old_musl => true,

_ => false,
}
});
Expand Down Expand Up @@ -4226,9 +4234,9 @@ fn test_linux(target: &str) {
if name == "PR_GET_MDWE" || name == "PR_MDWE_NO_INHERIT" || name == "PR_MDWE_REFUSE_EXEC_GAIN" || name == "PR_SET_MDWE" {
return true;
}
// FIXME(musl): Requires musl >= 1.2
if name == "SO_PREFER_BUSY_POLL"
|| name == "SO_BUSY_POLL_BUDGET"
// Requires musl >= 1.2
if old_musl && (name == "SO_PREFER_BUSY_POLL"
|| name == "SO_BUSY_POLL_BUDGET")
{
return true;
}
Expand All @@ -4252,6 +4260,14 @@ fn test_linux(target: &str) {
{
return true;
}
// Values changed in newer musl versions on these arches
if old_musl && (riscv64 || x86_64) && name == "O_LARGEFILE" {
return true;
}
// Values changed in newer musl versions
if old_musl && name == "RLIM_NLIMITS" {
return true;
}
}
match name {
// These constants are not available if gnu headers have been included
Expand Down Expand Up @@ -4657,18 +4673,18 @@ fn test_linux(target: &str) {
"getnameinfo" if uclibc => true,

// FIXME(musl): This needs musl 1.2.2 or later.
"gettid" if musl => true,
"gettid" if old_musl => true,

// Needs glibc 2.33 or later.
"mallinfo2" => true,

"reallocarray" if musl => true,
"reallocarray" if old_musl => true,

// Not defined in uclibc as of 1.0.34
"gettid" if uclibc => true,

// Needs musl 1.2.3 or later.
"pthread_getname_np" if musl => true,
"pthread_getname_np" if old_musl => true,

// pthread_sigqueue uses sigval, which was initially declared
// as a struct but should be defined as a union. However due
Expand Down Expand Up @@ -4762,8 +4778,8 @@ fn test_linux(target: &str) {
"sched_ss_init_budget",
"sched_ss_max_repl",
].contains(&field) && musl) ||
// FIXME(musl): After musl 1.1.24, the type becomes `int` instead of `unsigned short`.
(struct_ == "ipc_perm" && field == "__seq" && aarch64_musl) ||
// After musl 1.1.24, the type becomes `int` instead of `unsigned short`.
(struct_ == "ipc_perm" && field == "__seq" && old_musl && aarch64) ||
// glibc uses unnamed fields here and Rust doesn't support that yet
(struct_ == "timex" && field.starts_with("__unused")) ||
// FIXME(linux): It now takes mode_t since glibc 2.31 on some targets.
Expand Down Expand Up @@ -4812,8 +4828,8 @@ fn test_linux(target: &str) {
(struct_ == "statvfs64" && field == "__f_spare") ||
// the `xsk_tx_metadata_union` field is an anonymous union
(struct_ == "xsk_tx_metadata" && field == "xsk_tx_metadata_union") ||
// FIXME(musl): After musl 1.2.0, the type becomes `int` instead of `long`.
(struct_ == "utmpx" && field == "ut_session")
// After musl 1.2.0, the type becomes `int` instead of `long`.
(old_musl && struct_ == "utmpx" && field == "ut_session")
});

cfg.skip_roundtrip(move |s| match s {
Expand Down
3 changes: 0 additions & 3 deletions src/unix/linux_like/linux/arch/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,6 @@ 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")]
Expand Down
2 changes: 1 addition & 1 deletion src/unix/linux_like/linux/arch/mips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ 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")]
pub const RLIM_NLIMITS: c_int = 15;
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
2 changes: 1 addition & 1 deletion src/unix/linux_like/linux/arch/powerpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ 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")]
pub const RLIM_NLIMITS: c_int = 15;
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
8 changes: 8 additions & 0 deletions src/unix/linux_like/linux/musl/b32/arm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ s! {
}

pub struct ipc_perm {
#[cfg(musl_v1_2_3)]
pub __key: crate::key_t,
#[cfg(not(musl_v1_2_3))]
#[deprecated(
since = "0.2.173",
note = "This field is incorrectly named and will be changed
to __key in a future release."
)]
pub __ipc_perm_key: crate::key_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
Expand Down
8 changes: 8 additions & 0 deletions src/unix/linux_like/linux/musl/b32/hexagon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ s! {
}

pub struct ipc_perm {
#[cfg(musl_v1_2_3)]
pub __key: crate::key_t,
#[cfg(not(musl_v1_2_3))]
#[deprecated(
since = "0.2.173",
note = "This field is incorrectly named and will be changed
to __key in a future release"
)]
pub __ipc_perm_key: crate::key_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
Expand Down
8 changes: 8 additions & 0 deletions src/unix/linux_like/linux/musl/b32/mips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ s! {
}

pub struct ipc_perm {
#[cfg(musl_v1_2_3)]
pub __key: crate::key_t,
#[cfg(not(musl_v1_2_3))]
#[deprecated(
since = "0.2.173",
note = "This field is incorrectly named and will be changed
to __key in a future release."
)]
pub __ipc_perm_key: crate::key_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
Expand Down
8 changes: 8 additions & 0 deletions src/unix/linux_like/linux/musl/b32/powerpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ s! {
}

pub struct ipc_perm {
#[cfg(musl_v1_2_3)]
pub __key: crate::key_t,
#[cfg(not(musl_v1_2_3))]
#[deprecated(
since = "0.2.173",
note = "This field is incorrectly named and will be changed
to __key in a future release."
)]
pub __ipc_perm_key: crate::key_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
Expand Down
8 changes: 8 additions & 0 deletions src/unix/linux_like/linux/musl/b32/x86/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ s! {
}

pub struct ipc_perm {
#[cfg(musl_v1_2_3)]
pub __key: crate::key_t,
#[cfg(not(musl_v1_2_3))]
#[deprecated(
since = "0.2.173",
note = "This field is incorrectly named and will be changed
to __key in a future release."
)]
pub __ipc_perm_key: crate::key_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
Expand Down
21 changes: 19 additions & 2 deletions src/unix/linux_like/linux/musl/b64/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,32 @@ s! {
}

pub struct ipc_perm {
#[cfg(musl_v1_2_3)]
pub __key: crate::key_t,
#[cfg(not(musl_v1_2_3))]
#[deprecated(
since = "0.2.173",
note = "This field is incorrectly named and will be changed
to __key in a future release."
)]
pub __ipc_perm_key: crate::key_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
pub cuid: crate::uid_t,
pub cgid: crate::gid_t,
pub mode: crate::mode_t,

#[cfg(musl_v1_2_3)]
pub __seq: c_int,
#[cfg(not(musl_v1_2_3))]
#[deprecated(
since = "0.2.173",
note = "The type of this field has changed from c_ushort to c_int,
we'll follow that change in the future release."
)]
pub __seq: c_ushort,
__unused1: c_ulong,
__unused2: c_ulong,
__unused1: c_long,
__unused2: c_long,
}

pub struct ucontext_t {
Expand Down
8 changes: 8 additions & 0 deletions src/unix/linux_like/linux/musl/b64/mips64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ s! {
}

pub struct ipc_perm {
#[cfg(musl_v1_2_3)]
pub __key: crate::key_t,
#[cfg(not(musl_v1_2_3))]
#[deprecated(
since = "0.2.173",
note = "This field is incorrectly named and will be changed
to __key in a future release."
)]
pub __ipc_perm_key: crate::key_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
Expand Down
8 changes: 8 additions & 0 deletions src/unix/linux_like/linux/musl/b64/powerpc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ s! {
}

pub struct ipc_perm {
#[cfg(musl_v1_2_3)]
pub __key: crate::key_t,
#[cfg(not(musl_v1_2_3))]
#[deprecated(
since = "0.2.173",
note = "This field is incorrectly named and will be changed
to __key in a future release."
)]
pub __ipc_perm_key: crate::key_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
Expand Down
2 changes: 1 addition & 1 deletion src/unix/linux_like/linux/musl/b64/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ pub const SYS_landlock_restrict_self: c_long = 446;
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 = 0o100000;
pub const O_NOFOLLOW: c_int = 0x20000;
pub const O_CREAT: c_int = 64;
pub const O_EXCL: c_int = 128;
Expand Down
8 changes: 8 additions & 0 deletions src/unix/linux_like/linux/musl/b64/s390x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ pub type __s64 = i64;

s! {
pub struct ipc_perm {
#[cfg(musl_v1_2_3)]
pub __key: crate::key_t,
#[cfg(not(musl_v1_2_3))]
#[deprecated(
since = "0.2.173",
note = "This field is incorrectly named and will be changed
to __key in a future release."
)]
pub __ipc_perm_key: crate::key_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
Expand Down
8 changes: 8 additions & 0 deletions src/unix/linux_like/linux/musl/b64/wasm32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ s! {
}

pub struct ipc_perm {
#[cfg(musl_v1_2_3)]
pub __key: crate::key_t,
#[cfg(not(musl_v1_2_3))]
#[deprecated(
since = "0.2.173",
note = "This field is incorrectly named and will be changed
to __key in a future release."
)]
pub __ipc_perm_key: crate::key_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
Expand Down
10 changes: 9 additions & 1 deletion src/unix/linux_like/linux/musl/b64/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ s! {
}

pub struct ipc_perm {
#[cfg(musl_v1_2_3)]
pub __key: crate::key_t,
#[cfg(not(musl_v1_2_3))]
#[deprecated(
since = "0.2.173",
note = "This field is incorrectly named and will be changed
to __key in a future release."
)]
pub __ipc_perm_key: crate::key_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
Expand Down Expand Up @@ -701,7 +709,7 @@ pub const MAP_32BIT: c_int = 0x0040;
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 Down
Loading