Skip to content

Commit efc0b86

Browse files
authored
Merge pull request #4443 from xbjfk/musl-1-2-3
Start update to musl v1.2.3
2 parents 181b043 + 60f7b3d commit efc0b86

File tree

20 files changed

+166
-55
lines changed

20 files changed

+166
-55
lines changed

.github/workflows/ci.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ jobs:
195195
env:
196196
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64
197197
artifact-tag: offset-bits64
198+
- target: aarch64-unknown-linux-musl
199+
env:
200+
RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1
201+
- target: arm-unknown-linux-musleabihf
202+
env:
203+
RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1
204+
- target: i686-unknown-linux-musl
205+
env:
206+
RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1
207+
- target: loongarch64-unknown-linux-musl
208+
env:
209+
RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1
198210
# FIXME(ppc): SIGILL running tests, see
199211
# https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713
200212
# - target: powerpc-unknown-linux-gnu

build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const ALLOWED_CFGS: &[&str] = &[
2121
"libc_ctest",
2222
// Corresponds to `__USE_TIME_BITS64` in UAPI
2323
"linux_time_bits64",
24+
"musl_v1_2_3"
2425
];
2526

2627
// Extra values to allow for check-cfg.
@@ -85,6 +86,13 @@ fn main() {
8586
_ => (),
8687
}
8788

89+
let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok();
90+
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3");
91+
// loongarch64 and ohos have already updated
92+
if musl_v1_2_3 || target_os == "loongarch64" || target_env == "ohos" {
93+
// FIXME(musl): enable time64 api as well
94+
set_cfg("musl_v1_2_3");
95+
}
8896
let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok();
8997
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64");
9098
if linux_time_bits64 {

ci/install-musl.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ case ${1} in
1010
musl_version=1.2.5
1111
;;
1212
*)
13-
musl_version=1.1.24
13+
[ -n "${RUST_LIBC_UNSTABLE_MUSL_V1_2_3:-}" ] && musl_version=1.2.3 || musl_version=1.1.24
1414
;;
1515
esac
1616

1717
musl="musl-${musl_version}"
1818

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

2222
cd "$musl"
2323
case ${1} in

