You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, it seems that wasmer compile generates a .wasmu file. According to #3014 (comment), it's already contains compiled machine instructions for the target arch.
From the same thread, it seems implied that using create-exe with a .wasmu should generate a standalone binary with Wasmer runtime embedded on it and the module converted and linked as object. This would seem to align with a old blog post in wasmer.io.
When I run the following instructions, I get an error about a bad magic number.
> wasmer compile hello_world.wat -o hello_world.wasmu # Find hello_world.wat in the Additional details section.
Compiler: cranelift
Target: x86_64-unknown-linux-gnu
✔ File compiled successfully to `hello_world.wasmu`.
> wasmer create-exe hello_world.wasmu -o hello_world
Compiler: cranelift
Target: x86_64-unknown-linux-gnu
Using path `/home/dario/.wasmer/cache/wasmer-linux-amd64/lib/libwasmer-headless.a` as libwasmer path.
error: Compilation error: WebAssembly translation error: Invalid input WebAssembly code at offset 0: magic header not detected: bad magic number - expected=[
0x0,
0x61,
0x73,
0x6d,
] actual=[
0x77,
0x61,
0x73,
0x6d,
]
Does create-exe supports compile output files or should we use another tool to generate a .wasm file - like wat2wasm - to feed it to create-exe?
Thanks!
Additional details
Wasmer version: wasmer 5.0.4
hello-world.wat:
(module;; Import the required WASI functions
(import"wasi_snapshot_preview1""fd_write" (func$fd_write (parami32i32i32i32) (resulti32)))
;; Define a buffer to store the message
(memory (export"memory") 1)
(data (i32.const8) "Hello, World!\n")
;; Define the _start function
(func$main (export"_start")
;; Setup the iovec array
(i32.store (i32.const0) (i32.const8)) ;; pointer to the message
(i32.store (i32.const4) (i32.const14)) ;; length of the message;; Call fd_write
(call$fd_write
(i32.const1) ;; file_descriptor - 1 for stdout
(i32.const0) ;; *iovs - pointer to the iovec array
(i32.const1) ;; iovs_len - number of iovec entries
(i32.const20) ;; nwritten - where to store the number of bytes written
)
drop;; Discard the result
)
)
The text was updated successfully, but these errors were encountered:
Update: I converted the .wat file using wat2wasm and create-exe didn't complain but running the binary failed with a reference to wasmer-universal:
> wasmer create-exe hello_world.wasm -o hello_world
Compiler: cranelift
Target: x86_64-unknown-linux-gnu
Using path `/home/dario/.wasmer/cache/wasmer-linux-amd64/lib/libwasmer-headless.a` as libwasmer path.
✔ Native executable compiled successfully to `hello_world`.
> ./hello_world
Failed to create module from atom "hello_world"
Error len: `65`
incompatible binary: The provided bytes are not wasmer-universal
This makes sense if create-exe only works with WASM Universal binaries.
Summary
By default, it seems that
wasmer compile
generates a.wasmu
file. According to #3014 (comment), it's already contains compiled machine instructions for the target arch.From the same thread, it seems implied that using
create-exe
with a.wasmu
should generate a standalone binary with Wasmer runtime embedded on it and the module converted and linked as object. This would seem to align with a old blog post in wasmer.io.When I run the following instructions, I get an error about a bad magic number.
Does
create-exe
supportscompile
output files or should we use another tool to generate a.wasm
file - likewat2wasm
- to feed it tocreate-exe
?Thanks!
Additional details
Wasmer version:
wasmer 5.0.4
hello-world.wat
:The text was updated successfully, but these errors were encountered: