Skip to content

Commit 4b57007

Browse files
authored
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.
1 parent 2e8aad8 commit 4b57007

5 files changed

Lines changed: 25 additions & 5 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mhrv-rs"
3-
version = "1.1.2"
3+
version = "1.1.3"
44
edition = "2021"
55
description = "Rust port of MasterHttpRelayVPN -- DPI bypass via Google Apps Script relay with domain fronting"
66
license = "MIT"
@@ -49,6 +49,14 @@ http = "1"
4949
flate2 = "1"
5050
directories = "5"
5151
futures-util = { version = "0.3", default-features = false, features = ["std"] }
52+
# 64-bit atomics on 32-bit MIPS/ARMv5 targets. Rust's std AtomicU64 is
53+
# only available on targets that expose native 64-bit atomics, which
54+
# mipsel-unknown-linux-musl does not — `AtomicU64` resolves to "no
55+
# such name in sync::atomic" and the whole crate fails to build. The
56+
# `fallback` feature uses a global spinlock when the target can't do
57+
# 64-bit atomically; on x86_64 / aarch64 / armv7 / etc. it compiles
58+
# down to the native instructions with no overhead.
59+
portable-atomic = { version = "1", features = ["fallback"] }
5260

5361
# Optional UI dep: only pulled in when --features ui is set.
5462
# Both `glow` (OpenGL 2+) and `wgpu` (DX12/Vulkan/Metal) are compiled in;

android/app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ android {
1414
applicationId = "com.therealaleph.mhrv"
1515
minSdk = 24 // Android 7.0 — covers 99%+ of live devices.
1616
targetSdk = 34
17-
versionCode = 112
18-
versionName = "1.1.2"
17+
versionCode = 113
18+
versionName = "1.1.3"
1919

2020
// Ship all four mainstream Android ABIs:
2121
// - arm64-v8a — 95%+ of real-world Android phones since 2019

src/cache.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
use std::collections::{HashMap, VecDeque};
2-
use std::sync::atomic::{AtomicU64, Ordering};
2+
// AtomicU64 polyfill via portable-atomic — mipsel is MIPS32 with no
3+
// native 64-bit atomic instructions, so std::sync::atomic::AtomicU64
4+
// doesn't exist on that target. portable-atomic falls back to a
5+
// global spinlock on 32-bit MIPS; compiles to native insns on x86_64
6+
// and aarch64.
7+
use portable_atomic::AtomicU64;
8+
use std::sync::atomic::Ordering;
39
use std::sync::Mutex;
410
use std::time::{Duration, Instant};
511

src/domain_fronter.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
//! TODO: add parallel range-based downloads.
1111
1212
use std::collections::HashMap;
13-
use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering};
13+
// AtomicU64 via portable-atomic: native on 64-bit / armv7, spinlock-
14+
// backed on mipsel (MIPS32 has no 64-bit atomic instructions). API
15+
// is identical to std::sync::atomic::AtomicU64 so call sites need
16+
// no other changes.
17+
use portable_atomic::AtomicU64;
18+
use std::sync::atomic::{AtomicUsize, Ordering};
1419
use std::sync::Arc;
1520
use std::time::{Duration, Instant};
1621

0 commit comments

Comments
 (0)