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

Does not build with time feature and --cfg loom #2463

Open
faern opened this issue Apr 29, 2020 · 4 comments
Open

Does not build with time feature and --cfg loom #2463

faern opened this issue Apr 29, 2020 · 4 comments
Labels
A-tokio Area: The main tokio crate C-question User questions that are neither feature requests nor bug reports

Comments

@faern
Copy link
Contributor

faern commented Apr 29, 2020

Version

0.2.20 and latest git

Platform

macOS

Description

I'm using loom as recommended in the loom docs: by setting RUSTFLAGS="--cfg loom". This causes tokio to not compile if the time feature is activated. Can be reproduced by just creating an empty crate and adding tokio as a dependency:

[dependencies]
tokio = { version = "0.2.20", features = ["time"] }
$ RUSTFLAGS="--cfg loom" cargo build
...
error[E0432]: unresolved import `crate::sync::AtomicWaker`
 --> /Users/faern/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.20/src/time/driver/entry.rs:2:5
  |
2 | use crate::sync::AtomicWaker;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^ no `AtomicWaker` in `sync`

I assume crates depending on tokio should be able to use loom so I guess this is not intentional.

@carllerche
Copy link
Member

Tokio is not currently meant to be depended on w/ the loom cfg.

Could you provide more info on what you are trying to do?

@carllerche carllerche added the C-question User questions that are neither feature requests nor bug reports label Apr 29, 2020
@Darksonn Darksonn added the A-tokio Area: The main tokio crate label Apr 29, 2020
@faern
Copy link
Contributor Author

faern commented Apr 29, 2020

I'm using loom to test the correctness of a channel implementation I'm writing. This channel implementation also happens to implement Future. so I write integration tests that check if the channel works with tokio. But the crate does not compile when tested with loom as described above.

I could of course just #[cfg(not(loom))] all my tests that involve tokio and not pull in the dependency for dev-dependencies if that cfg is set. But I would then not be able to have loom evaluate the correctness of my impl Future for Receiver which is what I was hoping I could do.

This is one problem of using/recommending --cfg loom instead of having a public feature or recommending that the cfg flag be named --cfg {crate_name}_loom or something. The cfg currently propagates to all dependencies and no one knows which of your dependencies might be loom aware or how they might behave with that cfg.

@faern
Copy link
Contributor Author

faern commented Apr 29, 2020

I can understand if it would be really hard to make all of tokio work the way I expected it (given loom is a tokio project). But then, as an alternative solution: Is there any super simple async runtime that is loom aware that I can pull in?

Maybe I could write something simple myself...

@faern
Copy link
Contributor Author

faern commented Apr 29, 2020

How do you test the memory correctness of all Future types inside tokio if not with loom?

benbromhead added a commit to benbromhead/loom that referenced this issue Jul 17, 2020
I recently was bitten with tokio-rs/tokio#2463 while implementing loom based tests for code that was unrelated to the dependency that used tokio. This is a simple doc change until a different / better solution is implemented
ankitbhrdwj added a commit to vmware/node-replication that referenced this issue Sep 9, 2021
ankitbhrdwj added a commit to vmware/node-replication that referenced this issue Sep 9, 2021
ankitbhrdwj added a commit to vmware/node-replication that referenced this issue Sep 10, 2021
gz pushed a commit to vmware/node-replication that referenced this issue Nov 17, 2021
hunhoffe pushed a commit to gz/node-replication that referenced this issue May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-question User questions that are neither feature requests nor bug reports
Projects
None yet
Development

No branches or pull requests

3 participants