Skip to content

Conversation

Tropix126
Copy link
Contributor

@Tropix126 Tropix126 commented Aug 28, 2025

This PR adds standard library support for the VEX V5 Brain (armv7a-vex-v5 target). It is more-or-less an updated version of the library-side work done in #131530.

This was a joint effort between me, @lewisfm, @max-niederman, @Gavin-Niederman and several other members of the vexide project.

Background

VEXos is a fairly unconventional operating system, with user code running in a restricted enviornment with regards to I/O capabilities and whatnot. As such, several OS-dependent APIs are unsupported or have partial support (such as std::net, std::process, and most of std::thread). A more comprehensive list of what does or doesn't work is outlined in the updated target documentation. Despite these limitations, we believe that libstd support on this target still has value to users, especially given the popular use of this hardware for educational purposes. For some previous discussion on this matter, see this comment.

SDK Linkage

VEXos doesn't really ship with an official libc or POSIX-style platform API (and though it does port newlib, these are stubbed on top of the underlying SDK). Instead, VEX provides their own SDK for calling platform APIs. Their official SDK is kept proprietary (with public headers), though open-source implementations exist. Following the precedent of the armv6k-nintendo-3ds team's work in #95897, we've opted not to directly link libstd to any SDK with the expectation that users will provide their own - either through vex-sdk-build (which will download the official SDK from VEX), vex-sdk-jumptable (a compatible, open-source reimplementation), or potentially through linking the PROS kernel. The vex-sdk crate used in the VEXos PAL provides libc-style FFI bindings for any compatible system library, so any of these options should work fine.

Future Work

This PR implements virtually everything we are currently able to implement given the current capabilities of the platform. The exception to this is file directory enumeration, though the implementation of that is sufficiently gross enough to drive us away from supporting this officially.

Additionally, I have a working branch implementing the panic_unwind runtime for this target, which is something that would be nice to see in the future, though given the volume of compiler changes i've deemed it out-of-scope for this PR.

@rustbot
Copy link
Collaborator

rustbot commented Aug 28, 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

@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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 28, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 28, 2025

Some changes occurred in src/doc/rustc/src/platform-support

cc @Noratrieb

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.

These commits modify compiler targets.
(See the Target Tier Policy.)

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


pub fn exists(path: &Path) -> io::Result<bool> {
let path = CString::new(path.as_os_str().as_encoded_bytes())
.map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "Path contained a null byte"))?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this failure case actually possible, considering that this platform's OsString probably shouldn't allow null bytes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that this check is probably a good thing to have, but we shouldn't be doing it ourselves. I'll switch to small_c_string::run_path_with_cstr which is what the unix PAL (and basically all other targets except solid) use.

@tgross35
Copy link
Contributor

I think the limitations here seem fine, and from a quick skim nothing jumps out to me as problematic. Nominating to make sure the team doesn't have any concerns.

@rustbot label +I-libs-nominated

@rustbot rustbot added the I-libs-nominated Nominated for discussion during a libs team meeting. label Aug 28, 2025
@rust-log-analyzer

This comment has been minimized.

@@ -84,6 +84,11 @@ wasi = { version = "0.11.0", features = [
r-efi = { version = "5.2.0", features = ['rustc-dep-of-std'] }
r-efi-alloc = { version = "2.0.0", features = ['rustc-dep-of-std'] }

[target.'cfg(target_os = "vexos")'.dependencies]
vex-sdk = { version = "0.27.0", features = [
Copy link
Contributor

Choose a reason for hiding this comment

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

As a note, this version has a docs failure https://docs.rs/crate/vex-sdk/0.27.0

Copy link
Contributor Author

@Tropix126 Tropix126 Aug 28, 2025

Choose a reason for hiding this comment

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

Yeah, I noticed that. docs.rs has given me hell in the past when it comes to crates built for unconventional targets. I think it's likely we published 0.27.0 before they updated their server to a nightly version supporting armv7a-vex-v5. If that's a blocker for getting this PR in then I can push a new version and just lie in the docs.rs config by telling it to build for armv7a-none-eabi. The previously documented version should have a more or less identical API surface.

Copy link
Contributor

Choose a reason for hiding this comment

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

No it's not a blocker here, this was just a heads up that you might want to poke it

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 I-libs-nominated Nominated for discussion during a libs team meeting. 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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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.

5 participants