*: Add support for MIPS and PowerPC, which lack support for Atomic{U,I}64#37
*: Add support for MIPS and PowerPC, which lack support for Atomic{U,I}64#37chitoku-k wants to merge 2 commits intoprometheus:masterfrom
Conversation
|
Hi @chitoku-k, Thanks for the patch. First of all, would you mind adding the targets that you would like to see supported to the cross-compile matrix in our CI workflow? client_rust/.github/workflows/rust.yml Lines 146 to 147 in f7dd611 That way we ensure to never break compatibility. Now to the patch itself: I wonder whether we should support Benefits:
Drawbacks:
I would argue, that with enough documentation around the drawback, the benefits outweigh it. What do you think @chitoku-k? |
…I}64 Signed-off-by: Chitoku <odango@chitoku.jp>
Signed-off-by: Chitoku <odango@chitoku.jp>
688fb16 to
6120834
Compare
|
Thanks @mxinden for your effort made on the cross compilation set up, and your prompt review! I've added For what you've pointed out about pros and cons over |
I don't think one should use Cargo features to toggle this behavior. Cargo features are additive across your entire dependency tree. Thus, if some upstream dependency of yours enables the I would still suggest to use In cases where one would still need an use std::sync::atomic::Ordering;
struct AtomicU64(atomic_shim::AtomicU64);
impl prometheus_client::metrics::counter::Atomic<u64> for AtomicU64 {
fn inc(&self) -> u64 {
self.0.inc_by(1)
}
fn inc_by(&self, v: u64) -> u64 {
self.0.fetch_add(v, Ordering::Relaxed)
}
fn get(&self) -> u64 {
self.0.load(Ordering::Relaxed)
}
}
fn main() {
use prometheus_client::metrics::counter::Counter;
let _counter: Counter<AtomicU64> = Counter::default();
}@chitoku-k what do you think? |
|
Thank you for responding. As it was difficult to reach a consensus over this approach, I am closing this PR and will create a different PR that simply drops support for |
Signed-off-by: Chitoku odango@chitoku.jp
According to the official documentation, Rust does not provide
std::sync::atomic::AtomicU64andstd::sync::atomic::AtomicI64for MIPS and PowerPC with 32-bit pointers.See: https://doc.rust-lang.org/std/sync/atomic/
This means that prometheus-client even doesn't compile for those platforms:
The
atomic-shimcrate provides alternative implementation for those platforms if the build target is MIPS or PowerPC, otherwise just re-exportsstd::sync::atomic::AtomicU64andstd::sync::atomic::AtomicI64. With this patch it successfully compiles.