From 9a861ed61c696761c18037ad6255176409bf43fe Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 27 Jan 2025 09:53:12 +0100 Subject: [PATCH 1/2] Rerun build if RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64 changes Collect the linux_time_bits64 in one place. --- build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 915b3a929b0b3..3ee2b406aaeb6 100644 --- a/build.rs +++ b/build.rs @@ -44,7 +44,6 @@ fn main() { let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok() || rustc_minor_ver >= 80; - let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok(); // The ABI of libc used by std is backward compatible with FreeBSD 12. // The ABI of libc from crates.io is backward compatible with FreeBSD 12. @@ -81,6 +80,8 @@ fn main() { Some(_) | None => (), } + 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 { set_cfg("linux_time_bits64"); } From b0e68783fa8f4b91b6a1fa03fe7d4b1ebb8ed015 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 16 Dec 2024 09:21:06 +0100 Subject: [PATCH 2/2] Add forgotten SO_*_NEW values to powerpc, mips and arm The _NEW defines are not available in musl and ohos. --- src/unix/linux_like/linux/arch/generic/mod.rs | 14 +++++++++++++- src/unix/linux_like/linux/arch/mips/mod.rs | 5 +++++ src/unix/linux_like/linux/arch/powerpc/mod.rs | 10 +++++----- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index ea38a20d67e40..098c83c3b885b 100644 --- a/src/unix/linux_like/linux/arch/generic/mod.rs +++ b/src/unix/linux_like/linux/arch/generic/mod.rs @@ -57,13 +57,24 @@ const SO_TIMESTAMPING_OLD: c_int = 37; cfg_if! { if #[cfg(all( linux_time_bits64, - any(target_arch = "arm", target_arch = "x86") + any(target_arch = "arm", target_arch = "x86"), + not(any(target_env = "musl", target_env = "ohos")) ))] { pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW; pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW; pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW; pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW; pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW; + } else if #[cfg(all( + linux_time_bits64, + any(target_arch = "arm", target_arch = "x86"), + any(target_env = "musl", target_env = "ohos") + ))] { + pub const SO_TIMESTAMP: c_int = 63; + pub const SO_TIMESTAMPNS: c_int = 64; + pub const SO_TIMESTAMPING: c_int = 65; + pub const SO_RCVTIMEO: c_int = 66; + pub const SO_SNDTIMEO: c_int = 67; } else { pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD; pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD; @@ -114,6 +125,7 @@ cfg_if! { any( target_arch = "x86", target_arch = "x86_64", + target_arch = "arm", target_arch = "aarch64", target_arch = "csky", target_arch = "loongarch64" diff --git a/src/unix/linux_like/linux/arch/mips/mod.rs b/src/unix/linux_like/linux/arch/mips/mod.rs index 70364b3108cd4..612f8c73ffc3c 100644 --- a/src/unix/linux_like/linux/arch/mips/mod.rs +++ b/src/unix/linux_like/linux/arch/mips/mod.rs @@ -99,8 +99,13 @@ pub const SO_BINDTOIFINDEX: c_int = 62; // but CI haven't support them yet. // Some related consts could be found in b32.rs and b64.rs const SO_TIMESTAMP_OLD: c_int = 29; +const SO_RCVTIMEO_NEW: c_int = 66; +const SO_SNDTIMEO_NEW: c_int = 67; const SO_TIMESTAMPNS_OLD: c_int = 35; const SO_TIMESTAMPING_OLD: c_int = 37; +const SO_TIMESTAMP_NEW: c_int = 63; +const SO_TIMESTAMPNS_NEW: c_int = 64; +const SO_TIMESTAMPING_NEW: c_int = 65; cfg_if! { if #[cfg(linux_time_bits64)] { pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW; diff --git a/src/unix/linux_like/linux/arch/powerpc/mod.rs b/src/unix/linux_like/linux/arch/powerpc/mod.rs index 2e8d3e3675393..50d1ef17bb887 100644 --- a/src/unix/linux_like/linux/arch/powerpc/mod.rs +++ b/src/unix/linux_like/linux/arch/powerpc/mod.rs @@ -94,11 +94,11 @@ pub const SO_ZEROCOPY: c_int = 60; pub const SO_TXTIME: c_int = 61; pub const SCM_TXTIME: c_int = SO_TXTIME; pub const SO_BINDTOIFINDEX: c_int = 62; -// pub const SO_TIMESTAMP_NEW: c_int = 63; -// pub const SO_TIMESTAMPNS_NEW: c_int = 64; -// pub const SO_TIMESTAMPING_NEW: c_int = 65; -// pub const SO_RCVTIMEO_NEW: c_int = 66; -// pub const SO_SNDTIMEO_NEW: c_int = 67; +const SO_TIMESTAMP_NEW: c_int = 63; +const SO_TIMESTAMPNS_NEW: c_int = 64; +const SO_TIMESTAMPING_NEW: c_int = 65; +const SO_RCVTIMEO_NEW: c_int = 66; +const SO_SNDTIMEO_NEW: c_int = 67; // pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; // pub const SO_PREFER_BUSY_POLL: c_int = 69; // pub const SO_BUSY_POLL_BUDGET: c_int = 70;