WebAssembly/wabt là dự án mã nguồn mở trên GitHub với 8.2k sao, viết chủ yếu bằng C++. The WebAssembly Binary Toolkit
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
WABT (we pronounce it "wabbit") is a suite of tools for WebAssembly, including:
wat2wasm: translate from WebAssembly text format to the WebAssembly binary format
wasm2wat: the inverse of wat2wasm, translate from the binary format back to the text format (also known as a .wat)
wasm-objdump: print information about a wasm binary. Similiar to objdump.
wasm-interp: decode and run a WebAssembly binary file using a stack-based interpreter
wat-desugar: parse .wat text form as supported by the spec interpreter (s-expressions, flat syntax, or mixed) and print "canonical" flat format
wasm2c: convert a WebAssembly binary file to a C source and header
wasm-strip: remove sections of a WebAssembly binary file
wasm-validate: validate a file in the WebAssembly binary format
wast2json: convert a file in the wasm spec test format to a JSON file and associated wasm binary files
wasm-stats: output stats for a module
spectest-interp: read a Spectest JSON file, and run its tests in the interpreter
These tools are intended for use in (or for development of) toolchains or other
systems that want to manipulate WebAssembly files. Unlike the WebAssembly spec
interpreter (which is written to be as simple, declarative and "speccy" as
possible), they are written in C/C++ and designed for easier integration into
other systems. Unlike Binaryen these
tools do not aim to provide an optimization platform or a higher-level compiler
target; instead they aim for full fidelity and compliance with the spec (e.g.
1:1 round-trips with no changes to instructions).
Online Demos
Wabt has been compiled to JavaScript via emscripten. Some of the functionality is available in the following demos:
index
wat2wasm
wasm2wat
Supported Proposals
Proposal: Name and link to the WebAssembly proposal repo
flag: Flag to pass to the tool to enable/disable support for the feature
default: Whether the feature is enabled by default
binary: Whether wabt can read/write the binary format
text: Whether wabt can read/write the text format
validate: Whether wabt can validate the syntax
interpret: Whether wabt can execute these operations in wasm-interp or spectest-interp
wasm2c: Whether wasm2c supports these operations
Proposal
flag
default
binary
text
validate
interpret
wasm2c
exception handling
--disable-exceptions
✓
✓
✓
✓
✓
✓
mutable globals
--disable-mutable-globals
✓
✓
✓
✓
✓
✓
nontrapping float-to-int conversions
--disable-saturating-float-to-int
✓
✓
✓
✓
✓
✓
sign extension
--disable-sign-extension
✓
✓
✓
✓
✓
✓
simd
--disable-simd
✓
✓
✓
✓
✓
✓
threads
--enable-threads
✓
✓
✓
✓
multi-value
--disable-multi-value
✓
✓
✓
✓
✓
✓
tail-call
--disable-tail-call
✓
✓
✓
✓
✓
✓
bulk memory
--disable-bulk-memory
✓
✓
✓
✓
✓
✓
reference types
--disable-reference-types
✓
✓
✓
✓
✓
✓
annotations
--disable-annotations
✓
✓
memory64
--disable-memory64
✓
✓
✓
✓
✓
✓
multi-memory
--disable-multi-memory
✓
✓
✓
✓
✓
✓
extended-const
--disable-extended-const
✓
✓
✓
✓
✓
✓
relaxed-simd
--disable-relaxed-simd
✓
✓
✓
✓
✓
custom-page-sizes
--enable-custom-page-sizes
✓
✓
✓
✓
✓
compact-imports
--enable-compact-imports
✓
✓
function-references
--enable-function-references
✓
✓
✓
✓
wide-arithmetic
--enable-wide-arithmetic
✓
✓
✓
Cloning
Clone as normal, but don't forget to get the submodules as well:
This will produce build files using CMake's default build generator. Read the
CMake documentation for more information.
NOTE: You must create a separate directory for the build artifacts (e.g.
build above). Running cmake from the repo root directory will not work
since the build produces an executable called wasm2c which conflicts with the
wasm2c directory.
Building using the top-level Makefile (Linux and macOS)
NOTE: Under the hood, this uses make to run CMake, which then calls
ninja to perform that actual build. On some systems (typically macOS), this
doesn't build properly. If you see these errors, you can build using CMake
directly as described above.
You'll need CMake and Ninja. If
you just run make, it will run CMake for you, and put the result in
out/clang/Debug/ by default:
Note: If you are on macOS, you will need to use CMake version 3.2 or higher
$ make
This will build the default version of the tools: a debug build using the Clang
compiler.
There are many make targets available for other configurations as well. They
are generated from every combination of a compiler, build type and
configuration.
$ make clang-debug
$ make gcc-i686-release
$ make clang-debug-lsan
$ make gcc-debug-no-tests
Building (Windows)
You'll need CMake. You'll also need
Visual Studio (2015 or newer) or
MinGW.
Note: Visual Studio 2017 and later come with CMake (and the Ninja build system)
out of the box, and should be on your PATH if you open a Developer Command prompt.
See https://aka.ms/cmake for more details.
You can run CMake from the command prompt, or use the CMake GUI tool. See
Running CMake for more information.
When running from the commandline, create a new directory for the build
artifacts, then run cmake from this directory:
The [config] parameter should be a CMake build type, typically DEBUG or RELEASE.
The [generator] parameter should be the type of project you want to generate,
for example "Visual Studio 14 2015". You can see the list of available
generators by running cmake --help.
To build the project, you can use Visual Studio, or you can tell CMake to do it:
If you want to add new keywords, you'll need to install
gperf. Before you upload your PR, please
run make update-gperf to update the prebuilt C++ sources in src/prebuilt/.
Running wat2wasm
Some examples:
# parse test.wat and write to .wasm binary file with the same name
$ bin/wat2wasm test.wat
# parse test.wat and write to binary file test.wasm
$ bin/wat2wasm test.wat -o test.wasm
# parse spec-test.wast, and write verbose output to stdout (including the
# meaning of every byte)
$ bin/wat2wasm spec-test.wast -v
You can use --help to get additional help:
$ bin/wat2wasm --help
Or try the online demo.
Running wasm2wat
Some examples:
# parse binary file test.wasm and write text file test.wat
$ bin/wasm2wat test.wasm -o test.wat
# parse test.wasm and write test.wat
$ bin/wasm2wat test.wasm -o test.wat
You can use --help to get additional help:
$ bin/wasm2wat --help
Or try the online demo.
Running wasm-interp
Some examples:
# parse binary file test.wasm, and type-check it
$ bin/wasm-interp test.wasm
# parse test.wasm and run all its exported functions
$ bin/wasm-interp test.wasm --run-all-exports
# parse test.wasm, run the exported functions and trace the output
$ bin/wasm-interp test.wasm --run-all-exports --trace
# parse test.json and run the spec tests
$ bin/wasm-interp test.json --spec
# parse test.wasm and run all its exported functions, setting the value stack
# size to 100 elements
$ bin/wasm-interp test.wasm -V 100 --run-all-exports
You can use --help to get additional help:
$ bin/wasm-interp --help
Running wast2json
See wast2json.md.
Running wasm2c
See wasm2c.md
Running the test suite
See test/README.md.
Sanitizers
To build with the LLVM sanitizers,
append the sanitizer name to the target:
$ make clang-debug-asan
$ make clang-debug-msan
$ make clang-debug-lsan
$ make clang-debug-ubsan
There are configurations for the Address Sanitizer (ASAN), Memory Sanitizer
(MSAN), Leak Sanitizer (LSAN) and Undefined Behavior Sanitizer (UBSAN). You can
read about the behaviors of the sanitizers in the link above, but essentially
the Address Sanitizer finds invalid memory accesses (use after free, access
out-of-bounds, etc.), Memory Sanitizer finds uses of uninitialized memory,
the Leak Sanitizer finds memory leaks, and the Undefined Behavior Sanitizer
finds undefined behavior (surprise!).
Typically, you'll just want to run all the tests for a given sanitizer:
$ make test-asan
You can also run the tests for a release build:
$ make test-clang-release-asan
...
The GitHub actions bots run all of these tests (and more). Before you land a change,
you should run them too. One easy way is to use the test-everything target:
$ make test-everything
Fuzzing
To build using the LLVM fuzzer support,
append fuzz to the target:
$ make clang-debug-fuzz
This will produce a wasm2wat_fuzz binary. It can be used to fuzz the binary
reader, as well as reproduce fuzzer errors found by
oss-fuzz.
$ out/clang/Debug/fuzz/wasm2wat_fuzz ...
See the libFuzzer documentation for
more information about how to use this tool.
Installing prebuilt binaries
Wabt is available on many platforms as prepackaged binaries. For example, if
you use Homebrew you can use:
brew install wabt
And you use an apt-based linux distribution you can use:
sudo apt install wabt
For use from Python, an unofficial PyPI package is available
(wabt-package):
pip install wabt-package
You can also download prebuilt binaries for many platforms directly from the
github releases page.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/WebAssembly/wabt là nguồn chính thức.
WebAssembly/wabt có bao nhiêu sao?
WebAssembly/wabt có 8.2k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/WebAssembly/wabt. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
WebAssembly/wabt có những chủ đề gì?
GitHub topics của WebAssembly/wabt: "webassembly". TopGit xếp repo vào nhóm mã nguồn mở.
WebAssembly/wabt có phải mã nguồn mở không?
Có — WebAssembly/wabt phát hành theo license Apache-2.0, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/WebAssembly/wabt.
WebAssembly/wabt có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho WebAssembly/wabt. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
WebAssembly/wabt còn đang phát triển không?
Commit gần nhất trên WebAssembly/wabt là 13 ngày trước (theo timestamp GitHub). Repo có 844 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về wabt?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về wabt.