-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add Rust std support for x86_64-unknown-uefi #100316
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @thomcc (or someone else) soon. Please see the contribution instructions for more information. |
|
r? @dvdhrm |
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.
I think this is really cool! I played a bit with UEFI myself, and while I would definitely not use std
for writing bootloaders (where you need very precise control over initialisation), having it available should be really helpful when writing UEFI applications.
A small nitpick: io::Error::new
allocates even for static data, so it is better to use the internal io::error::const_io_error
for these cases.
96e5d0b
to
ccc4443
Compare
This comment has been minimized.
This comment has been minimized.
I would like other people's opinions about adding
Thus I added |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
0eeded5
to
ad6670e
Compare
ad6670e
to
824f067
Compare
This was originally a part of rust-lang/rust#100316. However, extracting it to a seperate PR should help with any extra testing that might be needed. Signed-off-by: Ayush Singh <[email protected]>
Update compiler-builtins This was originally a part of rust-lang/rust#100316. However, extracting it to a seperate PR should help with any extra testing that might be needed. Signed-off-by: Ayush Singh <[email protected]>
This commit extracts WStrUnits from sys::windows::args to sys_common::wstr. This allows using the same structure for other targets which use wtf8 (example UEFI). This was originally a part of rust-lang/rust#100316 Signed-off-by: Ayush Singh <[email protected]>
Extract WStrUnits to sys_common::wstr This commit extracts WStrUnits from sys::windows::args to sys_common::wstr. This allows using the same structure for other targets which use wtf8 (example UEFI). This was originally a part of rust-lang/rust#100316 Signed-off-by: Ayush Singh <[email protected]>
Closing this in favour of #105861 |
This allows decoupling `Command::spawn` and `Command::output`. This is useful for targets which do support launching programs in blocking mode but do not support multitasking (Eg: UEFI). This was originally conceived when working on rust-lang/rust#100316 Signed-off-by: Ayush Singh <[email protected]>
Allow blocking `Command::output` ### Problem Currently, `Command::output` is internally implemented using `Command::spawn`. This is problematic because some targets (like UEFI) do not actually support multitasking and thus block while the program is executing. This coupling does not make much sense as `Command::output` is supposed to block until the execution is complete anyway and thus does not need to rely on a non-blocking `Child` or any other intermediate. ### Solution This PR moves the implementation of `Command::output` to `std::sys`. This means targets can choose to implement only `Command::output` without having to implement `Command::spawn`. ### Additional Information This was originally conceived when working on rust-lang/rust#100316. Currently, the only target I know about that will benefit from this change is UEFI. This PR can also be used to implement more efficient `Command::output` since the intermediate `Process` is not actually needed anymore, but that is outside the scope of this PR. Since this is not a public API change, I'm not sure if an RFC is needed or not.
Improve generating Custom entry function This commit is aimed at making compiler-generated entry functions (Basically just C `main` right now) more generic so other targets can do similar things for custom entry. This was initially implemented as part of rust-lang/rust#100316. Currently, this moves the entry function name and Call convention to the target spec. Signed-off-by: Ayush Singh <[email protected]>
Implemented modules: 1. alloc 2. os_str 3. env 4. math Tracking Issue: rust-lang#100499 API Change Proposal: rust-lang/libs-team#87 This was originally part of rust-lang#100316. Since that PR was becoming too unwieldy and cluttered, and with suggestion from @dvdhrm, I have extracted a minimal std implementation to this PR. Signed-off-by: Ayush Singh <[email protected]>
Implemented modules: 1. alloc 2. os_str 3. env 4. math Tracking Issue: rust-lang#100499 API Change Proposal: rust-lang/libs-team#87 This was originally part of rust-lang#100316. Since that PR was becoming too unwieldy and cluttered, and with suggestion from @dvdhrm, I have extracted a minimal std implementation to this PR. Signed-off-by: Ayush Singh <[email protected]>
Implemented modules: 1. alloc 2. os_str 3. env 4. math Tracking Issue: rust-lang#100499 API Change Proposal: rust-lang/libs-team#87 This was originally part of rust-lang#100316. Since that PR was becoming too unwieldy and cluttered, and with suggestion from @dvdhrm, I have extracted a minimal std implementation to this PR. Signed-off-by: Ayush Singh <[email protected]>
…ngjubilee Add Minimal Std implementation for UEFI # Implemented modules: 1. alloc 2. os_str 3. env 4. math # Related Links Tracking Issue: rust-lang#100499 API Change Proposal: rust-lang/libs-team#87 # Additional Information This was originally part of rust-lang#100316. Since that PR was becoming too unwieldy and cluttered, and with suggestion from `@dvdhrm,` I have extracted a minimal std implementation to this PR. The example in `src/doc/rustc/src/platform-support/unknown-uefi.md` has been tested for `x86_64-unknown-uefi` and `i686-unknown-uefi` in OVMF. It would be great if someone more familiar with AARCH64 can help with testing for that target. Signed-off-by: Ayush Singh <[email protected]>
Add Minimal Std implementation for UEFI # Implemented modules: 1. alloc 2. os_str 3. env 4. math # Related Links Tracking Issue: rust-lang/rust#100499 API Change Proposal: rust-lang/libs-team#87 # Additional Information This was originally part of rust-lang/rust#100316. Since that PR was becoming too unwieldy and cluttered, and with suggestion from `@dvdhrm,` I have extracted a minimal std implementation to this PR. The example in `src/doc/rustc/src/platform-support/unknown-uefi.md` has been tested for `x86_64-unknown-uefi` and `i686-unknown-uefi` in OVMF. It would be great if someone more familiar with AARCH64 can help with testing for that target. Signed-off-by: Ayush Singh <[email protected]>
Extract WStrUnits to sys_common::wstr This commit extracts WStrUnits from sys::windows::args to sys_common::wstr. This allows using the same structure for other targets which use wtf8 (example UEFI). This was originally a part of rust-lang/rust#100316 Signed-off-by: Ayush Singh <[email protected]>
Extract WStrUnits to sys_common::wstr This commit extracts WStrUnits from sys::windows::args to sys_common::wstr. This allows using the same structure for other targets which use wtf8 (example UEFI). This was originally a part of rust-lang/rust#100316 Signed-off-by: Ayush Singh <[email protected]>
Notice
I have created a smaller PR (#105861) to get just a stripped-down version of std for UEFI merged. This would help simplify the review process and speed up the merge.
Introduction
Hello everyone, I have been working on porting Rust std to UEFI as a part of my Google Summer of Code 2022 project. While there are still problems left to fix, I would like to get more people experienced with Rust to check it out and provide feedback since this is my first time working with the Rust library internals.
Information about the current state of this implementation can be found at
src/doc/rustc/src/platform-support/unknown-uefi.md
. Some of the biggest limitations of the current implementation are the following:The custom entry point function for UEFI is present at: Now generated by compiler like C-main.library/std/src/sys/uefi/mod.rs
, This breaks using std with theno_main
feature. Maybe this can be generated by the compiler like the C entry pointer, but not sure.sys/uefi/net
module was implemented only for running tests usingremote-test-server
and thus is not implemented for any actual production use. If someone really wants to implement it, it would be best to do it on top ofSIMPLE_NETWORK_PROTOCOL
, but that won't be possible in the GSoC timeframe.No
panic=unwind
or backtrace support.Pipes are basically a hack and should not be used unless someone knows what they are doing.: Using a dedicated Pipe Protocol now. However, this protocol hasen't been tested outside ofsrc/tests/ui
yet.Feature: Fixedpanic_abort_tests
is broken. While the UEFI stdio prints the correct output, capturing test output is not working with this feature.: Fixedshould_panic
is broken for tests whenpanic_abort_tests
is disabled.Command is kinda broken. The current spawn is blocking. More about this can be found here
Feel free to try it out and provide feedback. It is possible to run tests using
remote-test-client
andremote-test-server
. For more details, you might want to look at my blog.For those who are wondering how a target like UEFI can benefit from std support, here are a few examples:
std::os::uefi::env
to provide access to the underlying SystemTable and SystemHandle, which are essential for writing anything for UEFI.Related Links