Docs.rs fails to build due to cfg conditions not being satisfied

Hi, forum, I published a crate that uses AtomicU128 on crates.io, however docs.rs fails to build because it doesn't support it:

[INFO] [stderr] error[E0432]: unresolved import `core::sync::atomic::AtomicU128`

https://docs.rs/crate/rcu_128/0.1.0/builds/1253840

AtomicU128 needs this cfg:

#[cfg(target_has_atomic_load_store = "128")]

How should I do?

I don't know if there is a tier-1 target that supports AtomicU128 right off the top of my head, but you can configure docs.rs to build for a different tier-1 target than x86_64-unknown-linux-gnu in your Cargo.toml.

You also might wish to suppress compile time errors by annotating your crate with [cfg(target_has_atomic = "128")] where appropriate. I.e. I think your whole crate only makes sense on targets with AtomicU128 support, so you could add a #![cfg(target_has_atomic = "128")] as the first line in your crate's root file to make it build on targets that don't support AtomicU128 as well. That wouldn't really be a fix for docs.rs though, as docs.rs would simply render your documentation as if your crate is empty (which it would be on targets without AtomicU128).

2 Likes

Thanks a lot, I will add this cfg

1 Like

I found that x86_64-apple-darwin and x86_64-pc-windows-msvc support AtomicU128, thanks for your help!

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.