Description
Compiling a minimal hello-word UEFI application is easy. Setting up a productive development environment with a "run in QEMU" command and unit-tests is hard, however. Especially the last part is very challenging, as one has to mix the UEFI target with a standard target for test execution - rust runtime problems (panic handlers, global allocators), different compilation targets... I worked on something (https://github.com/phip1611/rust-uefi-template) that supports the simultaneous building and unit testing inside the same Cargo project.
(Either I'm totally dumb or this is indeed very hard).
Can you (@nicholasbishop, @GabrielMajeri but also the community) please tell me what you think? And if yes, could or should we integrate the template into the rust-osdev namespace? The README and the code comments should describe the relevant problems that I'm solving there..
Summary of the Problems
- "cargo test" needs the host platform's target, such as x86_64-unknown-linux-gnu, as
libtest
is pre-compiled and working on this target. Unit tests can't be compiled and executed for thex86_64-unknown-uefi
target - that would not work. - "cargo build" needs the
x86_64-unknown-uefi
target - however, a application may use a custom
#[panic_handler]
. This won't work for unit tests in a cargo test setup - the same as above applies to the
#[global_allocator]
- a cargo workspace also shouldn't help here / doesn't change the root problem
As a consequence, it takes a few quirks to cope with that - and they are not very intuitive, I think.
https://github.com/phip1611/rust-uefi-template
PS: I just found that there is an open issue in cargo because of this problem: rust-lang/cargo#6784