libc-test/build.rs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3648,15 +3648,20 @@ fn test_linux(target: &str) {
36483648
let x32 = target.contains("x32");
36493649
let x86_32 = target.contains("i686");
36503650
let x86_64 = target.contains("x86_64");
3651-
let aarch64_musl = aarch64 && musl;
36523651
let gnueabihf = target.contains("gnueabihf");
36533652
let x86_64_gnux32 = target.contains("gnux32") && x86_64;
36543653
let riscv64 = target.contains("riscv64");
36553654
let loongarch64 = target.contains("loongarch64");
36563655
let wasm32 = target.contains("wasm32");
36573656
let uclibc = target.contains("uclibc");
36583657

3658+
let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok();
3659+
let old_musl = musl && !musl_v1_2_3;
3660+
36593661
let mut cfg = ctest_cfg();
3662+
if musl_v1_2_3 {
3663+
cfg.cfg("musl_v1_2_3", None);
3664+
}
36603665
cfg.define("_GNU_SOURCE", None);
36613666
// This macro re-defines fscanf,scanf,sscanf to link to the symbols that are
36623667
// deprecated since glibc >= 2.29. This allows Rust binaries to link against
@@ -4125,6 +4130,9 @@ fn test_linux(target: &str) {
41254130
// FIXME(linux): Requires >= 6.4 kernel headers.
41264131
"ptrace_sud_config" => true,
41274132

4133+
// Struct has changed for new musl versions
4134+
"tcp_info" if old_musl => true,
4135+
41284136
_ => false,
41294137
}
41304138
});
@@ -4226,9 +4234,9 @@ fn test_linux(target: &str) {
42264234
if name == "PR_GET_MDWE" || name == "PR_MDWE_NO_INHERIT" || name == "PR_MDWE_REFUSE_EXEC_GAIN" || name == "PR_SET_MDWE" {
42274235
return true;
42284236
}
4229-
// FIXME(musl): Requires musl >= 1.2
4230-
if name == "SO_PREFER_BUSY_POLL"
4231-
|| name == "SO_BUSY_POLL_BUDGET"
4237+
// Requires musl >= 1.2
4238+
if old_musl && (name == "SO_PREFER_BUSY_POLL"
4239+
|| name == "SO_BUSY_POLL_BUDGET")
42324240
{
42334241
return true;
42344242
}
@@ -4252,6 +4260,14 @@ fn test_linux(target: &str) {
42524260
{
42534261
return true;
42544262
}
4263+
// Values changed in newer musl versions on these arches
4264+
if old_musl && (riscv64 || x86_64) && name == "O_LARGEFILE" {
4265+
return true;
4266+
}
4267+
// Values changed in newer musl versions
4268+
if old_musl && name == "RLIM_NLIMITS" {
4269+
return true;
4270+
}
42554271
}
42564272
match name {
42574273
// These constants are not available if gnu headers have been included
@@ -4657,18 +4673,18 @@ fn test_linux(target: &str) {
46574673
"getnameinfo" if uclibc => true,
46584674

46594675
// FIXME(musl): This needs musl 1.2.2 or later.
4660-
"gettid" if musl => true,
4676+
"gettid" if old_musl => true,
46614677

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

4665-
"reallocarray" if musl => true,
4681+
"reallocarray" if old_musl => true,
46664682

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

46704686
// Needs musl 1.2.3 or later.
4671-
"pthread_getname_np" if musl => true,
4687+
"pthread_getname_np" if old_musl => true,
46724688

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

48194835
cfg.skip_roundtrip(move |s| match s {

src/unix/linux_like/linux/arch/generic/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,6 @@ cfg_if! {
357357
pub const RLIMIT_RTPRIO: c_int = 14;
358358
pub const RLIMIT_RTTIME: c_int = 15;
359359
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
360-
#[cfg(not(target_arch = "loongarch64"))]
361-
pub const RLIM_NLIMITS: c_int = 15;
362-
#[cfg(target_arch = "loongarch64")]
363360
pub const RLIM_NLIMITS: c_int = 16;
364361
#[allow(deprecated)]
365362
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]

src/unix/linux_like/linux/arch/mips/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ cfg_if! {
349349
pub const RLIMIT_RTPRIO: c_int = 14;
350350
pub const RLIMIT_RTTIME: c_int = 15;
351351
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
352-
pub const RLIM_NLIMITS: c_int = 15;
352+
pub const RLIM_NLIMITS: c_int = 16;
353353
#[allow(deprecated)]
354354
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
355355
pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS;

src/unix/linux_like/linux/arch/powerpc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ cfg_if! {
330330
pub const RLIMIT_RTPRIO: c_int = 14;
331331
pub const RLIMIT_RTTIME: c_int = 15;
332332
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
333-
pub const RLIM_NLIMITS: c_int = 15;
333+
pub const RLIM_NLIMITS: c_int = 16;
334334
#[allow(deprecated)]
335335
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
336336
pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS;

src/unix/linux_like/linux/musl/b32/arm/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ s! {
5555
}
5656

5757
pub struct ipc_perm {
58+
#[cfg(musl_v1_2_3)]
59+
pub __key: crate::key_t,
60+
#[cfg(not(musl_v1_2_3))]
61+
#[deprecated(
62+
since = "0.2.173",
63+
note = "This field is incorrectly named and will be changed
64+
to __key in a future release."
65+
)]
5866
pub __ipc_perm_key: crate::key_t,
5967
pub uid: crate::uid_t,
6068
pub gid: crate::gid_t,

src/unix/linux_like/linux/musl/b32/hexagon.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ s! {
3434
}
3535

3636
pub struct ipc_perm {
37+
#[cfg(musl_v1_2_3)]
38+
pub __key: crate::key_t,
39+
#[cfg(not(musl_v1_2_3))]
40+
#[deprecated(
41+
since = "0.2.173",
42+
note = "This field is incorrectly named and will be changed
43+
to __key in a future release"
44+
)]
3745
pub __ipc_perm_key: crate::key_t,
3846
pub uid: crate::uid_t,
3947
pub gid: crate::gid_t,

src/unix/linux_like/linux/musl/b32/mips/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ s! {
5757
}
5858

5959
pub struct ipc_perm {
60+
#[cfg(musl_v1_2_3)]
61+
pub __key: crate::key_t,
62+
#[cfg(not(musl_v1_2_3))]
63+
#[deprecated(
64+
since = "0.2.173",
65+
note = "This field is incorrectly named and will be changed
66+
to __key in a future release."
67+
)]
6068
pub __ipc_perm_key: crate::key_t,
6169
pub uid: crate::uid_t,
6270
pub gid: crate::gid_t,

src/unix/linux_like/linux/musl/b32/powerpc.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ s! {
5353
}
5454

5555
pub struct ipc_perm {
56+
#[cfg(musl_v1_2_3)]
57+
pub __key: crate::key_t,
58+
#[cfg(not(musl_v1_2_3))]
59+
#[deprecated(
60+
since = "0.2.173",
61+
note = "This field is incorrectly named and will be changed
62+
to __key in a future release."
63+
)]
5664
pub __ipc_perm_key: crate::key_t,
5765
pub uid: crate::uid_t,
5866
pub gid: crate::gid_t,

src/unix/linux_like/linux/musl/b32/x86/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ s! {
5959
}
6060

6161
pub struct ipc_perm {
62+
#[cfg(musl_v1_2_3)]
63+
pub __key: crate::key_t,
64+
#[cfg(not(musl_v1_2_3))]
65+
#[deprecated(
66+
since = "0.2.173",
67+
note = "This field is incorrectly named and will be changed
68+
to __key in a future release."
69+
)]
6270
pub __ipc_perm_key: crate::key_t,
6371
pub uid: crate::uid_t,
6472
pub gid: crate::gid_t,

src/unix/linux_like/linux/musl/b64/aarch64/mod.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,32 @@ s! {
6060
}
6161

6262
pub struct ipc_perm {
63+
#[cfg(musl_v1_2_3)]
64+
pub __key: crate::key_t,
65+
#[cfg(not(musl_v1_2_3))]
66+
#[deprecated(
67+
since = "0.2.173",
68+
note = "This field is incorrectly named and will be changed
69+
to __key in a future release."
70+
)]
6371
pub __ipc_perm_key: crate::key_t,
6472
pub uid: crate::uid_t,
6573
pub gid: crate::gid_t,
6674
pub cuid: crate::uid_t,
6775
pub cgid: crate::gid_t,
6876
pub mode: crate::mode_t,
77+
78+
#[cfg(musl_v1_2_3)]
79+
pub __seq: c_int,
80+
#[cfg(not(musl_v1_2_3))]
81+
#[deprecated(
82+
since = "0.2.173",
83+
note = "The type of this field has changed from c_ushort to c_int,
84+
we'll follow that change in the future release."
85+
)]
6986
pub __seq: c_ushort,
70-
__unused1: c_ulong,
71-
__unused2: c_ulong,
87+
__unused1: c_long,
88+
__unused2: c_long,
7289
}
7390

