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

uefi std: add example and add book chapter #1331

Merged
merged 6 commits into from
Aug 21, 2024

Conversation

phip1611
Copy link
Contributor

@phip1611 phip1611 commented Aug 14, 2024

Split-out of #1292. This adds an example for a Rust standard binary for UEFI that utilizes uefi on top of that. It also adds a chapter to the book.

Checklist

  • Sensible git history (for example, squash "typo" or "fix" commits). See the Rewriting History guide for help.
  • Update the changelog (if necessary)

@phip1611 phip1611 marked this pull request as draft August 14, 2024 18:08
@phip1611 phip1611 changed the title Uefi std uefi std: add example and add book chapter Aug 14, 2024
@phip1611 phip1611 marked this pull request as ready for review August 14, 2024 18:28
@phip1611 phip1611 force-pushed the uefi-std branch 3 times, most recently from 87cd184 to 722eeeb Compare August 14, 2024 18:43
book/src/tutorial/rust-std.md Outdated Show resolved Hide resolved
book/src/SUMMARY.md Outdated Show resolved Hide resolved
.github/workflows/rust.yml Outdated Show resolved Hide resolved
In the `uefi` crate, we provide tooling to create a `no_std` + `no_main`
binary, i.e., an UEFI image, in a convenient way. However, there is also the
option to create a "standard" binary with Rust. The result is the same, but the
build process and the overall programming is much more similar to regular
Copy link
Member

Choose a reason for hiding this comment

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

nit: the build process is the same either way right? cargo build --target <uefi-target>

instead. Just as you would to in the typical Linux application, for example.

The `uefi` crate is suited to extend the functionality of these "standard
binaries".
Copy link
Member

Choose a reason for hiding this comment

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

The three sections above are essentially all "what is uefi + std" -- I think it would be clearer to shorten down to a quick explanation that there is ongoing work to add more support for std to the UEFI targets in rust with link(s) to where more info can be found, then show the example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I also wasn't that happy with them. Do you like the new version better?

implementation is not feature-complete and work in progress
(Mid-2024, Rust stable 1.80), and will also be it in the coming months and
probably years. Over time, you will need less and less specific features of
`uefi` and can utilize standard and well-known OS-independent APIs in `std`
Copy link
Member

Choose a reason for hiding this comment

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

I think we should avoid making claims about it being recommended or not -- we can stick to just the facts and note that uefi+std is still in progress and gated by an unstable flag.

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 hope the new phrasing is better?

@phip1611 phip1611 marked this pull request as draft August 15, 2024 10:26
@phip1611 phip1611 marked this pull request as ready for review August 15, 2024 10:26
binary, i.e., an UEFI image, in a convenient way by providing a `#[entry]`
macro for the crate's main function. However, after ongoing efforts in upstream
Rust, there is also the option to create a "standard" binary for UEFI. The
result is the same, but the build process and the overall programming experience
Copy link
Contributor Author

Choose a reason for hiding this comment

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

result -> the compiled result


## About

In the `uefi` crate, we provide tooling to create a `no_std` + `no_main`
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'm still not 100% satisfied with the phrasing of this paragraph. Any idea?

Copy link
Member

Choose a reason for hiding this comment

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

One thing that would help I think is to drop the "standard binary" terminology; stick to no_std and the std crate.

Here's my attempt:


Programs created with the uefi crate are typically created with no_std and no_main. A no_std crate can use the core and alloc parts of Rust's standard library, but not std. A no_main executable does not use the standard main entry point, and must define its own entry point; uefi provides the entry macro for this purpose.

Rust has added partial support for building UEFI executables without no_std and no_main. Some functionality requires a nightly toolchain, and some parts of std are gated by the unstable uefi_std feature. Follow the tracking issue for details.

@phip1611
Copy link
Contributor Author

Ready for review. What do you think? Is this a better version?

@nicholasbishop nicholasbishop added this pull request to the merge queue Aug 21, 2024
Merged via the queue into rust-osdev:main with commit fa36299 Aug 21, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants