WebAssembly/wasi-sdk là dự án mã nguồn mở trên GitHub, viết chủ yếu bằng CMake, với 1.7k sao. WASI-enabled WebAssembly C/C++ toolchain
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.
This repository contains no compiler or library code itself; it uses
git submodules to pull in the upstream Clang and LLVM tree, as well as the
wasi-libc tree.
The libc portion of this SDK is maintained in wasi-libc.
Upstream Clang and LLVM (from 9.0 onwards) can compile for WASI out of the box,
and WebAssembly support is included in them by default. So, all that's done here
is to provide builds configured to set the default target and sysroot for
convenience.
One could also use a standard Clang installation, build a sysroot from the
sources mentioned above, and compile with --target=wasm32-wasip1 --sysroot=/path/to/sysroot. In this scenario, one would also need the
libclang_rt.*.a objects available separately in the release
downloads which must be extracted into
$CLANG_INSTALL_DIR/$CLANG_VERSION/lib/.
Clone
This repository uses git submodule, to clone it you need use the command below :
When you're developing locally you may also wish to pass
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache to assist with rebuilds. Other supported
CMake flags are:
-DLLVM_CMAKE_FLAGS - extra flags to pass to cmake when building
LLVM/Clang.
-DRUST_TARGET - the specific Rust target triple to build wasm-component-ld
for, useful for cross-compiles.
The clang compiler should now be located at build/install/bin/clang but it's
just a compiler, the sysroot isn't built yet. Next the second step of the build
is to build the sysroot:
A full toolchain should now be present at build/install and is ready for use
in compiling WebAssembly code. Supported CMake flags are:
-DWASI_SDK_DEBUG_PREFIX_MAKE=OFF - disable -fdebug-prefix-map when
building C/C++ code to use full host paths instead.
-DWASI_SDK_INCLUDE_TESTS=ON - used for building tests.
-DWASI_SDK_CPU_CFLAGS=.. - used to specify CFLAGS to tweak wasm features
to enable/disable. The default is -mcpu=lime1.
-DWASI_SDK_LTO=ON - whether to enable/disable builds of LTO-capable
libraries as part of the build.
-DWASI_SDK_BUILD_SHARED=ON - whether to build shared libraries (libc.so,
libc++.so, etc.) for targets that support them. Set to OFF to produce a
static-only sysroot.
-DWASI_SDK_EXCEPTIONS=ON - whether to enable/disable support for C++
exceptions, see CppExceptions.md for more information.
-DWASI_SDK_TEST_HOST_TOOLCHAIN=ON - test the host toolchain's wasi-libc and
sysroot libraries, don't build or use fresh libraries for tests.
-DWASI_SDK_TARGETS=.. - a list of targets to build, by default all WASI
targets are compiled. The default set is listed in
Supported Targets.
-DWASI_SDK_INSTALL_TO_CLANG_RESOURCE_DIR=ON - install compiler-rt
to the compiler's resource directory. might be convenient if you want to
use the toolchain (eg. ./build/install/bin/clang) in-place.
If you'd like to build distribution artifacts you can use the dist target like
so:
Tarballs will be created under build/toolchain/dist and build/sysroot/dist.
Note that these are separate tarballs for the toolchain and sysroot. To create a
single tarball for the entire SDK you'll first want to copy all tarballs into a
new folder and then run the ./ci/merge-artifacts.sh script:
This will produce dist/wasi-sdk-*.tar.gz which is the same as the release
artifacts for this repository.
Finally you can additionally bundle many of the above steps, minus
merge-artifact.sh by using the CI script to perform both the toolchain and
sysroot build:
./ci/build.sh
The built package can be found into build/dist directory.
For releasing a new version of the package on GitHub,
see RELEASING.md.
Install
A typical installation from the release binaries might look like the following:
WASI_OS=linux
WASI_ARCH=x86_64 # or 'arm64' if running on arm64 host
WASI_VERSION=27
WASI_VERSION_FULL=${WASI_VERSION}.0
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-${WASI_ARCH}-${WASI_OS}.tar.gz
tar xvf wasi-sdk-${WASI_VERSION_FULL}-${WASI_ARCH}-${WASI_OS}.tar.gz
Use
Use the clang installed in the wasi-sdk directory:
Note: ${WASI_SDK_PATH}/share/wasi-sysroot contains the WASI-specific
includes/libraries/etc. The --sysroot=... option is not necessary if
WASI_SDK_PATH is /opt/wasi-sdk. For troubleshooting, one can replace the
--sysroot path with a manual build of wasi-libc.
Supported Targets
The default target for the SDK's clang is wasm32-wasip1. The default
WASI_SDK_TARGETS build setting includes these targets:
Target
Description
wasm32-wasip1
WASI Preview 1, and the default target.
wasm32-wasip2
WASI Preview 2 and the component model.
wasm32-wasip3
WASI Preview 3 and async component model support.
wasm32-wasip1-threads
WASI Preview 1 with experimental support for spawning threads.
As of wasi-sdk 34, the previously supported wasm32-wasi and
wasm32-wasi-threads aliases have been removed. Use wasm32-wasip1 and
wasm32-wasip1-threads instead.
To build only a subset of targets, pass a semicolon-separated
WASI_SDK_TARGETS value when configuring the sysroot:
For convenience when building packages that aren't yet updated, updated
config.sub and config.guess files are installed at share/misc/config.*
in the install directory.
Docker Image
We provide a docker image including WASI SDK that can be used for building
projects without a separate installation of the SDK. Autotools, CMake, and Ninja
are included in this image, and standard environment variables are set to use
WASI SDK for building.
For example, this command can build a make-based project with the Docker
image.
docker run -v `pwd`:/src -w /src ghcr.io/webassembly/wasi-sdk make
Take note of the notable limitations below when
building projects, for example many projects will need threads support
disabled in a configure step before building with WASI SDK.
Notable Limitations
C++ exceptions are disabled by default and require extra configuration to get
working, see [CppExceptions.md].
C setjmp/longjmp require some extra configuration to get working, see
[SetjmpLongjmp.md].
Most targets do not support spawning a thread. Experimental support for
spawning threads is available with the wasm32-wasip1-threads target which
uses wasi-threads. Note that the pthread_* family of functions, as well as
C++ threading primitives such as <atomic>, <mutex>, and <thread> are
available on all targets. Defining a macro _WASI_STRICT_PTHREAD will make
pthread_create, pthread_detach, pthread_join, pthread_tryjoin_np, and
pthread_timedjoin_np fail with a compile time error when building for
single-threaded targets.
Dynamic linking is supported but not as fully baked as static
linking. There might be obscure bugs in some situations related to dynamic
linking.
The WASIp1 targets do not support networking, but WASIp2/WASIp3 support
networking.
64-bit linear memories (a "wasm64" target) are not supported at this time.
Supporting this will require resolving WebAssembly/component-model#22 first
at which point it will be possible to add a wasm64-wasip2 target. There are
no plans to add support for wasm64-wasi{,-threads,p1,p1-threads} at this
time.
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/wasi-sdk là nguồn chính thức.
WebAssembly/wasi-sdk có phải mã nguồn mở không?
Có — WebAssembly/wasi-sdk 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/wasi-sdk.
WebAssembly/wasi-sdk có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho WebAssembly/wasi-sdk. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
WebAssembly/wasi-sdk dùng license gì?
WebAssembly/wasi-sdk phát hành theo license Apache-2.0. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
WebAssembly/wasi-sdk là gì?
WebAssembly/wasi-sdk (WebAssembly/wasi-sdk) là dự án CMake trên GitHub. Theo mô tả gốc: WASI-enabled WebAssembly C/C++ toolchain
Đọc đầy đủ README ở tab phía trên.
wasi-sdk có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về wasi-sdk.