Skip to content

Conversation

lasiotus
Copy link
Contributor

Motor OS was added as a no-std Tier-3 target in
PR 146848 as x86_64-unknown-motor.

This PR adds the std library for Motor OS.

While the PR may seem large, all it does is proxy
std pal calls to moto-rt. Where there is some non-trivial
code (e.g. thread::spawn), it is quite similar, often
identical, to what other platforms do.

@rustbot
Copy link
Collaborator

rustbot commented Sep 24, 2025

These commits modify the library/Cargo.lock file. Unintentional changes to library/Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging.

cc @davidtwco, @wesleywiser

@rustbot rustbot added A-tidy Area: The tidy tool S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 24, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 24, 2025

r? @tgross35

rustbot has assigned @tgross35.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@tgross35
Copy link
Contributor

Is there any notable std functionality that isn't supported on this platform? Just skimming it, it seems like things are pretty complete (threads, systemtime, process, etc)

Nominating for libs as this adds a new std target.

@rustbot label +I-libs-nominated

@rustbot rustbot added the I-libs-nominated Nominated for discussion during a libs team meeting. label Sep 24, 2025
@lasiotus
Copy link
Contributor Author

Is there any notable std functionality that isn't supported on this platform? Just skimming it, it seems like things are pretty complete (threads, systemtime, process, etc)

I believe all major pieces are supported/implemented, including networking. Some specific things are not (yet) fully implemented, like FS links, or DNS lookup (at the moment, only "localhost" resolves to an IP address). On the other hand, tokio is ported via a mio port, which was not completely trivial...

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 25, 2025
@bors
Copy link
Collaborator

bors commented Sep 25, 2025

☔ The latest upstream changes (presumably #147019) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot

This comment has been minimized.

@lasiotus lasiotus requested a review from tgross35 September 26, 2025 21:38
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 26, 2025
@lasiotus lasiotus requested a review from bjorn3 September 26, 2025 21:38
@Amanieu
Copy link
Member

Amanieu commented Oct 1, 2025

We discussed this in the @rust-lang/libs meeting and are happy to add std support for this target because it supports all major functionality of std.

@Amanieu Amanieu removed the I-libs-nominated Nominated for discussion during a libs team meeting. label Oct 1, 2025
@lasiotus
Copy link
Contributor Author

lasiotus commented Oct 2, 2025

We discussed this in the @rust-lang/libs meeting and are happy to add std support for this target because it supports all major functionality of std.

Thanks, Amanieu!

@tgross35 Trevor, how can I improve this PR to make it mergeable?

@tgross35
Copy link
Contributor

tgross35 commented Oct 2, 2025

It's on my list, I just haven't had a chance to do a thorough review yet (probably later this week)

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 3, 2025
@rustbot

This comment has been minimized.

@lasiotus lasiotus force-pushed the motor-os_stdlib_pr branch from f2731ec to 41b36cd Compare October 8, 2025 02:11
@rustbot

This comment has been minimized.

@lasiotus
Copy link
Contributor Author

lasiotus commented Oct 8, 2025

I believe I have addressed all comments now. Thanks for the detailed review, the PR is definitely better now than what it was two weeks ago!

@lasiotus lasiotus requested a review from tgross35 October 8, 2025 02:14
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 8, 2025
Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

Looks pretty good for me! Just a few small requests then I think this should be set.

View changes since this review

Comment on lines 453 to 459
unsafe {
match addr.v4.sin_family {
netc::AF_INET => SocketAddr::V4(crate::net::SocketAddrV4::from(addr.v4)),
netc::AF_INET6 => SocketAddr::V6(crate::net::SocketAddrV6::from(addr.v6)),
_ => panic!("bad sin_family {}", addr.v4.sin_family),
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to format this as

// SAFETY: All variants have `sin_family` at the same offset
let family = unsafe { addr.v4.sin_family };
match family { ... }

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 8, 2025
As part of work to add stdlib support for Motor OS.
Motor OS was added as a no-std Tier-3 target in
rust-lang#146848
as x86_64-unknown-motor.

This patch/PR adds the std library for Motor OS.

While the patch may seem large, all it does is proxy
std pal calls to moto-rt. When there is some non-trivial
code (e.g. thread::spawn), it is quite similar, and often
identical, to what other platforms do.
@lasiotus lasiotus force-pushed the motor-os_stdlib_pr branch from 41b36cd to f2731ec Compare October 8, 2025 16:01
@rustbot

This comment has been minimized.

@lasiotus lasiotus requested a review from tgross35 October 8, 2025 16:05
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 8, 2025
@lasiotus
Copy link
Contributor Author

lasiotus commented Oct 8, 2025

Comment on lines +453 to +459

    unsafe {
        match addr.v4.sin_family {
            netc::AF_INET => SocketAddr::V4(crate::net::SocketAddrV4::from(addr.v4)),
            netc::AF_INET6 => SocketAddr::V6(crate::net::SocketAddrV6::from(addr.v6)),
            _ => panic!("bad sin_family {}", addr.v4.sin_family),
        }
    }

Contributor
@tgross35 tgross35 2 hours ago

It would be good to format this as

// SAFETY: All variants have `sin_family` at the same offset
let family = unsafe { addr.v4.sin_family };
match family { ... }

This is done/fixed. For some reason I can't add comments to or resolve the comment above (a github bug?).

@lasiotus lasiotus force-pushed the motor-os_stdlib_pr branch from f2731ec to a828ffc Compare October 8, 2025 18:53
@rustbot
Copy link
Collaborator

rustbot commented Oct 8, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tidy Area: The tidy tool S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants