Project Title
Extend sub-command of WasmEdge CLI tool
Motivation
WasmEdge command line tool currently supports only the sub-command about run and compile the WASM files. As a WebAssembly runtime tool, it's welcome to have more functions about verifying the WASM files. In this mentorship, we will plan and implement the functionality of WasmEdge command line tool about parsing, validating, and instantiating WASM files, which developers can do with WasmEdge C API.
Expected Outcome
- Extend the sub-commands for WasmEdge CLI tool to include parse, validate and instantiate commands.
- Provide the test cases to verify the implementation.
- Use WasmEdge C API to trigger the WasmEdge CLI tools for further test cases.
Details
This project extends the unified WasmEdge CLI by ensuring strict state isolation across pipeline phases. The implementation focuses on four core areas:
-
Architecture & Routing: Register three new sub-commands (parse, validate, instantiate) in lib/driver/uniTool.cpp and route them to dedicated handler files (e.g., validateTool.cpp, parseTool.cpp).
-
Stateful Option Parsing: Refactor include/driver/tool.h using a "Partial Registration" strategy. Flag scopes will be strictly isolated so each phase only accepts its required arguments (e.g., parse only accepts input files and WASM proposals, while instantiate safely adds host configs like --dir and --env).
-
Pipeline Workflows:
wasmedge parse: Extract and print the module's AST sections (Type, Import, Function, Memory, Global, Export) to match the industry-standard wasm-objdump -x format.
Output format
Type[N]:
- type[index] (param_types) -> return_type
Import[N]:
- kind[index] sig=type_idx <- module.name
Function[N]:
- func[index] sig=type_idx <name>
Export[N]:
- kind[index] <name> -> "export_name"
-
wasmedge validate: Generate the AST from the binary and pass it through the validation engine to strictly enforce WebAssembly specification compliance.
-
wasmedge instantiate: Initialize the runtime with WASI host modules, perform the full loading/validation/instantiation pipeline, and exit successfully without executing code to confirm all import dependencies and links are satisfied.
-
Integration Testing: Programmatically verify the new sub-commands via the public WasmEdge C API. Add comprehensive test coverage for scenarios including malformed binaries, validation logic failures, successful parsing, and instantiation linker errors.
Milestones
- Week 1: Option Struct Refactoring & Analysis
- Week 2: CLI Routing & Setup
- Week 3: Implement
validate Command
- Weeks 4-5: Implement
parse Command
- Week 6: Implement
instantiate Command & Mid-Term PR
- Week 7: Mid-Term Evaluation
- Weeks 8-9: Comprehensive Testing
- Week 10: Code Polish & Testing Cleanup
- Week 11: Official Documentation
- Week 12: Review Cycle, Final PR, & Final Evaluation
Appendix
Original Issue: #4513
Project Title
Extend sub-command of WasmEdge CLI tool
Motivation
WasmEdge command line tool currently supports only the sub-command about run and compile the WASM files. As a WebAssembly runtime tool, it's welcome to have more functions about verifying the WASM files. In this mentorship, we will plan and implement the functionality of WasmEdge command line tool about parsing, validating, and instantiating WASM files, which developers can do with WasmEdge C API.
Expected Outcome
Details
This project extends the unified WasmEdge CLI by ensuring strict state isolation across pipeline phases. The implementation focuses on four core areas:
Architecture & Routing: Register three new sub-commands (
parse,validate,instantiate) inlib/driver/uniTool.cppand route them to dedicated handler files (e.g.,validateTool.cpp,parseTool.cpp).Stateful Option Parsing: Refactor
include/driver/tool.husing a "Partial Registration" strategy. Flag scopes will be strictly isolated so each phase only accepts its required arguments (e.g.,parseonly accepts input files and WASM proposals, whileinstantiatesafely adds host configs like--dirand--env).Pipeline Workflows:
wasmedge parse: Extract and print the module's AST sections (Type, Import, Function, Memory, Global, Export) to match the industry-standardwasm-objdump -xformat.Output format
wasmedge validate: Generate the AST from the binary and pass it through the validation engine to strictly enforce WebAssembly specification compliance.wasmedge instantiate: Initialize the runtime with WASI host modules, perform the full loading/validation/instantiation pipeline, and exit successfully without executing code to confirm all import dependencies and links are satisfied.Integration Testing: Programmatically verify the new sub-commands via the public WasmEdge C API. Add comprehensive test coverage for scenarios including malformed binaries, validation logic failures, successful parsing, and instantiation linker errors.
Milestones
include/driver/tool.hto map existing flags strictly to the appropriate new sub-commands.lib/driver/uniTool.cppto register the newparse,validate, andinstantiatesub-commands and create their corresponding routing stubs.validateCommandparseCommandwasm-objdump -xformat.instantiateCommand & Mid-Term PRparse,validate, andinstantiatecommands.uniTool.cppto ensurewasmedge --helpprints a clean, consistent summary matching existing commands.validate.md,parse.mdetc) in https://github.com/WasmEdge/docs.Appendix
Original Issue: #4513