목차

, , , ,

wasmtime

WebAssembly, WASI, Component Model 코드를 로컬에서 실행, 사전 컴파일, 검사할 수 있는 Wasmtime CLI.

Summary

Usage

wasmtime [OPTIONS] <WASM-OR-SUBCOMMAND> [ARGS...]
wasmtime run [OPTIONS] module.wasm [ARGS...]
wasmtime serve [OPTIONS] component.wasm
wasmtime compile [OPTIONS] module.wasm

Options

Common Behavior

Important Subcommands

Common Run-Specific Options

Examples

Basic Execution

# 기본 run 동작
wasmtime hello.wasm
 
# 텍스트 형식(.wat)도 직접 실행
wasmtime hello.wat
 
# guest 프로그램 인수 전달
wasmtime app.wasm --mode prod --port 8080

WASI Options Placement

Wasmtime 자체 옵션은 wasm 파일 앞에 둬야 한다. wasmtime foo.wasm –dir .–dir . 을 Wasmtime이 아니라 guest 프로그램 인수로 넘긴다.
# 현재 디렉터리를 guest에 mount
wasmtime --dir . app.wasm
 
# 환경 변수 전달
wasmtime --env APP_ENV=dev app.wasm

Invoke Specific Export

# core wasm module의 특정 export 실행
wasmtime run --invoke initialize init.wasm
 
# 정수 인수를 받는 export 실행
wasmtime run --invoke add add.wasm 1 2
 
# component export 실행 시 WAVE 문법 사용
wasmtime run --invoke 'initialize("hello")' component.wasm
공식 문서는 –invoke 를 통한 일부 CLI 인수 구문이 아직 unstable 하며 향후 바뀔 수 있다고 안내한다.

HTTP Component

# wasi:http/proxy world 기반 component 실행
wasmtime serve proxy.wasm
 
# listen address 지정
wasmtime serve --addr=0.0.0.0:8081 proxy.wasm

AOT Compile and Inspect

# AOT compile
wasmtime compile app.wasm
 
# 생성된 .cwasm 실행
wasmtime app.cwasm
 
# shell completion 생성
wasmtime completion zsh
 
# compiled wasm의 native code 확인
wasmtime objdump app.cwasm

Config

Troubleshooting

Compatibility

Help

+ wasmtime --help

로컬 환경에 wasmtime binary가 없어 실제 ''wasmtime --help'' 출력은 수집하지 못했다.
 
참고:
  * https://wasmtime.dev/
  * https://docs.wasmtime.dev/cli-options.html

+

See Also

History