Skip to content
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

Disable compilation of Atomic64 code in metric.rs if there's no Atomic64 #188

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mjt0k
Copy link

@mjt0k mjt0k commented Apr 16, 2023

Atomic64 is not present, at least, on armel, mipsel and x32 platforms. Disable compilation of metrics.rs which enhances this data type.

Atomic64 is not present, at least, on armel, mipsel and x32 platforms.

Signed-off-by: Michael Tokarev <[email protected]>
@@ -11,6 +11,8 @@
//! of these components can choose what metrics they’re interested in and also
//! can add their own custom metrics without the need to maintain forks.

#![cfg(target_has_atomic = "64")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would result in a compilation error when this condition is not true.

To implement this, it should be on https://github.com/rust-vmm/vmm-sys-util/blob/main/src/lib.rs#L21 like:

#[cfg(target_has_atomic = "64")]
pub mod metric;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it doesn't result in compilation error: see https://buildd.debian.org/status/package.php?p=rust-vmm-sys-util&suite=sid - it compiled fine on all platforms where previously this caused an error. I guess it will result in compilation error of crates which use this one, as there will be no implementation for the declared functionality.

But I must admit: I know nothing about rust. It's the 2nd day since I looked at what rust actually is, what I suggest is just something I've seen being used elsewhere. I've no idea if this is a correct solution or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing #![cfg(target_has_atomic = "64")] (notice the !) is equivalent to:

#[cfg(target_has_atomic = "64")] pub mod metric;

We can still have it as @JonathanWoollett-Light suggested even if they're equivalent because it is making it a bit more obvious that the whole module is excluded from compilation on targets that don't support atomic64.

@andreeaflorescu
Copy link
Member

@mjt0k can we think about a way to test this in the CI? I find it nice that we're adding support for other platforms as well, but the problem I am seeing is that (similar to the big endian support in vm-virtio) we are going to fix it, and future PRs will break it because we're not testing it.

@andreeaflorescu
Copy link
Member

@mjt0k can you fix your commit message so we can merge this? We are expecting the summary to be less than 60 chars, and the body to be less than 72 (i think). We have some issues with the CI (cargo audit is not installed on arm, and that's why it's failing), so we can ignore that for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants