-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Linux on MIPS and ARMv5TE #39
Conversation
These platforms does not provide `std::sync::atomic::AtomicU64`. - Add a cargo feature "quanta" and make it a default feature. - Add a module `common::time` and conditionally choose the source file from "time_quanta.rs" or "time_compat.rs". - time_quanta.rs file has type aliases to `quanta::{Instant, Clock, Mock}`. It also has `AtomicInstant` holding an `AtomicU64`. - time_compat.rs file has `Instant` based on `std::time::Instant` and quanta-like `Clock` and `Mock`. It also has `AtomicInstant` holding a `RwLock<Option<Instant>>`. - Update Cache, etc. modules to use `common::time` instead of `quanta`. - Add a step to GitHub Actions to test future feature without quanta/ `AtomicU64`.
Remove some old codes.
Remove target_arch = "mips" from the cfg_attr for the time module. (It will not work when quanta feature is still enabled it Cargo.toml)
Add a section to the README to explain that `default-features = false` will be needed on these platforms.
Note that I've also opened metrics-rs/quanta#55 to fix quanta on these platforms, so maybe after that lands moka can still use quanta but not |
Thanks. Good point. Hmm. I am having hard time to come up with a good short name for the feature. Moka uses So... perhaps, I think |
- Rename the Cargo feature "quanta" to "atomic64". - Update the change log and readme. - Update a comment in the yml for GitHub Actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
I've just tested this on a mipsel router, it compiles and runs, but hits seanmonstar/num_cpus#69 , I think this line should be changed to use 1 if moka/src/common/thread_pool.rs Line 56 in 988816a
See also rust-lang/futures-rs#1835 |
Ensure to set num threads to 1 for thread pools when `num_cpus::get()` returns 0.
Thanks for testing on the real hardware. I did not realize it could return 0. Changed to use 1 when it returns 0. |
Verified the followings:
Test 1 % git remote -v
origin git@github.com:moka-rs/moka.git (fetch)
origin git@github.com:moka-rs/moka.git (push)
$ git log -1
commit d91c5ce4bbd6d403e1fe37fa9ed1831225b18434 (HEAD -> mips-armv5, origin/mips-armv5)
Author: Tatsuya Kawano
Date: Fri Sep 10 20:19:23 2021 +0800
Bump the version to v0.5.3
$ sudo rm -rf release
$ docker run -it --rm -v $(pwd):/home/rust/src \
--mount source=cargo-registry,target=/root/.cargo/registry \
messense/rust-musl-cross:armv5te-musleabi \
cargo build --no-default-features --features future --target armv5te-unknown-linux-musleabi
...
Compiling moka v0.5.3 (/home/rust/src)
...
Finished dev [unoptimized + debuginfo] target(s) in 32.67s
$ echo $?
0
$ docker run -it --rm -v $(pwd):/home/rust/src \
--mount source=cargo-registry,target=/root/.cargo/registry \
messense/rust-musl-cross:mips-musl \
sh -c "RUSTFLAGS='-C target-feature=+crt-static -C link-arg=-s' \
cargo build --no-default-features --features future --target mips-unknown-linux-musl"
...
Compiling moka v0.5.3 (/home/rust/src)
...
Finished dev [unoptimized + debuginfo] target(s) in 8.96s
$ echo $?
0
$ docker run -it --rm -v $(pwd):/home/rust/src \
--mount source=cargo-registry,target=/root/.cargo/registry \
messense/rust-musl-cross:mipsel-musl \
sh -c "RUSTFLAGS='-C target-feature=+crt-static -C link-arg=-s' \
cargo build --no-default-features --features future --target mipsel-unknown-linux-musl"
...
Compiling moka v0.5.3 (/home/rust/src)
...
Finished dev [unoptimized + debuginfo] target(s) in 8.82s
$ echo $?
0 |
Test again on mipsel router and I'm happy to report that it works™. |
Thank you for testing. I am merging this and will publish v0.5.3 to crate.io soon. |
This pull request is for supporting Linux on 32-bit MIPS and ARMv5TE. These platforms does not provide
std::sync::atomic::AtomicU64
so currently both Moka and quanta will not compile.After merging this PR, Moka will compile on 32-bit MIPS. For ARMv5TE, you need to adddefault-features = false
to "moka" dependency in Cargo.toml and then Moka will compile.After this PR is merged, you can resolve the errors by disabling the default features by adding
default-features = false
to the dependency declaration in Cargo.toml. This will remove quanta from the dependencies and enable a fall-back implementation in Moka.Changes
quanta
atomic64
and make it a default feature.common::time
and conditionally choose the source file from "time_quanta.rs" or "time_compat.rs".quanta::{Instant, Clock, Mock}
. It also hasAtomicInstant
holding anAtomicU64
.Instant
based onstd::time::Instant
and quanta-likeClock
andMock
. It also hasAtomicInstant
holding aRwLock<Option<Instant>>
.common::time
instead ofquanta
.AtomicU64
.Fixes #38.