forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
This should be trivial to do (once libtheseus is sorted out).
We can define a function in std::sys::theseus as follows:
pub unsafe fn __theseus_start(args: Vec<String>) -> isize {
let argc = args.len();
let argv = args.as_ptr();
extern "C" {
// This function is exported by Rust (and all other language) binaries.
fn main(argc: isize, argv: *const *const c_char) -> i32;
}
// Do initialisation.
let result = unsafe { main(argc as size, argv) };
// Do cleanup.
result as isize
}* This code is untested.
To run a crate we would then run __theseus_start similar to how we currently run main functions exported by applications. The process of finding the section and transmuting it to a function pointer would remain the same.
Hermit does a slightly similar thing.
I believe std::sys::theseus::init is called by the main function exported by binaries. E.g. Hermit's runtime_entry function doesn't initialise the network because it's done in init, which will be called by main.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
🛑 Blocked