Skip to content
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
14 changes: 7 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -198,34 +198,34 @@ jobs:
- target: aarch64-linux-android
- target: aarch64-unknown-linux-musl
- target: aarch64-unknown-linux-musl
env: { TEST_MUSL_V1_2_3: 1 }
env: { TEST_MUSL_V1_2: 1 }
artifact-tag: new-musl
- target: arm-linux-androideabi
- target: arm-unknown-linux-gnueabihf
- target: arm-unknown-linux-musleabihf
- target: arm-unknown-linux-musleabihf
env: { TEST_MUSL_V1_2_3: 1 }
env: { TEST_MUSL_V1_2: 1 }
artifact-tag: new-musl
# FIXME(#4297): Disabled due to spurious failue
# - target: i686-linux-android
- target: i686-unknown-linux-musl
- target: i686-unknown-linux-musl
env: { TEST_MUSL_V1_2_3: 1 }
env: { TEST_MUSL_V1_2: 1 }
artifact-tag: new-musl
- target: loongarch64-unknown-linux-gnu
- target: loongarch64-unknown-linux-musl
- target: loongarch64-unknown-linux-musl
env: { TEST_MUSL_V1_2_3: 1 }
env: { TEST_MUSL_V1_2: 1 }
artifact-tag: new-musl
- target: powerpc64-unknown-linux-gnu
- target: powerpc64-unknown-linux-musl
- target: powerpc64-unknown-linux-musl
env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 }
env: { RUST_LIBC_UNSTABLE_MUSL_V1_2: 1 }
artifact-tag: new-musl
- target: powerpc64le-unknown-linux-gnu
- target: powerpc64le-unknown-linux-musl
- target: powerpc64le-unknown-linux-musl
env: { TEST_MUSL_V1_2_3: 1 }
env: { TEST_MUSL_V1_2: 1 }
artifact-tag: new-musl
- target: riscv64gc-unknown-linux-gnu
- target: s390x-unknown-linux-gnu
Expand All @@ -242,7 +242,7 @@ jobs:
# - target: x86_64-unknown-linux-gnux32
- target: x86_64-unknown-linux-musl
- target: x86_64-unknown-linux-musl
env: { TEST_MUSL_V1_2_3: 1 }
env: { TEST_MUSL_V1_2: 1 }
artifact-tag: new-musl
# FIXME: It seems some items in `src/unix/mod.rs` aren't defined on redox actually.
# - target: x86_64-unknown-redox
Expand Down
23 changes: 15 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const ALLOWED_CFGS: &[&str] = &[
"libc_elfv2",
// Corresponds to `__USE_TIME_BITS64` in UAPI
"linux_time_bits64",
"musl_v1_2_3",
// musl v1.2.3+ && 32-bit: time_t is i64, struct layouts change
"musl_v1_2",
// musl v1.2.0+ && 32-bit: time_t is i64, struct layouts change
"musl32_time64",
// Corresponds to `_REDIR_TIME64` in musl: symbol redirects to __*_time64
"musl_redir_time64",
Expand Down Expand Up @@ -150,13 +150,20 @@ fn main() {
_ => (),
}

let mut musl_v1_2_3 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3");
let mut musl_v1_2 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2");
if let Ok(old_musl_v1_2_3) = env::var("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3") {
println!(
"cargo:warning=`--cfg=libc_unstable_musl_v1_2_3` will be removed; \
set `--cfg=libc_unstable_musl_v1_2`instead"
);
musl_v1_2 |= old_musl_v1_2_3 != "0";
}
if let Ok(old_musl_v1_2_3) = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3") {
println!(
"cargo:warning=RUST_LIBC_UNSTABLE_MUSL_V1_2_3 will be removed; \
set `--cfg=libc_unstable_musl_v1_2_3` via RUSTFLAGS instead"
set `--cfg=libc_unstable_musl_v1_2` via RUSTFLAGS instead"
);
musl_v1_2_3 |= old_musl_v1_2_3 != "0";
musl_v1_2 |= old_musl_v1_2_3 != "0";
}

