-
Couldn't load subscription status.
- Fork 13.9k
Description
The code:
fn main() {}
#[export_name="test"]
pub fn test() {}would produce the following Wasm assembly on Rust 1.66.1 compiled with cargo build --target="wasm32-wasi":
;; ... truncated ...
(func $test.command_export (type 0)
call $__wasm_call_ctors ;; <- WASI initialized here
;; ... truncated ...
(export "test" (func $test.command_export))
(export "main" (func $main.command_export))
;; ... truncated ...On 1.67.0 it produces this one:
;; ... truncated ...
(func $test (type 0)
return)
;; ... truncated ...
(export "test" (func $test))
(export "_start" (func $_start))
;; ... truncated ...Notice that the call to the $__wasm_call_ctors function is missing in the exported test. This means that when entering the Wasm instance through the exported function, it will not have a correctly set up WASI environment and calls to open files or look up environment variables will fail. The _start function in both versions calls $__wasm_call_ctors and works correctly.
I'm not sure what commit broke this. The only PR that is related to this seems to be this one #105405.
EDIT: Or more likely, this one #105395