rust-osdev / ovmf-prebuilt

Apache License 2.0
23 stars 7 forks source link

Compile error[E0658]: use of unstable library feature 'restricted_std' #37

Closed ryanbaggs2 closed 4 months ago

ryanbaggs2 commented 4 months ago

When compiling for the target x86_64-unknown-none I get the error message:

error[E0658]: use of unstable library feature 'restricted_std'
  |
  = help: add `#![feature(restricted_std)]` to the crate attributes to enable

I added the attribute #![feature(restricted_std)] to the top of the lib.rs file and also had to add it to my project main.rs file which corrected the issue. The change also successfully compiled for the x86_64-pc-windows-msvc target. This occurs for the nightly-x86_64-pc-windows-msvc toolchain, but the attribute can't be applied for the 'stable' or 'beta' compilers: https://doc.rust-lang.org/error_codes/E0554.html

This is my first issue and I am not sure what the standard procedure would be for getting this fixed. Is there a way to add attributes for specific toolchains, or is that not recommended because the feature "may be removed or altered in the future"? Any input would be greatly appreciated.

Note: Edited as I found that the feature attribute does not compile for stable/beta channel.

nicholasbishop commented 4 months ago

In it's current form, this repo is no longer actually providing a crate. The thing up on crates.io (https://docs.rs/crate/ovmf-prebuilt/0.1.0-alpha.1/source/) is an older version that packaged a OVMF-pure-efi.fd file directly into the crate. The code included in that crate is very trivial: https://docs.rs/crate/ovmf-prebuilt/0.1.0-alpha.1/source/src/lib.rs, just provides a path to that fd file. Since that code uses std, it won't work on a no-std target like x86_64-unknown-none.

In the current version of the repo, we're building an EDK2 release and uploading the binaries a Github release. For example: https://github.com/rust-osdev/ovmf-prebuilt/releases/tag/edk2-stable202311-r2

So the intended usage is to just download those files and unpack. You can see an example of this in uefi-rs: https://github.com/rust-osdev/uefi-rs/blob/ccdfb66cd073442e3dc08412a7c18369d906aff7/xtask/src/qemu.rs#L95

Something I've been thinking of doing is moving a variation of that code into this crate and publishing a new version with that.

ryanbaggs2 commented 4 months ago

Ok, thank you.

Basically I arrived at this issue from using the bootloader repo (https://github.com/rust-osdev/bootloader) as a dependency for a project, which has this as a dependency. So I should I instead open the issue on the bootloader repo?

ryanbaggs2 commented 4 months ago

Thank you again for your input, I think I just opened this issue in the wrong repo.

phil-opp commented 4 months ago

Basically I arrived at this issue from using the bootloader repo (https://github.com/rust-osdev/bootloader) as a dependency for a project,

If you want to use the latest version of the bootloader crate, you should add a dependency on the bootloader_api crate to your kernel. Then you use the bootloader crate from e.g. a build script to create a bootable disk image. See https://github.com/rust-osdev/bootloader?tab=readme-ov-file#usage for details.