-
Notifications
You must be signed in to change notification settings - Fork 472
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
Fix no_std build #368
Fix no_std build #368
Conversation
|
||
# Check for no_std environment. | ||
cd .. && cargo run --manifest-path ci/Cargo.toml --bin remove-dev-dependencies */Cargo.toml && cd - | ||
cargo check --target thumbv7m-none-eabi --no-default-features |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If build with Linux as a target, it will link to std, so it need to specify a target that does not have std.
I see what you've done here & agree that it's a better solution to what I have done (less breakage)... however, I'm not sure how it handles lazy_static. Lazy_static is available for |
AFAIK the current no_std crossbeam does not depend on lazy_tactic. The crossbeam currently uses lazy_static in two places: crossbeam/crossbeam-utils/src/sync/sharded_lock.rs Lines 556 to 562 in 86eff71
crossbeam/crossbeam-epoch/src/default.rs Lines 10 to 13 in 86eff71
However, these are both in modules that require std. Also, they seem to be used with features not available on no_std. crossbeam/crossbeam-utils/src/sync/sharded_lock.rs Lines 7 to 10 in 86eff71
crossbeam/crossbeam-epoch/src/default.rs Lines 15 to 18 in 86eff71
So I don't think crossbeam needs to think about lazy_static's no_std support. |
Also, I believe many crates in the ecosystem (e.g., serde, futures, itertools) support the no_std environment in the same way as the current crossbeam. lazy_static supports no_std in the other way as these crates, because it adds FYI, you can always use the lazy_static/spin_no_std feature or configure the feature to allow users to opt-in like the following: [dependencies]
lazy_static = { version = "1", optional = true }
[features]
std = ["lazy_static"]
spin_no_std = ["lazy_static/spin_no_std"] The point to keep in mind when always using the lazy_static/spin_no_std feature is that it has not been tested on older versions than the latest stable (lazy_static, spin). |
Yeah I just didn't want to fragment the options. |
@taiki-e This looks great to me, thanks so much! :) The only thing left to do is to update the readmes -- check out how we're currently explaining which parts of Crossbeam are available with individual features. We should probably also mention the |
8045061
to
61e15de
Compare
@stjepang |
Thanks again, this looks ready for landing now! :) bors r+ |
Build succeeded |
508: Make std feature to depend on alloc feature r=jeehoonkang a=taiki-e `alloc` crate is available on 1.36, see #368 (comment) for why it was previously separated. This is a breaking change proposed in #503. Co-authored-by: Taiki Endo <te316e89@gmail.com>
Closes #364