From cfad01449fee502e1bd074eac7927896406bb249 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 17 Jan 2023 11:54:56 -0800 Subject: [PATCH] Fix compilation on armv7-unknown-freebsd (#518) * Fix compilation on armv7-unknown-freebsd Use `time_t::MAX` to avoid depending on the relationship between `time_t` and `c_long`. * Silence the deprecation warning about `time_t`. --- .github/workflows/main.yml | 1 + src/backend/libc/net/syscalls.rs | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 608ddfd8..d1ec347c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -203,6 +203,7 @@ jobs: - run: cargo check -Z build-std --target mips64-openwrt-linux-musl --all-targets --features=all-apis - run: cargo check -Z build-std --target x86_64-unknown-dragonfly --all-targets --features=all-apis - run: cargo check -Z build-std --target sparc-unknown-linux-gnu --all-targets --features=all-apis + - run: cargo check -Z build-std --target armv7-unknown-freebsd --all-targets --features=all-apis # Omit --all-targets on haiku because not all the tests build yet. - run: cargo check -Z build-std --target x86_64-unknown-haiku --features=all-apis # x86_64-uwp-windows-msvc isn't currently working. diff --git a/src/backend/libc/net/syscalls.rs b/src/backend/libc/net/syscalls.rs index 3d8a849c..15c6762b 100644 --- a/src/backend/libc/net/syscalls.rs +++ b/src/backend/libc/net/syscalls.rs @@ -555,11 +555,12 @@ pub(crate) mod sockopt { return Err(io::Errno::INVAL); } - let tv_sec = timeout.as_secs().try_into(); - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - let tv_sec = tv_sec.unwrap_or(c::c_long::MAX); - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - let tv_sec = tv_sec.unwrap_or(i64::MAX); + // Rust's musl libc bindings deprecated `time_t` while they + // transition to 64-bit `time_t`. What we want here is just + // "whatever type `timeval`'s `tv_sec` is", so we're ok using + // the deprecated type. + #[allow(deprecated)] + let tv_sec = timeout.as_secs().try_into().unwrap_or(c::time_t::MAX); // `subsec_micros` rounds down, so we use `subsec_nanos` and // manually round up.