Closed lastmjs closed 11 months ago
The Wasi Wasm and the supposed non-Wasi Wasm after running the tool are identical.
I turned on logging and got a bunch of these:
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::random_get
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::args_get
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::args_sizes_get
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::clock_time_get
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::fd_filestat_set_size
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::fd_read
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::fd_readdir
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::fd_write
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::path_create_directory
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::path_filestat_get
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::path_link
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::path_open
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::path_readlink
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::path_remove_directory
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::path_rename
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::path_unlink_file
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::poll_oneoff
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::sched_yield
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::environ_get
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::environ_sizes_get
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::fd_close
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::fd_fdstat_get
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::fd_fdstat_set_flags
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::fd_filestat_get
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::fd_prestat_get
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::fd_prestat_dir_name
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::fd_seek
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::fd_sync
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::path_filestat_set_times
[2023-05-10T17:03:24Z WARN wasi2ic] Could not find the replacement for the WASI function: wasi_snapshot_preview1::proc_exit
Does this tool have to be used in conjunction with https://github.com/wasm-forge/ic-wasi-polyfill?
It seems like I must have ic_wasi_polyfill
as a dependency, and it must be included in my binary by doing something like ic_wasi_polyfill::init(0);
.
I'll just leave this open because it would be nice for this to be documented, but so far so good! We have Kybra compiling to wasm32-wasi with this and the polyfill
It should be better documented now, so I close the issue.
I think this is still not well documented.
NOTE
The tool requires that you the polyfill implementation is present in your Wasm binary, to do that in your Rust project, you can add the dependency:
cargo add --git https://github.com/wasm-forge/ic-wasi-polyfill
This will create the polyfill methods in your .wasm file, which are needed for wasi2ic.
This section doesn't mention the required start
code:
#[ic_cdk::init]
fn init() {
unsafe {
ic_wasi_polyfill::init(&[0u8; 32], &[]);
}
}
I think this is still not well documented.
This section doesn't mention the required
start
code:
Good point! I've updated the documentation.
Hey! I'm excited to use this tool and for the forthcoming Wasi support on the IC.
I could really use this functionality right now in Kybra (Python CDK), but the tool doesn't seem to work. I've been running it on my Wasm files but I'm still getting an error with one of my Wasm runtimes saying that
wasi_snapshot_preview1
.random_get
is an unknown import, and when I manually inspect the Wasm binaries after running the tool I see the textwasi_snapshot_preview
still all over the place, and I see now instances of__ic_custom
.Am I doing something wrong? I'm compiling with
wasm32-wasi
and then running this tool using the instructions in the README.