mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
[GH-ISSUE #423] Do not use std::sync::atomic::AtomicU64 on platforms which do not support 64-bit atomics
#181
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @NoisyCoil on GitHub (Jul 29, 2024).
Original GitHub issue: https://github.com/bootandy/dust/issues/423
Hi there. While packaging dust for Debian (it landed in unstable yesterday: https://tracker.debian.org/pkg/rust-du-dust), the build failed on armel because
AtomicU64is missing on that platform. I could work around this usingportable_atomics, but the underlying issue here is you are usingu64s instead ofusizes for file sizes and similar stuff even on 32-bit platforms. Could you please fix this? Thank you.@wugeer commented on GitHub (Jul 29, 2024):
If usize is used instead of u64 for file size, then for a 32-bit platform, usize is u32, and the upper limit of the representable file size is 4GB, which obviously does not meet the upper limit of file size.
If you can't compile it on your machine, could you please submit a PR to fix the issue yourself?
Or Could you provide more detailed information to help me reproduce this issue? :(
@NoisyCoil commented on GitHub (Jul 29, 2024):
Well you're right there, I didn't think about this very obvious shortcoming :-)
The issue as I mentioned before is armel does not have 64-bit atomic unsigned integers: there's
AtomicU32andAtomicUsizebut noAtomicU64, so the build fails on that platform since you're using them insrc/progress.rs.AtomicU64only exists whentarget_has_atomic_load_store = "64"is true (see e.g. https://doc.rust-lang.org/1.80.0/src/core/sync/atomic.rs.html#3141), and armel is not one of those platforms.The easiest way to reproduce would be to set up a cross-compilation environment for armel and try to build
dust. E.g. on debian-like OSes with rustup installedthen add
to
.cargo/config.tomland compile withcargo build --targetarmv5te-unknown-linux-gnueabi. The build will fail.As to possibile ways for fixing this issue, a Debian Rust Team member suggested to use portable-atomic, which has a
AtomicU64for armel too. If you are not opposed to adding one dependency for these platforms alone then sure, I could submit a PR. I want to be clear though that with this change the build succeeds but functionality has not been tested on armel (there are no changes for other platforms).@wugeer commented on GitHub (Jul 30, 2024):
I think you can submit a PR after sufficient testing on the armel platform and let bootandy review the PR. I hope this can help you. :)
@wugeer commented on GitHub (Aug 6, 2024):
Hi, @NoisyCoil maybe you should turn your commit into a PR so that @bootandy can review the code?

Also I think the comment here is irrelevant and can be removed.
@NoisyCoil commented on GitHub (Aug 6, 2024):
Hey there. The commit needs some further testing, I'll open a PR when I find the time to do so.
ROTFL. That might have been part of the above mentioned testing at some point, I didn't even realize it was there (nor that it would get linked to the main issue). Like, literally ROTFL.