7491
pub struct ucontext_t {

src/unix/linux_like/linux/musl/b64/mips64.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ s! {
5757
}
5858

5959
pub struct ipc_perm {
60+
#[cfg(musl_v1_2_3)]
61+
pub __key: crate::key_t,
62+
#[cfg(not(musl_v1_2_3))]
63+
#[deprecated(
64+
since = "0.2.173",
65+
note = "This field is incorrectly named and will be changed
66+
to __key in a future release."
67+
)]
6068
pub __ipc_perm_key: crate::key_t,
6169
pub uid: crate::uid_t,
6270
pub gid: crate::gid_t,

src/unix/linux_like/linux/musl/b64/powerpc64.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ s! {
5151
}
5252

5353
pub struct ipc_perm {
54+
#[cfg(musl_v1_2_3)]
55+
pub __key: crate::key_t,
56+
#[cfg(not(musl_v1_2_3))]
57+
#[deprecated(
58+
since = "0.2.173",
59+
note = "This field is incorrectly named and will be changed
60+
to __key in a future release."
61+
)]
5462
pub __ipc_perm_key: crate::key_t,
5563
pub uid: crate::uid_t,
5664
pub gid: crate::gid_t,

src/unix/linux_like/linux/musl/b64/riscv64/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ pub const SYS_landlock_restrict_self: c_long = 446;
432432
pub const O_APPEND: c_int = 1024;
433433
pub const O_DIRECT: c_int = 0x4000;
434434
pub const O_DIRECTORY: c_int = 0x10000;
435-
pub const O_LARGEFILE: c_int = 0;
435+
pub const O_LARGEFILE: c_int = 0o100000;
436436
pub const O_NOFOLLOW: c_int = 0x20000;
437437
pub const O_CREAT: c_int = 64;
438438
pub const O_EXCL: c_int = 128;

