The CLI subcommand create-obj supports creating object files from wasm files. It'd be useful if it could also support compiling directly from wat files.
The use case for this is that when adding wasmer support to compiler explorer, I used create-obj to build a object file that could late be disassembled and shown to the user. However since create-obj doesn't support wat files I had to do some slightly hacky things and run it through wat2wasm before compiling.
This works, but is not something I'd like to upstream, so before doing that I'd like to ask if it would be possible to support it in create-obj first.
Proposed solution
Ideally I would be able to pass the text file instead of a wasm module as part of the input file to create-obj. We could detect if the file is a binary module by checking for the WASM magic header, or fall back to parsing a wat file.
Alternatively adding a flag that would interpret the input file as a wat file would also work.
Alternatives
I don't really need it for create-obj to support wat files directly. I only need a disassembly view of a compiled wat file.
I don't think wasmer has a disassembly CLI flag (at least I couldn't find one), but that would also work.
Additionally I've also tried to use the compile subcommand, but the output of that doesn't seem to be a valid ELF file that I could disassemble.
Finally, I can also upstream my current implementation using wat2wasm, but I'd prefer to not do that unless there is no better solution.
CC: @syrusakbary since you've previously asked about wasmer support in CE.
👋 Hey
Motivation
The CLI subcommand
create-obj
supports creating object files fromwasm
files. It'd be useful if it could also support compiling directly fromwat
files.The use case for this is that when adding wasmer support to compiler explorer, I used
create-obj
to build a object file that could late be disassembled and shown to the user. However sincecreate-obj
doesn't supportwat
files I had to do some slightly hacky things and run it throughwat2wasm
before compiling.This works, but is not something I'd like to upstream, so before doing that I'd like to ask if it would be possible to support it in
create-obj
first.Proposed solution
Ideally I would be able to pass the text file instead of a wasm module as part of the input file to
create-obj
. We could detect if the file is a binary module by checking for the WASM magic header, or fall back to parsing a wat file.Alternatively adding a flag that would interpret the input file as a wat file would also work.
Alternatives
I don't really need it for
create-obj
to support wat files directly. I only need a disassembly view of a compiled wat file. I don't think wasmer has a disassembly CLI flag (at least I couldn't find one), but that would also work.Additionally I've also tried to use the
compile
subcommand, but the output of that doesn't seem to be a valid ELF file that I could disassemble.Finally, I can also upstream my current implementation using
wat2wasm
, but I'd prefer to not do that unless there is no better solution.CC: @syrusakbary since you've previously asked about wasmer support in CE.