v1.1.3: portable-atomic polyfill so mipsel-softfloat compiles (#46)

v1.1.2 reached cargo build inside the mipsel docker this time
(YAML-fold bug finally out of the way) and surfaced the real
underlying problem: MIPS32 has no native 64-bit atomic instructions,
so std::sync::atomic::AtomicU64 doesn't exist on
mipsel-unknown-linux-musl. Three call sites (DomainFronter stats
counters + the request-cache) failed to resolve the import.

Fix: depend on `portable-atomic` with the `fallback` feature and
import AtomicU64 from there instead of std. The API is identical
(same associated methods, same Ordering accepted), so the two
touched files change only the `use` line. On 64-bit targets
portable-atomic compiles down to the native 64-bit atomic insns
with no overhead; on MIPS32 it uses a global spinlock, which is
fine for counter increments that happen a few times per relay.

Cache.rs and domain_fronter.rs both updated. No other callers of
AtomicU64 in non-cfg-gated code (android_jni.rs has it but is
gated `#![cfg(target_os = "android")]`, so mipsel-linux-musl
never sees it).

`cargo test --lib` / `cargo build` still pass on host.
This commit is contained in:
Shin (Former Aleph)
2026-04-23 11:23:40 +03:00
committed by GitHub
parent 383bea008e
commit 5a5139f6ea
5 changed files with 25 additions and 5 deletions
Generated
+1
View File
@@ -2199,6 +2199,7 @@ dependencies = [
"httparse", "httparse",
"jni 0.21.1", "jni 0.21.1",
"libc", "libc",
"portable-atomic",
"rand 0.8.6", "rand 0.8.6",
"rcgen", "rcgen",
"rustls", "rustls",
+9 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "mhrv-rs" name = "mhrv-rs"
version = "1.1.2" version = "1.1.3"
edition = "2021" edition = "2021"
description = "Rust port of MasterHttpRelayVPN -- DPI bypass via Google Apps Script relay with domain fronting" description = "Rust port of MasterHttpRelayVPN -- DPI bypass via Google Apps Script relay with domain fronting"
license = "MIT" license = "MIT"
@@ -49,6 +49,14 @@ http = "1"
flate2 = "1" flate2 = "1"
directories = "5" directories = "5"
futures-util = { version = "0.3", default-features = false, features = ["std"] } futures-util = { version = "0.3", default-features = false, features = ["std"] }
# 64-bit atomics on 32-bit MIPS/ARMv5 targets. Rust's std AtomicU64 is
# only available on targets that expose native 64-bit atomics, which
# mipsel-unknown-linux-musl does not — `AtomicU64` resolves to "no
# such name in sync::atomic" and the whole crate fails to build. The
# `fallback` feature uses a global spinlock when the target can't do
# 64-bit atomically; on x86_64 / aarch64 / armv7 / etc. it compiles
# down to the native instructions with no overhead.
portable-atomic = { version = "1", features = ["fallback"] }
# Optional UI dep: only pulled in when --features ui is set. # Optional UI dep: only pulled in when --features ui is set.
# Both `glow` (OpenGL 2+) and `wgpu` (DX12/Vulkan/Metal) are compiled in; # Both `glow` (OpenGL 2+) and `wgpu` (DX12/Vulkan/Metal) are compiled in;
+2 -2
View File
@@ -14,8 +14,8 @@ android {
applicationId = "com.therealaleph.mhrv" applicationId = "com.therealaleph.mhrv"
minSdk = 24 // Android 7.0 — covers 99%+ of live devices. minSdk = 24 // Android 7.0 — covers 99%+ of live devices.
targetSdk = 34 targetSdk = 34
versionCode = 112 versionCode = 113
versionName = "1.1.2" versionName = "1.1.3"
// Ship all four mainstream Android ABIs: // Ship all four mainstream Android ABIs:
// - arm64-v8a — 95%+ of real-world Android phones since 2019 // - arm64-v8a — 95%+ of real-world Android phones since 2019
+7 -1
View File
@@ -1,5 +1,11 @@
use std::collections::{HashMap, VecDeque}; use std::collections::{HashMap, VecDeque};
use std::sync::atomic::{AtomicU64, Ordering}; // AtomicU64 polyfill via portable-atomic — mipsel is MIPS32 with no
// native 64-bit atomic instructions, so std::sync::atomic::AtomicU64
// doesn't exist on that target. portable-atomic falls back to a
// global spinlock on 32-bit MIPS; compiles to native insns on x86_64
// and aarch64.
use portable_atomic::AtomicU64;
use std::sync::atomic::Ordering;
use std::sync::Mutex; use std::sync::Mutex;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
+6 -1
View File
@@ -10,7 +10,12 @@
//! TODO: add parallel range-based downloads. //! TODO: add parallel range-based downloads.
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering}; // AtomicU64 via portable-atomic: native on 64-bit / armv7, spinlock-
// backed on mipsel (MIPS32 has no 64-bit atomic instructions). API
// is identical to std::sync::atomic::AtomicU64 so call sites need
// no other changes.
use portable_atomic::AtomicU64;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc; use std::sync::Arc;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};