{"id":13441175,"url":"https://github.com/WebAssembly/wabt","last_synced_at":"2025-03-20T11:37:27.016Z","repository":{"id":37390748,"uuid":"42467830","full_name":"WebAssembly/wabt","owner":"WebAssembly","description":"The WebAssembly Binary Toolkit","archived":false,"fork":false,"pushed_at":"2024-10-24T19:58:41.000Z","size":25187,"stargazers_count":6831,"open_issues_count":152,"forks_count":696,"subscribers_count":155,"default_branch":"main","last_synced_at":"2024-10-26T06:47:28.577Z","etag":null,"topics":["webassembly"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WebAssembly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"Contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-14T18:14:23.000Z","updated_at":"2024-10-26T02:43:15.000Z","dependencies_parsed_at":"2024-05-20T21:42:23.636Z","dependency_job_id":"1c4b2f89-870b-4129-8102-008f5749b797","html_url":"https://github.com/WebAssembly/wabt","commit_stats":{"total_commits":2386,"total_committers":148,"mean_commits":16.12162162162162,"dds":0.5762782900251466,"last_synced_commit":"4beb52501f863f1cbd92e0ce4879f04f473935b5"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebAssembly%2Fwabt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebAssembly%2Fwabt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebAssembly%2Fwabt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebAssembly%2Fwabt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebAssembly","download_url":"https://codeload.github.com/WebAssembly/wabt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221759943,"owners_count":16876322,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["webassembly"],"created_at":"2024-07-31T03:01:30.766Z","updated_at":"2025-03-20T11:37:26.951Z","avatar_url":"https://github.com/WebAssembly.png","language":"C++","readme":"[![Github CI Status](https://github.com/WebAssembly/wabt/workflows/CI/badge.svg)](https://github.com/WebAssembly/wabt)\n\n# WABT: The WebAssembly Binary Toolkit\n\nWABT (we pronounce it \"wabbit\") is a suite of tools for WebAssembly, including:\n\n - [**wat2wasm**](https://webassembly.github.io/wabt/doc/wat2wasm.1.html): translate from [WebAssembly text format](https://webassembly.github.io/spec/core/text/index.html) to the [WebAssembly binary format](https://webassembly.github.io/spec/core/binary/index.html)\n - [**wasm2wat**](https://webassembly.github.io/wabt/doc/wasm2wat.1.html): the inverse of wat2wasm, translate from the binary format back to the text format (also known as a .wat)\n - [**wasm-objdump**](https://webassembly.github.io/wabt/doc/wasm-objdump.1.html): print information about a wasm binary. Similiar to objdump.\n - [**wasm-interp**](https://webassembly.github.io/wabt/doc/wasm-interp.1.html): decode and run a WebAssembly binary file using a stack-based interpreter\n - [**wasm-decompile**](https://webassembly.github.io/wabt/doc/wasm-decompile.1.html): decompile a wasm binary into readable C-like syntax.\n - [**wat-desugar**](https://webassembly.github.io/wabt/doc/wat-desugar.1.html): parse .wat text form as supported by the spec interpreter (s-expressions, flat syntax, or mixed) and print \"canonical\" flat format\n - [**wasm2c**](https://webassembly.github.io/wabt/doc/wasm2c.1.html): convert a WebAssembly binary file to a C source and header\n - [**wasm-strip**](https://webassembly.github.io/wabt/doc/wasm-strip.1.html): remove sections of a WebAssembly binary file\n - [**wasm-validate**](https://webassembly.github.io/wabt/doc/wasm-validate.1.html): validate a file in the WebAssembly binary format\n - [**wast2json**](https://webassembly.github.io/wabt/doc/wast2json.1.html): convert a file in the wasm spec test format to a JSON file and associated wasm binary files\n - [**wasm-stats**](https://webassembly.github.io/wabt/doc/wasm-stats.1.html): output stats for a module\n - [**spectest-interp**](https://webassembly.github.io/wabt/doc/spectest-interp.1.html): read a Spectest JSON file, and run its tests in the interpreter\n\nThese tools are intended for use in (or for development of) toolchains or other\nsystems that want to manipulate WebAssembly files. Unlike the WebAssembly spec\ninterpreter (which is written to be as simple, declarative and \"speccy\" as\npossible), they are written in C/C++ and designed for easier integration into\nother systems. Unlike [Binaryen](https://github.com/WebAssembly/binaryen) these\ntools do not aim to provide an optimization platform or a higher-level compiler\ntarget; instead they aim for full fidelity and compliance with the spec (e.g.\n1:1 round-trips with no changes to instructions).\n\n## Online Demos\n\nWabt has been compiled to JavaScript via emscripten. Some of the functionality is available in the following demos:\n\n- [index](https://webassembly.github.io/wabt/demo/)\n- [wat2wasm](https://webassembly.github.io/wabt/demo/wat2wasm/)\n- [wasm2wat](https://webassembly.github.io/wabt/demo/wasm2wat/)\n\n## Supported Proposals\n\n* Proposal: Name and link to the WebAssembly proposal repo\n* flag: Flag to pass to the tool to enable/disable support for the feature\n* default: Whether the feature is enabled by default\n* binary: Whether wabt can read/write the binary format\n* text: Whether wabt can read/write the text format\n* validate: Whether wabt can validate the syntax\n* interpret: Whether wabt can execute these operations in `wasm-interp` or `spectest-interp`\n* wasm2c: Whether wasm2c supports these operations\n\n| Proposal   | flag | default | binary | text | validate | interpret | wasm2c |\n| --------------------- | --------------------------- | - | - | - | - | - | - |\n| [exception handling][]| `--enable-exceptions`       |   | ✓ | ✓ | ✓ | ✓ | ✓ |\n| [mutable globals][]   | `--disable-mutable-globals` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |\n| [nontrapping float-to-int conversions][] | `--disable-saturating-float-to-int` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |\n| [sign extension][]    | `--disable-sign-extension`  | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |\n| [simd][]              | `--disable-simd`            | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |\n| [threads][]           | `--enable-threads`          |   | ✓ | ✓ | ✓ | ✓ |   |\n| [multi-value][]       | `--disable-multi-value`     | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |\n| [tail-call][]         | `--enable-tail-call`        |   | ✓ | ✓ | ✓ | ✓ | ✓ |\n| [bulk memory][]       | `--disable-bulk-memory`     | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |\n| [reference types][]   | `--disable-reference-types` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |\n| [annotations][]       | `--enable-annotations`      |   |   | ✓ |   |   |   |\n| [memory64][]          | `--enable-memory64`         |   | ✓ | ✓ | ✓ | ✓ | ✓ |\n| [multi-memory][]      | `--enable-multi-memory`     |   | ✓ | ✓ | ✓ | ✓ | ✓ |\n| [extended-const][]    | `--enable-extended-const`   |   | ✓ | ✓ | ✓ | ✓ | ✓ |\n| [relaxed-simd][]      | `--enable-relaxed-simd`     |   | ✓ | ✓ | ✓ | ✓ |   |\n| [custom-page-sizes][] | `--enable-custom-page-sizes`|   | ✓ | ✓ | ✓ | ✓ | ✓ |\n\n[exception handling]: https://github.com/WebAssembly/exception-handling\n[mutable globals]: https://github.com/WebAssembly/mutable-global\n[nontrapping float-to-int conversions]: https://github.com/WebAssembly/nontrapping-float-to-int-conversions\n[sign extension]: https://github.com/WebAssembly/sign-extension-ops\n[simd]: https://github.com/WebAssembly/simd\n[threads]: https://github.com/WebAssembly/threads\n[multi-value]: https://github.com/WebAssembly/multi-value\n[tail-call]: https://github.com/WebAssembly/tail-call\n[bulk memory]: https://github.com/WebAssembly/bulk-memory-operations\n[reference types]: https://github.com/WebAssembly/reference-types\n[annotations]: https://github.com/WebAssembly/annotations\n[memory64]: https://github.com/WebAssembly/memory64\n[multi-memory]: https://github.com/WebAssembly/multi-memory\n[extended-const]: https://github.com/WebAssembly/extended-const\n[relaxed-simd]: https://github.com/WebAssembly/relaxed-simd\n[custom-page-sizes]: https://github.com/WebAssembly/custom-page-sizes\n\n## Cloning\n\nClone as normal, but don't forget to get the submodules as well:\n\n```console\n$ git clone --recursive https://github.com/WebAssembly/wabt\n$ cd wabt\n$ git submodule update --init\n```\n\nThis will fetch the testsuite and gtest repos, which are needed for some tests.\n\n## Building using CMake directly (Linux and macOS)\n\nYou'll need [CMake](https://cmake.org). You can then run CMake, the normal way:\n\n```console\n$ mkdir build\n$ cd build\n$ cmake ..\n$ cmake --build .\n```\n\nThis will produce build files using CMake's default build generator. Read the\nCMake documentation for more information.\n\n**NOTE**: You must create a separate directory for the build artifacts (e.g.\n`build` above).  Running `cmake` from the repo root directory will not work\nsince the build produces an executable called `wasm2c` which conflicts with the\n`wasm2c` directory.\n\n## Building using the top-level `Makefile` (Linux and macOS)\n\n**NOTE**: Under the hood, this uses `make` to run CMake, which then calls\n`ninja` to perform that actual build.  On some systems (typically macOS), this\ndoesn't build properly. If you see these errors, you can build using CMake\ndirectly as described above.\n\nYou'll need [CMake](https://cmake.org) and [Ninja](https://ninja-build.org). If\nyou just run `make`, it will run CMake for you, and put the result in\n`out/clang/Debug/` by default:\n\n\u003e Note: If you are on macOS, you will need to use CMake version 3.2 or higher\n\n```console\n$ make\n```\n\nThis will build the default version of the tools: a debug build using the Clang\ncompiler.\n\nThere are many make targets available for other configurations as well. They\nare generated from every combination of a compiler, build type and\nconfiguration.\n\n - compilers: `gcc`, `clang`, `gcc-i686`, `emscripten`\n - build types: `debug`, `release`\n - configurations: empty, `asan`, `msan`, `lsan`, `ubsan`, `fuzz`, `no-tests`\n\nThey are combined with dashes, for example:\n\n```console\n$ make clang-debug\n$ make gcc-i686-release\n$ make clang-debug-lsan\n$ make gcc-debug-no-tests\n```\n\n## Building (Windows)\n\nYou'll need [CMake](https://cmake.org). You'll also need\n[Visual Studio](https://www.visualstudio.com/) (2015 or newer) or\n[MinGW](https://www.mingw-w64.org/).\n\n_Note: Visual Studio 2017 and later come with CMake (and the Ninja build system)\nout of the box, and should be on your PATH if you open a Developer Command prompt.\nSee \u003chttps://aka.ms/cmake\u003e for more details._\n\nYou can run CMake from the command prompt, or use the CMake GUI tool. See\n[Running CMake](https://cmake.org/runningcmake/) for more information.\n\nWhen running from the commandline, create a new directory for the build\nartifacts, then run cmake from this directory:\n\n```console\n\u003e cd [build dir]\n\u003e cmake [wabt project root] -DCMAKE_BUILD_TYPE=[config] -DCMAKE_INSTALL_PREFIX=[install directory] -G [generator]\n```\n\nThe `[config]` parameter should be a CMake build type, typically `DEBUG` or `RELEASE`.\n\nThe `[generator]` parameter should be the type of project you want to generate,\nfor example `\"Visual Studio 14 2015\"`. You can see the list of available\ngenerators by running `cmake --help`.\n\nTo build the project, you can use Visual Studio, or you can tell CMake to do it:\n\n```console\n\u003e cmake --build [wabt project root] --config [config] --target install\n```\n\nThis will build and install to the installation directory you provided above.\n\nSo, for example, if you want to build the debug configuration on Visual Studio 2015:\n\n```console\n\u003e mkdir build\n\u003e cd build\n\u003e cmake .. -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_INSTALL_PREFIX=..\\ -G \"Visual Studio 14 2015\"\n\u003e cmake --build . --config DEBUG --target install\n```\n\n## Adding new keywords to the lexer\n\nIf you want to add new keywords, you'll need to install\n[gperf](https://www.gnu.org/software/gperf/). Before you upload your PR, please\nrun `make update-gperf` to update the prebuilt C++ sources in `src/prebuilt/`.\n\n## Running wat2wasm\n\nSome examples:\n\n```sh\n# parse test.wat and write to .wasm binary file with the same name\n$ bin/wat2wasm test.wat\n\n# parse test.wat and write to binary file test.wasm\n$ bin/wat2wasm test.wat -o test.wasm\n\n# parse spec-test.wast, and write verbose output to stdout (including the\n# meaning of every byte)\n$ bin/wat2wasm spec-test.wast -v\n```\n\nYou can use `--help` to get additional help:\n\n```console\n$ bin/wat2wasm --help\n```\n\nOr try the [online demo](https://webassembly.github.io/wabt/demo/wat2wasm/).\n\n## Running wasm2wat\n\nSome examples:\n\n```sh\n# parse binary file test.wasm and write text file test.wat\n$ bin/wasm2wat test.wasm -o test.wat\n\n# parse test.wasm and write test.wat\n$ bin/wasm2wat test.wasm -o test.wat\n```\n\nYou can use `--help` to get additional help:\n\n```console\n$ bin/wasm2wat --help\n```\n\nOr try the [online demo](https://webassembly.github.io/wabt/demo/wasm2wat/).\n\n## Running wasm-interp\n\nSome examples:\n\n```sh\n# parse binary file test.wasm, and type-check it\n$ bin/wasm-interp test.wasm\n\n# parse test.wasm and run all its exported functions\n$ bin/wasm-interp test.wasm --run-all-exports\n\n# parse test.wasm, run the exported functions and trace the output\n$ bin/wasm-interp test.wasm --run-all-exports --trace\n\n# parse test.json and run the spec tests\n$ bin/wasm-interp test.json --spec\n\n# parse test.wasm and run all its exported functions, setting the value stack\n# size to 100 elements\n$ bin/wasm-interp test.wasm -V 100 --run-all-exports\n```\n\nYou can use `--help` to get additional help:\n\n```console\n$ bin/wasm-interp --help\n```\n\n## Running wast2json\n\nSee [wast2json.md](docs/wast2json.md).\n\n## Running wasm-decompile\n\nFor example:\n\n```sh\n# parse binary file test.wasm and write text file test.dcmp\n$ bin/wasm-decompile test.wasm -o test.dcmp\n```\n\nYou can use `--help` to get additional help:\n\n```console\n$ bin/wasm-decompile --help\n```\n\nSee [decompiler.md](docs/decompiler.md) for more information on the language\nbeing generated.\n\n## Running wasm2c\n\nSee [wasm2c.md](wasm2c/README.md)\n\n## Running the test suite\n\nSee [test/README.md](test/README.md).\n\n## Sanitizers\n\nTo build with the [LLVM sanitizers](https://github.com/google/sanitizers),\nappend the sanitizer name to the target:\n\n```console\n$ make clang-debug-asan\n$ make clang-debug-msan\n$ make clang-debug-lsan\n$ make clang-debug-ubsan\n```\n\nThere are configurations for the Address Sanitizer (ASAN), Memory Sanitizer\n(MSAN), Leak Sanitizer (LSAN) and Undefined Behavior Sanitizer (UBSAN). You can\nread about the behaviors of the sanitizers in the link above, but essentially\nthe Address Sanitizer finds invalid memory accesses (use after free, access\nout-of-bounds, etc.), Memory Sanitizer finds uses of uninitialized memory,\nthe Leak Sanitizer finds memory leaks, and the Undefined Behavior Sanitizer\nfinds undefined behavior (surprise!).\n\nTypically, you'll just want to run all the tests for a given sanitizer:\n\n```console\n$ make test-asan\n```\n\nYou can also run the tests for a release build:\n\n```console\n$ make test-clang-release-asan\n...\n```\n\nThe GitHub actions bots run all of these tests (and more). Before you land a change,\nyou should run them too. One easy way is to use the `test-everything` target:\n\n```console\n$ make test-everything\n```\n\n## Fuzzing\n\nTo build using the [LLVM fuzzer support](https://llvm.org/docs/LibFuzzer.html),\nappend `fuzz` to the target:\n\n```console\n$ make clang-debug-fuzz\n```\n\nThis will produce a `wasm2wat_fuzz` binary. It can be used to fuzz the binary\nreader, as well as reproduce fuzzer errors found by\n[oss-fuzz](https://github.com/google/oss-fuzz/tree/master/projects/wabt).\n\n```console\n$ out/clang/Debug/fuzz/wasm2wat_fuzz ...\n```\n\nSee the [libFuzzer documentation](https://llvm.org/docs/LibFuzzer.html) for\nmore information about how to use this tool.\n\n## Installing prebuilt binaries\n\nWabt is available on many platforms as prepackaged binaries. For example, if\nyou use Homebrew you can use:\n```sh\nbrew install wabt\n```\n\nAnd you use an apt-based linux distribution you can use:\n```sh\nsudo apt install wabt\n```\n\nYou can also download prebuilt binaries for many platforms directly from the\ngithub releases page.\n","funding_links":[],"categories":["C++","Tools","webassembly","Development Tools","Static analysis","Projects","开发工具链","Tooling","WebAssambly","🔧 Packages"],"sub_categories":["Kits","Inspecting `.wasm` Binaries","Mesh networks","Libraries","调试与性能工具","Frameworks","Video","⚡ Debugging"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWebAssembly%2Fwabt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWebAssembly%2Fwabt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWebAssembly%2Fwabt/lists"}