-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Comments
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsDescriptionWasm 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 StepsBuild mono example: https://github.com/silesmo/wasm-unmanaged-callers-bug Expected behaviorImports 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] } Actual behaviorImports built with mono: Regression?No response Known WorkaroundsNo response ConfigurationNo response Other informationNo response
|
These are all the imports that shouldn't be there: |
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsDescriptionWasm 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 StepsBuild mono example: https://github.com/silesmo/wasm-unmanaged-callers-bug Expected behaviorImports 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] } Actual behaviorImports built with mono: Regression?No response Known WorkaroundsNo response ConfigurationNo response Other informationNo response
|
we probably need to run something like |
I haven't had time to look into this directly but are you running The NativeAOT build operates differently. |
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
For an application that should have none of the optional components |
@maraf please take a look at the components logic, it was working briefly before the browser/wasm target unification |
I got away
I'm still getting
Manually running These are imports differ native aot
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 |
I'm thinking that's mono corelib -> using dotnet PAL -> is using libc from SDK -> is using those WASM imports ? |
The socket import is gone by proper mono component selection. Moving tracking down where the rest of the imports comes from to vNext. |
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
The text was updated successfully, but these errors were encountered: