console-rs / indicatif

A command line progress reporting library for Rust
MIT License
4.36k stars 241 forks source link

Error compiling on armv5tel architecture #475

Closed lscorcia closed 1 year ago

lscorcia commented 2 years ago

Hi, totally a rust noob so I apologize if I'm misreading what the rust compiler is telling me. I'm trying to build homeassistant on an embedded armv5tel NAS (32-bit). I'm stuck at building maturin, which requires indicatif v0.17.0. While building, I get the following error:

error[E0432]: unresolved import `std::sync::atomic::AtomicU64`
 --> /home/homeassistant/.cargo/registry/src/github.com-1285ae84e5963aae/indicatif-0.17.0/src/state.rs:2:25
  |
2 | use std::sync::atomic::{AtomicU64, AtomicU8, Ordering};
  |                         ^^^^^^^^^
  |                         |
  |                         no `AtomicU64` in `sync::atomic`
  |                         help: a similar name exists in the module: `AtomicU8`

For more information about this error, try `rustc --explain E0432`.
error: failed to compile `maturin v0.13.2 (/home/homeassistant/maturin)`, intermediate artifacts can be found at `/home/homeassistant/maturin/target`

Caused by:
  could not compile `indicatif` due to previous error

Some info about my environment:

(homeassistant) homeassistant@nsa325:~/maturin$ rustc --version
rustc 1.59.0
(homeassistant) homeassistant@nsa325:~/maturin$ cargo --version
cargo 1.56.0
(homeassistant) homeassistant@nsa325:~/maturin$ uname -a
Linux nsa325 5.15.5-kirkwood-tld-1 #1.0 PREEMPT Sun Nov 28 23:08:13 PST 2021 armv5tel GNU/Linux
(homeassistant) homeassistant@nsa325:~/maturin$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

It seems like AtomicU64 is not defined on all architectures (I've seen similar reports for PowerPC, i.e. https://github.com/tikv/rust-prometheus/issues/315). Can you please provide a fix/workaround?

djc commented 2 years ago

Ah yeah, so we're using AtomicU64 which apparently your target doesn't have. I'd be open to polyfilling that with a Mutex<u64> somehow but I probably won't be motivated to write that code myself.

lscorcia commented 2 years ago

I've been able to continue the compilation process by patching indicatif to use atomic-shim, but I had to slightly alter that in order to support the arm platform. Later I found out about https://docs.rs/tokio/0.2.4/src/tokio/loom/std/atomic_u64.rs.html which seems simpler, but already includes the arm platform. Could you borrow the implementation from those?

djc commented 2 years ago

The loom is an internal implementation detail for Tokio that is used to help them test. Relying on atomic-shim for these platforms seems correct, probably submit a PR their way to add arm support?

lscorcia commented 2 years ago

Sent PR at https://github.com/bltavares/atomic-shim/pull/5 . Let's wait and see!

messense commented 2 years ago

Opened #484 to use portable-atomic.