-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
DRAFT RFC: limited no-std
I/O support using portable-io
#7102
Draft
brody4hire
wants to merge
19
commits into
tokio-rs:master
Choose a base branch
from
brody4hire:start-no-std-io-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… from tokio/src/net/mod.rs)
…ptions at this point: "std", io-util, io-std, parking_lot (parking_lot with & w/o std)
…ESTIGATE & RESOLVE ISSUES with fs test mocks
github-actions
bot
added
R-loom-current-thread
Run loom current-thread tests on this PR
R-loom-multi-thread
Run loom multi-thread tests on this PR
R-loom-multi-thread-alt
Run loom multi-thread alt tests on this PR
R-loom-sync
Run loom sync tests on this PR
R-loom-time-driver
Run loom time driver tests on this PR
labels
Jan 15, 2025
Darksonn
added
A-tokio
Area: The main tokio crate
M-runtime
Module: tokio/runtime
labels
Jan 15, 2025
My initial reaction is that this is not going to happen. Other runtimes can support the no-std use-case. |
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
M-runtime
Module: tokio/runtime
R-loom-current-thread
Run loom current-thread tests on this PR
R-loom-multi-thread
Run loom multi-thread tests on this PR
R-loom-multi-thread-alt
Run loom multi-thread alt tests on this PR
R-loom-sync
Run loom sync tests on this PR
R-loom-time-driver
Run loom time driver tests on this PR
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
I have been very interested in getting some more widely-used Rust libraries working with
no-std
for embedded devices.no-std
support was requested in #3544 /cc @surechenMy initial idea is to start achieving this kind of support with help from
portable-io
crate that I recently published.NOTE that my primary intention is to start discussion on supporting
no-std
, with a working demo, and would be very happy to discuss any possible alternative solutions.Possible alternative solutions
tokio-io
, maybe like it was done in the past, and only supportno-std
in that crateno-std
I/O updates in a separate forkstd::io
traits & classes, working withno-std
std::io
functionality intocore
, as discussed in RFC: Proposed refactoring to implement core::io rust-lang/rfcs#2262Solution
Proposed solution
This is a proposal to get the core IO & optional
io-util
features working withno-std
using some of the Rust I/O traits & types that I extracted inportable-io
crate.Features added:
std
- proposed to be enabled by defaultportable-io
- option to useportable-io
instead ofstd::io
for the standard I/O traits & typeswith some feature requirements & restrictions:
std
orportable-io
features must be enabled (both can be enabled)portable-io
withfs
,net
,process
,rt
orsignal
featuresother implementation notes:
parking_lot
with slight API variation to supportno-std
intokio/src/io/split.rs
- I think it would be ideal to use a more portable mutex APItokio/src/io/util/write_all_buf.rs
to simplify logic as needed forportable-io
option - I think this logic should be simplified in a separate PR for normalstd::io
usage as wellMajor drawbacks:
no-std
directive requires updates throughout the Tokio codebase to explicitly importstd
crate features that would otherwise have been implicit, adding some complexity to the existing importsportable-io
crate is new & unproven - it is yet another alternative for Proposed refactoring to implement core::io rust-lang/rfcs#2262 (looks like some other alternatives had stopped development)Testing done:
cargo test -F full -p tokio
✅Build testing done:
cargo build --no-default-features -F portable-io -p tokio
cargo build -F portable-io -p tokio
cargo build --no-default-features -F portable-io,io-util -p tokio
cargo build -F portable-io,io-util -p tokio
cargo build --no-default-features -F portable-io,io-util,macros,time -p tokio
cargo build -F full -p tokio
# (same as before; includes std; DOES NOT include portable-io)Deferred for now:
no-std
support for runtime tasks - I would like to see this, would likely require major rework of context state maintained inthread_local!
portable-atomic
to enable building for targets with no atomic ptr (etc.)tokio-stream
&tokio-util
to supportno-std
(I have started this in my workarea)Loose ends & major TODO items:
no-std
target (with no std library available)fs
test mock not working with these updates - seems to be an issue between these updates &mockall
intokio/src/fs/mocks.rs
- testing withfs
disabled for now - needs further investigationportable-io
feature