Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm][wasi] incorrecly adds imports that aren't needed #96862

Open
silesmo opened this issue Jan 11, 2024 · 12 comments
Open

[wasm][wasi] incorrecly adds imports that aren't needed #96862

silesmo opened this issue Jan 11, 2024 · 12 comments
Assignees
Labels
arch-wasm WebAssembly architecture area-Build-mono os-wasi Related to WASI variant of arch-wasm
Milestone

Comments

@silesmo
Copy link

silesmo commented Jan 11, 2024

Description

Wasm modules built with mono incorrectly includes wasi imports that aren't used by the module.

This causes tests to fail for https://github.com/bytecodealliance/wit-bindgen.

Related: #96419

@AaronRobinsonMSFT @lewing @yowl @jsturtevant

Reproduction Steps

Build mono example: https://github.com/silesmo/wasm-unmanaged-callers-bug

Expected behavior

Imports for the same code built with native-aot-llvm:

Function { module: "test:numbers/test", field: "get-scalar", import_idx: 0, index: 10, params: [], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-char", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-float32", import_idx: 0, index: 17, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-float64", import_idx: 0, index: 16, params: [F64], results: [F64] }
Function { module: "test:numbers/test", field: "roundtrip-s16", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-s32", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-s64", import_idx: 0, index: 18, params: [I64], results: [I64] }
Function { module: "test:numbers/test", field: "roundtrip-s8", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u16", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u32", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u64", import_idx: 0, index: 18, params: [I64], results: [I64] }
Function { module: "test:numbers/test", field: "roundtrip-u8", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "set-scalar", import_idx: 0, index: 0, params: [I32], results: [] }
Function { module: "wasi_snapshot_preview1", field: "environ_get", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "environ_sizes_get", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "clock_time_get", import_idx: 0, index: 33, params: [I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_close", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_fdstat_get", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_fdstat_set_flags", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_prestat_get", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_prestat_dir_name", import_idx: 0, index: 2, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_read", import_idx: 0, index: 6, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_seek", import_idx: 0, index: 48, params: [I32, I64, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_write", import_idx: 0, index: 6, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_filestat_get", import_idx: 0, index: 23, params: [I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_open", import_idx: 0, index: 60, params: [I32, I32, I32, I32, I32, I64, I64, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_unlink_file", import_idx: 0, index: 2, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "poll_oneoff", import_idx: 0, index: 6, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "proc_exit", import_idx: 0, index: 0, params: [I32], results: [] }
Function { module: "wasi_snapshot_preview1", field: "sched_yield", import_idx: 0, index: 10, params: [], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "random_get", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }

Actual behavior

Imports built with mono:
Function { module: "wasi_snapshot_preview1", field: "sock_accept", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "test:numbers/test", field: "get-scalar", import_idx: 0, index: 9, params: [], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-char", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-float32", import_idx: 0, index: 59, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-float64", import_idx: 0, index: 55, params: [F64], results: [F64] }
Function { module: "test:numbers/test", field: "roundtrip-s16", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-s32", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-s64", import_idx: 0, index: 23, params: [I64], results: [I64] }
Function { module: "test:numbers/test", field: "roundtrip-s8", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u16", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u32", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u64", import_idx: 0, index: 23, params: [I64], results: [I64] }
Function { module: "test:numbers/test", field: "roundtrip-u8", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "set-scalar", import_idx: 0, index: 1, params: [I32], results: [] }
Function { module: "wasi_snapshot_preview1", field: "args_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "args_sizes_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "environ_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "environ_sizes_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "clock_res_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "clock_time_get", import_idx: 0, index: 26, params: [I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_advise", import_idx: 0, index: 66, params: [I32, I64, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_close", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_fdstat_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_fdstat_set_flags", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_filestat_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_filestat_set_size", import_idx: 0, index: 24, params: [I32, I64], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_filestat_set_times", import_idx: 0, index: 66, params: [I32, I64, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_pread", import_idx: 0, index: 71, params: [I32, I32, I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_prestat_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_prestat_dir_name", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_pwrite", import_idx: 0, index: 71, params: [I32, I32, I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_read", import_idx: 0, index: 12, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_readdir", import_idx: 0, index: 71, params: [I32, I32, I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_seek", import_idx: 0, index: 41, params: [I32, I64, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_sync", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_tell", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_write", import_idx: 0, index: 12, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_create_directory", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_filestat_get", import_idx: 0, index: 11, params: [I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_filestat_set_times", import_idx: 0, index: 72, params: [I32, I32, I32, I32, I64, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_link", import_idx: 0, index: 14, params: [I32, I32, I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_open", import_idx: 0, index: 73, params: [I32, I32, I32, I32, I32, I64, I64, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_readlink", import_idx: 0, index: 10, params: [I32, I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_remove_directory", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_rename", import_idx: 0, index: 10, params: [I32, I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_symlink", import_idx: 0, index: 11, params: [I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_unlink_file", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "poll_oneoff", import_idx: 0, index: 12, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "proc_exit", import_idx: 0, index: 1, params: [I32], results: [] }
Function { module: "wasi_snapshot_preview1", field: "random_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jan 11, 2024
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jan 11, 2024
@ghost
Copy link

ghost commented Jan 11, 2024

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Wasm modules built with mono incorrectly includes wasi imports that aren't used by the module.

This causes tests to fail for https://github.com/bytecodealliance/wit-bindgen.

@AaronRobinsonMSFT @lewing @yowl @jsturtevant

Reproduction Steps

Build mono example: https://github.com/silesmo/wasm-unmanaged-callers-bug

Expected behavior

Imports for the same code built with native-aot-llvm:

Function { module: "test:numbers/test", field: "get-scalar", import_idx: 0, index: 10, params: [], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-char", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-float32", import_idx: 0, index: 17, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-float64", import_idx: 0, index: 16, params: [F64], results: [F64] }
Function { module: "test:numbers/test", field: "roundtrip-s16", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-s32", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-s64", import_idx: 0, index: 18, params: [I64], results: [I64] }
Function { module: "test:numbers/test", field: "roundtrip-s8", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u16", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u32", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u64", import_idx: 0, index: 18, params: [I64], results: [I64] }
Function { module: "test:numbers/test", field: "roundtrip-u8", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "set-scalar", import_idx: 0, index: 0, params: [I32], results: [] }
Function { module: "wasi_snapshot_preview1", field: "environ_get", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "environ_sizes_get", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "clock_time_get", import_idx: 0, index: 33, params: [I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_close", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_fdstat_get", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_fdstat_set_flags", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_prestat_get", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_prestat_dir_name", import_idx: 0, index: 2, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_read", import_idx: 0, index: 6, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_seek", import_idx: 0, index: 48, params: [I32, I64, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_write", import_idx: 0, index: 6, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_filestat_get", import_idx: 0, index: 23, params: [I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_open", import_idx: 0, index: 60, params: [I32, I32, I32, I32, I32, I64, I64, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_unlink_file", import_idx: 0, index: 2, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "poll_oneoff", import_idx: 0, index: 6, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "proc_exit", import_idx: 0, index: 0, params: [I32], results: [] }
Function { module: "wasi_snapshot_preview1", field: "sched_yield", import_idx: 0, index: 10, params: [], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "random_get", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }

Actual behavior

Imports built with mono:
Function { module: "wasi_snapshot_preview1", field: "sock_accept", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "test:numbers/test", field: "get-scalar", import_idx: 0, index: 9, params: [], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-char", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-float32", import_idx: 0, index: 59, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-float64", import_idx: 0, index: 55, params: [F64], results: [F64] }
Function { module: "test:numbers/test", field: "roundtrip-s16", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-s32", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-s64", import_idx: 0, index: 23, params: [I64], results: [I64] }
Function { module: "test:numbers/test", field: "roundtrip-s8", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u16", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u32", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u64", import_idx: 0, index: 23, params: [I64], results: [I64] }
Function { module: "test:numbers/test", field: "roundtrip-u8", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "set-scalar", import_idx: 0, index: 1, params: [I32], results: [] }
Function { module: "wasi_snapshot_preview1", field: "args_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "args_sizes_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "environ_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "environ_sizes_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "clock_res_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "clock_time_get", import_idx: 0, index: 26, params: [I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_advise", import_idx: 0, index: 66, params: [I32, I64, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_close", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_fdstat_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_fdstat_set_flags", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_filestat_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_filestat_set_size", import_idx: 0, index: 24, params: [I32, I64], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_filestat_set_times", import_idx: 0, index: 66, params: [I32, I64, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_pread", import_idx: 0, index: 71, params: [I32, I32, I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_prestat_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_prestat_dir_name", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_pwrite", import_idx: 0, index: 71, params: [I32, I32, I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_read", import_idx: 0, index: 12, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_readdir", import_idx: 0, index: 71, params: [I32, I32, I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_seek", import_idx: 0, index: 41, params: [I32, I64, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_sync", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_tell", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_write", import_idx: 0, index: 12, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_create_directory", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_filestat_get", import_idx: 0, index: 11, params: [I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_filestat_set_times", import_idx: 0, index: 72, params: [I32, I32, I32, I32, I64, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_link", import_idx: 0, index: 14, params: [I32, I32, I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_open", import_idx: 0, index: 73, params: [I32, I32, I32, I32, I32, I64, I64, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_readlink", import_idx: 0, index: 10, params: [I32, I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_remove_directory", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_rename", import_idx: 0, index: 10, params: [I32, I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_symlink", import_idx: 0, index: 11, params: [I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_unlink_file", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "poll_oneoff", import_idx: 0, index: 12, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "proc_exit", import_idx: 0, index: 1, params: [I32], results: [] }
Function { module: "wasi_snapshot_preview1", field: "random_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: silesmo
Assignees: -
Labels:

area-CodeGen-coreclr, untriaged

Milestone: -

@silesmo
Copy link
Author

silesmo commented Jan 11, 2024

These are all the imports that shouldn't be there:
Function { module: "wasi_snapshot_preview1", field: "sock_accept", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "args_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "args_sizes_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "clock_res_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_advise", import_idx: 0, index: 66, params: [I32, I64, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_pread", import_idx: 0, index: 71, params: [I32, I32, I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_pwrite", import_idx: 0, index: 71, params: [I32, I32, I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_sync", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_tell", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_create_directory", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_filestat_set_times", import_idx: 0, index: 72, params: [I32, I32, I32, I32, I64, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_link", import_idx: 0, index: 14, params: [I32, I32, I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_readlink", import_idx: 0, index: 10, params: [I32, I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_remove_directory", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_rename", import_idx: 0, index: 10, params: [I32, I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_symlink", import_idx: 0, index: 11, params: [I32, I32, I32, I32, I32], results: [I32] }

@radical radical added arch-wasm WebAssembly architecture area-Build-mono and removed area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels Jan 11, 2024
@ghost
Copy link

ghost commented Jan 11, 2024

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Wasm modules built with mono incorrectly includes wasi imports that aren't used by the module.

This causes tests to fail for https://github.com/bytecodealliance/wit-bindgen.

Related: #96419

@AaronRobinsonMSFT @lewing @yowl @jsturtevant

Reproduction Steps

Build mono example: https://github.com/silesmo/wasm-unmanaged-callers-bug

Expected behavior

Imports for the same code built with native-aot-llvm:

Function { module: "test:numbers/test", field: "get-scalar", import_idx: 0, index: 10, params: [], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-char", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-float32", import_idx: 0, index: 17, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-float64", import_idx: 0, index: 16, params: [F64], results: [F64] }
Function { module: "test:numbers/test", field: "roundtrip-s16", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-s32", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-s64", import_idx: 0, index: 18, params: [I64], results: [I64] }
Function { module: "test:numbers/test", field: "roundtrip-s8", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u16", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u32", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u64", import_idx: 0, index: 18, params: [I64], results: [I64] }
Function { module: "test:numbers/test", field: "roundtrip-u8", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "set-scalar", import_idx: 0, index: 0, params: [I32], results: [] }
Function { module: "wasi_snapshot_preview1", field: "environ_get", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "environ_sizes_get", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "clock_time_get", import_idx: 0, index: 33, params: [I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_close", import_idx: 0, index: 1, params: [I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_fdstat_get", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_fdstat_set_flags", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_prestat_get", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_prestat_dir_name", import_idx: 0, index: 2, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_read", import_idx: 0, index: 6, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_seek", import_idx: 0, index: 48, params: [I32, I64, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_write", import_idx: 0, index: 6, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_filestat_get", import_idx: 0, index: 23, params: [I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_open", import_idx: 0, index: 60, params: [I32, I32, I32, I32, I32, I64, I64, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_unlink_file", import_idx: 0, index: 2, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "poll_oneoff", import_idx: 0, index: 6, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "proc_exit", import_idx: 0, index: 0, params: [I32], results: [] }
Function { module: "wasi_snapshot_preview1", field: "sched_yield", import_idx: 0, index: 10, params: [], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "random_get", import_idx: 0, index: 3, params: [I32, I32], results: [I32] }

Actual behavior

Imports built with mono:
Function { module: "wasi_snapshot_preview1", field: "sock_accept", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "test:numbers/test", field: "get-scalar", import_idx: 0, index: 9, params: [], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-char", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-float32", import_idx: 0, index: 59, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-float64", import_idx: 0, index: 55, params: [F64], results: [F64] }
Function { module: "test:numbers/test", field: "roundtrip-s16", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-s32", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-s64", import_idx: 0, index: 23, params: [I64], results: [I64] }
Function { module: "test:numbers/test", field: "roundtrip-s8", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u16", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u32", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "roundtrip-u64", import_idx: 0, index: 23, params: [I64], results: [I64] }
Function { module: "test:numbers/test", field: "roundtrip-u8", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "test:numbers/test", field: "set-scalar", import_idx: 0, index: 1, params: [I32], results: [] }
Function { module: "wasi_snapshot_preview1", field: "args_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "args_sizes_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "environ_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "environ_sizes_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "clock_res_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "clock_time_get", import_idx: 0, index: 26, params: [I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_advise", import_idx: 0, index: 66, params: [I32, I64, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_close", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_fdstat_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_fdstat_set_flags", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_filestat_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_filestat_set_size", import_idx: 0, index: 24, params: [I32, I64], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_filestat_set_times", import_idx: 0, index: 66, params: [I32, I64, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_pread", import_idx: 0, index: 71, params: [I32, I32, I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_prestat_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_prestat_dir_name", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_pwrite", import_idx: 0, index: 71, params: [I32, I32, I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_read", import_idx: 0, index: 12, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_readdir", import_idx: 0, index: 71, params: [I32, I32, I32, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_seek", import_idx: 0, index: 41, params: [I32, I64, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_sync", import_idx: 0, index: 4, params: [I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_tell", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "fd_write", import_idx: 0, index: 12, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_create_directory", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_filestat_get", import_idx: 0, index: 11, params: [I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_filestat_set_times", import_idx: 0, index: 72, params: [I32, I32, I32, I32, I64, I64, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_link", import_idx: 0, index: 14, params: [I32, I32, I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_open", import_idx: 0, index: 73, params: [I32, I32, I32, I32, I32, I64, I64, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_readlink", import_idx: 0, index: 10, params: [I32, I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_remove_directory", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_rename", import_idx: 0, index: 10, params: [I32, I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_symlink", import_idx: 0, index: 11, params: [I32, I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "path_unlink_file", import_idx: 0, index: 7, params: [I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "poll_oneoff", import_idx: 0, index: 12, params: [I32, I32, I32, I32], results: [I32] }
Function { module: "wasi_snapshot_preview1", field: "proc_exit", import_idx: 0, index: 1, params: [I32], results: [] }
Function { module: "wasi_snapshot_preview1", field: "random_get", import_idx: 0, index: 5, params: [I32, I32], results: [I32] }

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: silesmo
Assignees: -
Labels:

arch-wasm, area-CodeGen-coreclr, untriaged, area-Build-mono

Milestone: -

@radical
Copy link
Member

radical commented Jan 11, 2024

cc @pavelsavara @radekdoulik

@pavelsavara
Copy link
Member

@maraf

@lambdageek
Copy link
Member

we probably need to run something like wasm-opt --remove-unused-module-elements as part of the module build.

@lewing lewing self-assigned this Jan 26, 2024
@lewing
Copy link
Member

lewing commented Jan 26, 2024

I haven't had time to look into this directly but are you running dotnet publish or just build. The imports should be linked away if you are running publish. At the moment it isn't really possible to do iltriming during build which is what is required for the import table generator to remove the linkage.

The NativeAOT build operates differently.

@lewing lewing added this to the 9.0.0 milestone Feb 5, 2024
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Feb 5, 2024
@lewing
Copy link
Member

lewing commented Mar 27, 2024

It appears something has broken in the build and the the component selection logic is not working at all so things like sock_accept are coming from the debugger component. With a nightly build I see

(import "wasi_snapshot_preview1" "sock_accept" (func $fimport$0 (param i32 i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "args_get" (func $fimport$1 (param i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "args_sizes_get" (func $fimport$2 (param i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "environ_get" (func $fimport$3 (param i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "environ_sizes_get" (func $fimport$4 (param i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "clock_res_get" (func $fimport$5 (param i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "clock_time_get" (func $fimport$6 (param i32 i64 i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_advise" (func $fimport$7 (param i32 i64 i64 i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_close" (func $fimport$8 (param i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_fdstat_get" (func $fimport$9 (param i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_fdstat_set_flags" (func $fimport$10 (param i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_filestat_get" (func $fimport$11 (param i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_filestat_set_size" (func $fimport$12 (param i32 i64) (result i32)))
 (import "wasi_snapshot_preview1" "fd_pread" (func $fimport$13 (param i32 i32 i32 i64 i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_prestat_get" (func $fimport$14 (param i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_prestat_dir_name" (func $fimport$15 (param i32 i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_pwrite" (func $fimport$16 (param i32 i32 i32 i64 i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_read" (func $fimport$17 (param i32 i32 i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_readdir" (func $fimport$18 (param i32 i32 i32 i64 i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_seek" (func $fimport$19 (param i32 i64 i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_sync" (func $fimport$20 (param i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_tell" (func $fimport$21 (param i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_write" (func $fimport$22 (param i32 i32 i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "path_filestat_get" (func $fimport$23 (param i32 i32 i32 i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "path_open" (func $fimport$24 (param i32 i32 i32 i32 i32 i64 i64 i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "path_readlink" (func $fimport$25 (param i32 i32 i32 i32 i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "path_unlink_file" (func $fimport$26 (param i32 i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "poll_oneoff" (func $fimport$27 (param i32 i32 i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "proc_exit" (func $fimport$28 (param i32)))
 (import "wasi_snapshot_preview1" "random_get" (func $fimport$29 (param i32 i32) (result i32)))

For an application that should have none of the optional components

@lewing lewing assigned maraf and unassigned lewing Mar 27, 2024
@lewing
Copy link
Member

lewing commented Mar 27, 2024

@maraf please take a look at the components logic, it was working briefly before the browser/wasm target unification

@lewing lewing added the os-wasi Related to WASI variant of arch-wasm label Mar 27, 2024
@maraf
Copy link
Member

maraf commented Mar 28, 2024

I got away sock_accept by linking with debugger-stub, but all the remaining are still there (even after using the rest of the stubs)

_WasmLinkDependencies
    entrypoint_Wasi.Console.Sample.dll.c
    pinvoke.o
    driver.o
    runtime.o
    main.o
    stubs.o
    synthetic-pthread.o

    libicudata.a
    libicui18n.a
    libicuuc.a
    libmono-component-debugger-stub-static.a
    libmono-component-diagnostics_tracing-stub-static.a
    libmono-component-hot_reload-stub-static.a
    libmono-component-marshal-ilgen-stub-static.a
    libmono-ee-interp.a
    libmono-icall-table.a
    libmono-wasm-nosimd.a
    libmonosgen-2.0.a
    libSystem.Globalization.Native.a
    libSystem.IO.Compression.Native.a
    libSystem.Native.a
    wasm-bundled-timezones.a
    libmono-wasm-nosimd.a

    libc++.a
    libc++abi.a

I'm still getting

(import "wasi_snapshot_preview1" "args_get" (func (;0;) (type 7)))
(import "wasi_snapshot_preview1" "args_sizes_get" (func (;1;) (type 7)))
(import "wasi_snapshot_preview1" "environ_get" (func (;2;) (type 7)))
(import "wasi_snapshot_preview1" "environ_sizes_get" (func (;3;) (type 7)))
(import "wasi_snapshot_preview1" "clock_res_get" (func (;4;) (type 7)))
(import "wasi_snapshot_preview1" "clock_time_get" (func (;5;) (type 48)))
(import "wasi_snapshot_preview1" "fd_advise" (func (;6;) (type 17)))
(import "wasi_snapshot_preview1" "fd_close" (func (;7;) (type 6)))
(import "wasi_snapshot_preview1" "fd_fdstat_get" (func (;8;) (type 7)))
(import "wasi_snapshot_preview1" "fd_fdstat_set_flags" (func (;9;) (type 7)))
(import "wasi_snapshot_preview1" "fd_filestat_get" (func (;10;) (type 7)))
(import "wasi_snapshot_preview1" "fd_filestat_set_size" (func (;11;) (type 15)))
(import "wasi_snapshot_preview1" "fd_pread" (func (;12;) (type 63)))
(import "wasi_snapshot_preview1" "fd_prestat_get" (func (;13;) (type 7)))
(import "wasi_snapshot_preview1" "fd_prestat_dir_name" (func (;14;) (type 8)))
(import "wasi_snapshot_preview1" "fd_read" (func (;15;) (type 9)))
(import "wasi_snapshot_preview1" "fd_readdir" (func (;16;) (type 63)))
(import "wasi_snapshot_preview1" "fd_seek" (func (;17;) (type 50)))
(import "wasi_snapshot_preview1" "fd_tell" (func (;18;) (type 7)))
(import "wasi_snapshot_preview1" "fd_write" (func (;19;) (type 9)))
(import "wasi_snapshot_preview1" "path_filestat_get" (func (;20;) (type 10)))
(import "wasi_snapshot_preview1" "path_open" (func (;21;) (type 64)))
(import "wasi_snapshot_preview1" "path_readlink" (func (;22;) (type 11)))
(import "wasi_snapshot_preview1" "path_unlink_file" (func (;23;) (type 8)))
(import "wasi_snapshot_preview1" "poll_oneoff" (func (;24;) (type 9)))
(import "wasi_snapshot_preview1" "proc_exit" (func (;25;) (type 24)))
(import "wasi_snapshot_preview1" "random_get" (func (;26;) (type 7)))

Manually running wasm-opt --remove-unused-module-elements ... didn't remove any of those

These are imports differ native aot

args_get
args_sizes_get
clock_res_get
fd_advise
fd_filestat_get
fd_filestat_set_size
fd_pread
fd_readdir
fd_tell
path_readlink

They might be use from https://github.com/search?q=repo%3AWebAssembly%2Fwasi-libc+clock_res_get&type=code, I'll track them down to have clear understanding

@pavelsavara
Copy link
Member

I'm still getting

(import "wasi_snapshot_preview1" "args_get" (func (;0;) (type 7)))
(import "wasi_snapshot_preview1" "args_sizes_get" (func (;1;) (type 7)))
(import "wasi_snapshot_preview1" "environ_get" (func (;2;) (type 7)))
...

I'm thinking that's mono corelib -> using dotnet PAL -> is using libc from SDK -> is using those WASM imports ?
Should ILink trim some of that ? If so, would it also mean that the native symbols should be trimmed ?
Or is that just Mono VM -> libc -> WASM imports ?
Or both.

@maraf
Copy link
Member

maraf commented Jul 24, 2024

The socket import is gone by proper mono component selection. Moving tracking down where the rest of the imports comes from to vNext.

@maraf maraf modified the milestones: 9.0.0, 10.0.0 Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-Build-mono os-wasi Related to WASI variant of arch-wasm
Projects
None yet
Development

No branches or pull requests

6 participants