我正在尝试创建一个嵌入友好的可执行文件(占用空间小且不依赖于 Rust 标准库),它使用一个已经支持no_std构建的库 (wasmi) 。Rust 的新手,我只是将说明拼凑在一起,但其要点似乎是按照步骤操作。
对于可执行文件:
#![no_std]
#![no_main]
use core::panic::PanicInfo;
/// This function is called on panic.
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}
#[no_mangle]
pub extern "C" fn _start(_argc: isize, _argv: *const *const u8) -> ! {
interpret(_argc, _argv);
loop {}
}
Run Code Online (Sandbox Code Playgroud)
即:
#![no_std]main因为我们没有调用它的运行时)我要编译的 Cargo 文件如下所示:
[package]
name = "driver"
version = "0.1.0"
edition = "2018"
[dependencies.wasmi]
path = "../../github_dev/wasmi"
features = ["core"] …Run Code Online (Sandbox Code Playgroud)