Description
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