github.com/AR1011/wazero@v1.0.5/site/content/specs.md (about) 1 +++ 2 title = "Specifications" 3 +++ 4 5 wazero understands that while no-one desired to create confusion, confusion 6 exists both in what is a standard and what in practice is in fact a standard 7 feature. To help with this, we created some guidance both on the status quo 8 of WebAssembly portability and what we support. 9 10 The WebAssembly Core Specification is the only specification relevant to 11 wazero, governed by a standards body. Release [1.0][1] is a Web Standard (REC). 12 Release [2.0][2] is a Working Draft (WD), so not yet a Web Standard. 13 14 Many compilers implement system calls using the WebAssembly System Interface, 15 [WASI][5]. WASI is a WebAssembly community [subgroup][3], but has not published 16 any working drafts as a result of their work. WASI's last stable point was 17 [wasi_snapshot_preview1][4], tagged at the end of 2020. 18 19 While this seems scary, the confusion caused by pre-standard features is not as 20 bad as it sounds. The WebAssembly ecosystem is generally responsive regardless 21 of where things are written down and wazero provides tools, such as built-in 22 support for WASI, to reduce pain. 23 24 The goal of this section isn't to promote a W3C recommendation exclusive 25 approach, rather to help you understand common language around portable 26 features and which of those wazero supports at the moment. While we consider 27 features formalized through W3C recommendation status mandatory, we actively 28 pursue pre-standard features as well interop with commonly used infrastructure 29 such as AssemblyScript. 30 31 In summary, we hope this section can guide you in terms of what wazero supports 32 as well as how to classify a request for a feature we don't yet support. 33 34 ### WebAssembly Core {#core} 35 36 wazero conforms with tests defined alongside WebAssembly Core 37 Specification [1.0][1] and [2.0][14]. 38 39 By default, the runtime configuration enables features in WebAssembly Core 40 Specification, despite it not yet being a Web Standard (REC). You can select 41 version 1.0 like so: 42 43 ```go 44 rConfig = wazero.NewRuntimeConfig().WithCoreFeatures(api.CoreFeaturesV1) 45 ``` 46 47 One current limitation of wazero is that it doesn't implement the Text 48 Format, e.g. compiling `.wat` files. Users can work around this using tools such as `wat2wasm` to 49 compile the text format into the binary format. In practice, the text format is 50 too low level for most users, so delays here have limited impact. 51 52 #### Post 2.0 Features 53 54 Features regardless of W3C release are inventoried in the [Proposals][10]. 55 repository. wazero implements [Finished Proposals][11] based on user demand, 56 using [wazero.RuntimeConfig][7] feature flags. As of late 2022, all finished 57 proposals are included in [2.0][14] Working Draft. 58 59 Features not yet assigned to a W3C release are not reliable. Encourage the 60 [WebAssembly community][12] to formalize features you rely on, so that they 61 become assigned to a release, and reach the W3C recommendation (REC) phase. 62 63 ### WebAssembly System Interface (WASI) {#wasi} 64 65 Many compilers implement system calls using the WebAssembly System Interface, 66 [WASI][5]. WASI is a WebAssembly community [subgroup][3], but has not published 67 any working drafts as a result of their work. WASI's last stable point was 68 [wasi_snapshot_preview1][4], tagged at the end of 2020. 69 70 Some functions in this tag are used in practice while some others are not known 71 to be used at all. Further confusion exists because some compilers, like 72 GrainLang, import functions not used. Finally, some functions were added and 73 removed after the git tag. For example, [`proc_raise`][13] was removed and 74 [`sock_accept`][15] added. 75 76 For all of these reasons, wazero will not implement all WASI features, just to 77 complete the below chart. If you desire something not yet implemented, please 78 [raise an issue](https://github.com/AR1011/wazero/issues/new) and include 79 your use case (ex which language you are using to compile, a.k.a. target Wasm). 80 81 Notes: 82 83 - AssemblyScript has its own ABI which can optionally use [wasi-shim][17] 84 - C (via clang) supports the maximum WASI functions due to [wasi-libc][16] 85 - Rust supports WASI via its [wasm32-wasi][18] target. 86 87 <details><summary>Click to see the full list of supported WASI functions</summary> 88 <p> 89 90 | Function | Status | Known Usage | 91 | :---------------------- | :----: | --------------: | 92 | args_get | ✅ | TinyGo | 93 | args_sizes_get | ✅ | TinyGo | 94 | environ_get | ✅ | TinyGo | 95 | environ_sizes_get | ✅ | TinyGo | 96 | clock_res_get | ✅ | | 97 | clock_time_get | ✅ | TinyGo | 98 | fd_advise | 👷 | | 99 | fd_allocate | ✅ | Rust | 100 | fd_close | ✅ | TinyGo | 101 | fd_datasync | ✅ | Rust | 102 | fd_fdstat_get | ✅ | TinyGo | 103 | fd_fdstat_set_flags | ✅ | Rust | 104 | fd_fdstat_set_rights | 💀 | | 105 | fd_filestat_get | ✅ | Zig | 106 | fd_filestat_set_size | ✅ | Rust,Zig | 107 | fd_filestat_set_times | ✅ | Rust,Zig | 108 | fd_pread | ✅ | Zig | 109 | fd_prestat_get | ✅ | Rust,TinyGo,Zig | 110 | fd_prestat_dir_name | ✅ | Rust,TinyGo,Zig | 111 | fd_pwrite | ✅ | Rust,Zig | 112 | fd_read | ✅ | Rust,TinyGo,Zig | 113 | fd_readdir | ✅ | Rust,Zig | 114 | fd_renumber | ✅ | libc | 115 | fd_seek | ✅ | TinyGo | 116 | fd_sync | ✅ | Go | 117 | fd_tell | ✅ | Rust | 118 | fd_write | ✅ | Rust,TinyGo,Zig | 119 | path_create_directory | ✅ | Rust,TinyGo,Zig | 120 | path_filestat_get | ✅ | Rust,TinyGo,Zig | 121 | path_filestat_set_times | ✅ | Rust,libc | 122 | path_link | ✅ | Rust,Zig | 123 | path_open | ✅ | Rust,TinyGo,Zig | 124 | path_readlink | ✅ | Rust,Zig | 125 | path_remove_directory | ✅ | Rust,TinyGo,Zig | 126 | path_rename | ✅ | Rust,TinyGo,Zig | 127 | path_symlink | ✅ | Rust,Zig | 128 | path_unlink_file | ✅ | Rust,TinyGo,Zig | 129 | poll_oneoff | ✅ | Rust,TinyGo,Zig | 130 | proc_exit | ✅ | Rust,TinyGo,Zig | 131 | proc_raise | 💀 | | 132 | sched_yield | ✅ | Rust | 133 | random_get | ✅ | Rust,TinyGo,Zig | 134 | sock_accept | ✅ | Rust,Zig | 135 | sock_recv | ✅ | Rust,Zig | 136 | sock_send | ✅ | Rust,Zig | 137 | sock_shutdown | ✅ | Rust,Zig | 138 139 Note: 💀 means the function was later removed from WASI. 140 141 </p> 142 </details> 143 144 [1]: https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/ 145 [2]: https://www.w3.org/TR/2022/WD-wasm-core-2-20220419/ 146 [3]: https://github.com/WebAssembly/meetings/blob/main/process/subgroups.md 147 [4]: https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md 148 [5]: https://github.com/WebAssembly/WASI 149 [6]: https://github.com/WebAssembly/spec/tree/wg-1.0/test/core 150 [7]: https://pkg.go.dev/github.com/AR1011/wazero#RuntimeConfig 151 [9]: https://github.com/AR1011/wazero/issues/59 152 [10]: https://github.com/WebAssembly/proposals 153 [11]: https://github.com/WebAssembly/proposals/blob/main/finished-proposals.md 154 [12]: https://www.w3.org/community/webassembly/ 155 [13]: https://github.com/WebAssembly/WASI/pull/136 156 [14]: https://github.com/WebAssembly/spec/tree/d39195773112a22b245ffbe864bab6d1182ccb06/test/core 157 [15]: https://github.com/WebAssembly/WASI/pull/458 158 [16]: https://github.com/WebAssembly/wasi-libc 159 [17]: https://github.com/AssemblyScript/wasi-shim 160 [18]: https://github.com/rust-lang/rust/tree/1.68.0/library/std/src/sys/wasi