// OpenHarmony uses a fork of the musl libc
Expand All @@ -168,11 +175,11 @@ fn main() {
|| target_env == "ohos"
|| target_abi == "pauthtest"
{
musl_v1_2_3 = true;
musl_v1_2 = true;
}

if musl && musl_v1_2_3 {
set_cfg("musl_v1_2_3");
if musl && musl_v1_2 {
set_cfg("musl_v1_2");
if target_ptr_width == "32" {
set_cfg("musl32_time64");
set_cfg("linux_time_bits64");
Expand Down
4 changes: 2 additions & 2 deletions ci/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ run() {
# and test them both in `ci/run.sh` more similar to what we do with glibc,
# rather than needing two separate jobs.
if [[ "$run_target" = *"musl"* ]]; then
if [ -n "${TEST_MUSL_V1_2_3:-}" ]; then
export RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_musl_v1_2_3"
if [ -n "${TEST_MUSL_V1_2:-}" ]; then
export RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_musl_v1_2"
build_args+=("--build-arg=MUSL_VERSION=new")
else
build_args+=("--build-arg=MUSL_VERSION=old")
Expand Down
2 changes: 1 addition & 1 deletion ci/verify-build.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def test_target(cfg: Cfg, target: Target) -> TargetResult:

if "musl" in target_env:
# Check with breaking changes from musl, including 64-bit time_t on 32-bit
run(cmd, rustflags=f"{rustflags} --cfg=libc_unstable_musl_v1_2_3")
run(cmd, rustflags=f"{rustflags} --cfg=libc_unstable_musl_v1_2")

# Test again without default features, i.e. without `std`
run([*cmd, "--no-default-features"], rustflags=rustflags)
Expand Down
2 changes: 1 addition & 1 deletion etc/libc-util.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def prepare() -> "CheckAllTargets":
new.attributes = base.attributes | {"time_bits": "64"}
new.target_dir = base.target_dir / "time64"
new.extra_rustflags = base.extra_rustflags + [
"--cfg=libc_unstable_musl_v1_2_3"
"--cfg=libc_unstable_musl_v1_2"
]
new_checks.append(new)

Expand Down
35 changes: 16 additions & 19 deletions libc-test/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3969,22 +3969,22 @@ fn test_linux(target: &str) {
None => panic!("failed to detect kernel version for Linux target {target}"),
};

let mut musl_v1_2_3 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3");
if musl_v1_2_3 {
let mut musl_v1_2 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2");
if musl_v1_2 {
assert!(musl);
}

// Some platforms only exist with recent musl. Keep in sync with libc's build.rs.
if musl && (loongarch64 || hexagon || pauthtest/* || ohos */) {
musl_v1_2_3 = true;
musl_v1_2 = true;
}

let old_musl = musl && !musl_v1_2_3;
let old_musl = musl && !musl_v1_2;

let mut cfg = ctest_cfg();

if musl_v1_2_3 {
cfg.cfg("musl_v1_2_3", None);
if musl_v1_2 {
cfg.cfg("musl_v1_2", None);
if b32 {
cfg.cfg("musl32_time64", None);
cfg.cfg("linux_time_bits64", None);
Expand Down Expand Up @@ -4258,9 +4258,9 @@ fn test_linux(target: &str) {
cfg.rename_struct_field(move |struct_, field| {
match (struct_.ident(), field.ident()) {
// Our stat *_nsec fields normally don't actually exist but are part
// of a timeval struct - this is fixed in musl_v1_2_3
// of a timeval struct - this is fixed in musl_v1_2
("stat" | "statfs" | "statvfs" | "stat64" | "statfs64" | "statvfs64", f)
if !musl_v1_2_3 && f.ends_with("_nsec") =>
if !musl_v1_2 && f.ends_with("_nsec") =>
{
Some(f.replace("e_nsec", ".tv_nsec"))
}
Expand Down Expand Up @@ -4521,16 +4521,10 @@ fn test_linux(target: &str) {
}
}
if musl {
// LFS64 types have been removed in musl 1.2.4+
if name.starts_with("RLIM64") {
return true;
}
// CI fails because musl targets use Linux v4 kernel
if name.starts_with("NI_IDN") {
return true;
}

match name {
// LFS64 types have been removed in musl 1.2.4+
x if x.starts_with("RLIM64") && musl_v1_2 => return true,

// FIXME: Does not exist on non-x86 architectures, slated for removal
// in libc in 1.0
"MAP_32BIT" if ppc64 => return true,
Expand Down Expand Up @@ -4582,11 +4576,14 @@ fn test_linux(target: &str) {
| "PR_SCHED_CORE_SHARE_FROM"
| "PR_SCHED_CORE_SHARE_TO" => return true,

// Not present in musl, deprecated in libc.
"NI_IDN" => return true,

/* Added in versions more recent than what we test */
// Since 1.2.0
"SO_DETACH_REUSEPORT_BPF" => return true,
"SO_DETACH_REUSEPORT_BPF" if old_musl => return true,
// Since 1.2.3
"SO_BUSY_POLL_BUDGET" | "SO_PREFER_BUSY_POLL" => return true,
"SO_BUSY_POLL_BUDGET" | "SO_PREFER_BUSY_POLL" if old_musl => return true,

// FIXME(musl): value was updated in new musl
"RLIM_NLIMITS" => return true,
Expand Down
2 changes: 1 addition & 1 deletion libc-test/tests/style_lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const ALLOWED_POSITIVE_S_CFGS: &[&str] = &[
"gnu_file_offset_bits64",
"gnu_time_bits64",
"musl32_time64",
"musl_v1_2_3",
"musl_v1_2",
];

pub type Error = Box<dyn std::error::Error>;
Expand Down
2 changes: 1 addition & 1 deletion src/new/emscripten/sched.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::prelude::*;

cfg_if! {
if #[cfg(musl_v1_2_3)] {
if #[cfg(musl_v1_2)] {
s! {
struct __c_anon_sched_param__reserved2 {
__reserved1: crate::time_t,
Expand Down
2 changes: 1 addition & 1 deletion src/new/musl/sched.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::prelude::*;

cfg_if! {
if #[cfg(musl_v1_2_3)] {
if #[cfg(musl_v1_2)] {
s! {
struct __c_anon_sched_param__reserved2 {
__reserved1: crate::time_t,
Expand Down
16 changes: 8 additions & 8 deletions src/unix/linux_like/linux/musl/b32/arm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ s! {
#[cfg(musl32_time64)]
__st_ctim32: Padding<__c_anonymous_timespec32>,

#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_atime: crate::time_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_atime_nsec: c_long,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_mtime: crate::time_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_mtime_nsec: c_long,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_ctime: crate::time_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_ctime_nsec: c_long,

pub st_ino: crate::ino_t,
Expand All @@ -60,9 +60,9 @@ s! {
}

pub struct ipc_perm {
#[cfg(musl_v1_2_3)]
#[cfg(musl_v1_2)]
pub __key: crate::key_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
#[deprecated(
since = "0.2.173",
note = "This field is incorrectly named and will be changed
Expand Down
22 changes: 11 additions & 11 deletions src/unix/linux_like/linux/musl/b32/hexagon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ s! {
__st_blksize_padding: Padding<c_int>,
pub st_blocks: crate::blkcnt_t,

#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_atime: crate::time_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_atime_nsec: c_long,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_mtime: crate::time_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_mtime_nsec: c_long,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_ctime: crate::time_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_ctime_nsec: c_long,

#[cfg(musl_v1_2_3)]
#[cfg(musl_v1_2)]
pub st_atim: crate::timespec,
#[cfg(musl_v1_2_3)]
#[cfg(musl_v1_2)]
pub st_mtim: crate::timespec,
#[cfg(musl_v1_2_3)]
#[cfg(musl_v1_2)]
pub st_ctim: crate::timespec,

__unused: Padding<[c_int; 2]>,
Expand All @@ -47,9 +47,9 @@ s! {
}

pub struct ipc_perm {
#[cfg(musl_v1_2_3)]
#[cfg(musl_v1_2)]
pub __key: crate::key_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
#[deprecated(
since = "0.2.173",
note = "This field is incorrectly named and will be changed
Expand Down
16 changes: 8 additions & 8 deletions src/unix/linux_like/linux/musl/b32/mips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ s! {
#[cfg(musl32_time64)]
__st_ctim32: Padding<__c_anonymous_timespec32>,

#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_atime: crate::time_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_atime_nsec: c_long,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_mtime: crate::time_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_mtime_nsec: c_long,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_ctime: crate::time_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_ctime_nsec: c_long,

pub st_blksize: crate::blksize_t,
Expand Down Expand Up @@ -65,9 +65,9 @@ s! {
}

pub struct ipc_perm {
#[cfg(musl_v1_2_3)]
#[cfg(musl_v1_2)]
pub __key: crate::key_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
#[deprecated(
since = "0.2.173",
note = "This field is incorrectly named and will be changed
Expand Down
16 changes: 8 additions & 8 deletions src/unix/linux_like/linux/musl/b32/powerpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ s! {
#[cfg(musl32_time64)]
__st_ctim32: Padding<__c_anonymous_timespec32>,

#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_atime: crate::time_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_atime_nsec: c_long,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_mtime: crate::time_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_mtime_nsec: c_long,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_ctime: crate::time_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
pub st_ctime_nsec: c_long,

__unused: Padding<[c_long; 2]>,
Expand All @@ -70,9 +70,9 @@ s! {
}

pub struct ipc_perm {
#[cfg(musl_v1_2_3)]
#[cfg(musl_v1_2)]
pub __key: crate::key_t,
#[cfg(not(musl_v1_2_3))]
#[cfg(not(musl_v1_2))]
#[deprecated(
since = "0.2.173",
note = "This field is incorrectly named and will be changed
Expand Down
Loading