src/unix/linux_like/linux/musl/b64/s390x.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ pub type __s64 = i64;
1010

1111
s! {
1212
pub struct ipc_perm {
13+
#[cfg(musl_v1_2_3)]
14+
pub __key: crate::key_t,
15+
#[cfg(not(musl_v1_2_3))]
16+
#[deprecated(
17+
since = "0.2.173",
18+
note = "This field is incorrectly named and will be changed
19+
to __key in a future release."
20+
)]
1321
pub __ipc_perm_key: crate::key_t,
1422
pub uid: crate::uid_t,
1523
pub gid: crate::gid_t,

src/unix/linux_like/linux/musl/b64/wasm32/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ s! {
5353
}
5454

5555
pub struct ipc_perm {
56+
#[cfg(musl_v1_2_3)]
57+
pub __key: crate::key_t,
58+
#[cfg(not(musl_v1_2_3))]
59+
#[deprecated(
60+
since = "0.2.173",
61+
note = "This field is incorrectly named and will be changed
62+
to __key in a future release."
63+
)]
5664
pub __ipc_perm_key: crate::key_t,
5765
pub uid: crate::uid_t,
5866
pub gid: crate::gid_t,

src/unix/linux_like/linux/musl/b64/x86_64/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ s! {
112112
}
113113

114114
pub struct ipc_perm {
115+
#[cfg(musl_v1_2_3)]
116+
pub __key: crate::key_t,
117+
#[cfg(not(musl_v1_2_3))]
118+
#[deprecated(
119+
since = "0.2.173",
120+
note = "This field is incorrectly named and will be changed
121+
to __key in a future release."
122+
)]
115123
pub __ipc_perm_key: crate::key_t,
116124
pub uid: crate::uid_t,
117125
pub gid: crate::gid_t,
@@ -701,7 +709,7 @@ pub const MAP_32BIT: c_int = 0x0040;
701709
pub const O_APPEND: c_int = 1024;
702710
pub const O_DIRECT: c_int = 0x4000;
703711
pub const O_DIRECTORY: c_int = 0x10000;
704-
pub const O_LARGEFILE: c_int = 0;
712+
pub const O_LARGEFILE: c_int = 0o0100000;
705713
pub const O_NOFOLLOW: c_int = 0x20000;
706714
pub const O_CREAT: c_int = 64;
707715
pub const O_EXCL: c_int = 128;

0 commit comments

Comments
 (0)