I used clang --target=wasm32-unknown-wasi ... to compile a Hello World C program into WebAssembly. Everything goes fine, and the .wasm file can run correctly in runtime like wasmer.
But when I check the .wasm file(in .wat format), I found some i64 instructions like:
(func $__lseek (type $t1) (param $p0 i32) (param $p1 i64) (param $p2 i32) (result i64)
(local $l3 i32)
global.get $g0
i32.const 16
i32.sub
local.tee $l3
global.set $g0
block $B0
block $B1
local.get $p0
local.get $p1
local.get $p2
i32.const 255
i32.and
local.get $l3
i32.const 8
i32.add
call $__wasi_fd_seek
local.tee $p0
i32.eqz
br_if $B1
i32.const 0
i32.const 70
local.get $p0
local.get $p0
i32.const 76
i32.eq
select
i32.store offset=3696
i64.const -1
local.set $p1
br $B0
end
local.get $l3
i64.load offset=8
local.set $p1
end
local.get $l3
i32.const 16
i32.add
global.set $g0
local.get $p1)
It looks strange: why would clang emit i64 instructions when targeting wasm32?
According to the discussions in https://github.com/WebAssembly/wasi-libc/issues/158 , I think it's probably because some wasi APIs which includes i64 instructions were introduced during link time. Am I right?
Thanks for your attention!