{"id":13470961,"url":"https://github.com/WebAssembly/wasi-sdk","last_synced_at":"2025-03-26T12:32:14.575Z","repository":{"id":38209343,"uuid":"174204333","full_name":"WebAssembly/wasi-sdk","owner":"WebAssembly","description":"WASI-enabled WebAssembly C/C++ toolchain","archived":false,"fork":false,"pushed_at":"2024-10-11T22:27:22.000Z","size":356,"stargazers_count":1264,"open_issues_count":49,"forks_count":189,"subscribers_count":51,"default_branch":"main","last_synced_at":"2024-10-29T15:23:31.112Z","etag":null,"topics":["llvm","sysroot","wasi-libc","wasi-sdk"],"latest_commit_sha":null,"homepage":"","language":"CMake","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":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-06T19:07:27.000Z","updated_at":"2024-10-29T14:15:37.000Z","dependencies_parsed_at":"2024-04-03T15:46:34.658Z","dependency_job_id":"4f5f97a9-8076-4365-92d5-a07c11537e56","html_url":"https://github.com/WebAssembly/wasi-sdk","commit_stats":{"total_commits":263,"total_committers":45,"mean_commits":5.844444444444444,"dds":0.8365019011406845,"last_synced_commit":"adbbf2c07fc339588d73ab483f14a4578137e50a"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebAssembly%2Fwasi-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebAssembly%2Fwasi-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebAssembly%2Fwasi-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebAssembly%2Fwasi-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebAssembly","download_url":"https://codeload.github.com/WebAssembly/wasi-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245654380,"owners_count":20650854,"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":["llvm","sysroot","wasi-libc","wasi-sdk"],"created_at":"2024-07-31T16:00:37.865Z","updated_at":"2025-03-26T12:32:14.566Z","avatar_url":"https://github.com/WebAssembly.png","language":"CMake","readme":"# WASI SDK\n\n## Quick Start\n\n[Download SDK packages here.][releases]\n\n[releases]: https://github.com/WebAssembly/wasi-sdk/releases\n\n## About this repository\n\nThis repository contains no compiler or library code itself; it uses\ngit submodules to pull in the upstream Clang and LLVM tree, as well as the\nwasi-libc tree.\n\nThe libc portion of this SDK is maintained in [wasi-libc].\n\n[wasi-libc]: https://github.com/WebAssembly/wasi-libc\n\nUpstream Clang and LLVM (from 9.0 onwards) can compile for WASI out of the box,\nand WebAssembly support is included in them by default. So, all that's done here\nis to provide builds configured to set the default target and sysroot for\nconvenience.\n\nOne could also use a standard Clang installation, build a sysroot from the\nsources mentioned above, and compile with `--target=wasm32-wasi\n--sysroot=/path/to/sysroot`. In this scenario, one would also need the\n`libclang_rt.builtins-wasm32.a` objects available separately in the [release\ndownloads][releases] which must be extracted into\n`$CLANG_INSTALL_DIR/$CLANG_VERSION/lib/wasi/`.\n\n## Clone\n\nThis repository uses git submodule, to clone it you need use the command below :\n\n```shell script\ngit clone --recursive https://github.com/WebAssembly/wasi-sdk.git\n```\n\n## Requirements\n\nThe Wasm-sdk's build process needs some packages :\n\n* `cmake`\n* `clang`\n* `ninja`\n* `python3`\n\nPlease refer to your OS documentation to install those packages.\n\n## Build\n\nBuilding `wasi-sdk` uses CMake and is split into two halves. First you can build\nthe toolchain itself:\n\n```shell script\ncmake -G Ninja -B build/toolchain -S . -DWASI_SDK_BUILD_TOOLCHAIN=ON -DCMAKE_INSTALL_PREFIX=build/install\ncmake --build build/toolchain --target install\n```\n\nWhen you're developing locally you may also wish to pass\n`-DCMAKE_CXX_COMPILER_LAUNCHER=ccache` to assist with rebuilds. Other supported\nCMake flags are:\n\n* `-DLLVM_CMAKE_FLAGS` - extra flags to pass to `cmake` when building\n  LLVM/Clang.\n* `-DRUST_TARGET` - the specific Rust target triple to build `wasm-component-ld`\n  for, useful for cross-compiles.\n\nThe `clang` compiler should now be located at `build/install/bin/clang` but it's\njust a compiler, the sysroot isn't built yet. Next the second step of the build\nis to build the sysroot:\n\n```shell script\ncmake -G Ninja -B build/sysroot -S . \\\n    -DCMAKE_INSTALL_PREFIX=build/install \\\n    -DCMAKE_TOOLCHAIN_FILE=build/install/share/cmake/wasi-sdk.cmake \\\n    -DCMAKE_C_COMPILER_WORKS=ON \\\n    -DCMAKE_CXX_COMPILER_WORKS=ON\ncmake --build build/sysroot --target install\n```\n\nA full toolchain should now be present at `build/install` and is ready for use\nin compiling WebAssembly code. Supported CMake flags are:\n\n* `-DWASI_SDK_DEBUG_PREFIX_MAKE=OFF` - disable `-fdebug-prefix-map` when\n  building C/C++ code to use full host paths instead.\n* `-DWASI_SDK_INCLUDE_TESTS=ON` - used for building tests.\n* `-DWASI_SDK_TEST_HOST_TOOLCHAIN=ON` - test the host toolchain's wasi-libc and\n  sysroot libraries, don't build or use fresh libraries for tests.\n* `-DWASI_SDK_TARGETS=..` - a list of targets to build, by default all WASI\n  targets are compiled.\n* `-DWASI_SDK_INSTALL_TO_CLANG_RESOURCE_DIR=ON` - install compiler-rt\n  to the compiler's resource directory. might be convenient if you want to\n  use the toolchain (eg. `./build/install/bin/clang`) in-place.\n\nIf you'd like to build distribution artifacts you can use the `dist` target like\nso:\n\n```shell script\ncmake --build build/toolchain --target dist\ncmake --build build/sysroot --target dist\n```\n\nTarballs will be created under `build/toolchain/dist` and `build/sysroot/dist`.\nNote that these are separate tarballs for the toolchain and sysroot. To create a\nsingle tarball for the entire SDK you'll first want to copy all tarballs into a\nnew folder and then run the `./ci/merge-artifacts.sh` script:\n\n```shell script\nmkdir dist-my-platform\ncp build/toolchain/dist/* build/sysroot/dist/* dist-my-platform\n./ci/merge-artifacts.sh\n```\n\nThis will produce `dist/wasi-sdk-*.tar.gz` which is the same as the release\nartifacts for this repository.\n\nFinally you can additionally bundle many of the above steps, minus\n`merge-artifact.sh` by using the CI script to perform both the toolchain and\nsysroot build:\n\n```shell script\n./ci/build.sh\n```\n\nThe built package can be found into `build/dist` directory.\nFor releasing a new version of the package on GitHub,\nsee [RELEASING.md](RELEASING.md).\n\n## Install\n\nA typical installation from the release binaries might look like the following:\n\n```shell script\nWASI_OS=linux\nWASI_ARCH=x86_64 # or 'arm64' if running on arm64 host\nWASI_VERSION=24\nWASI_VERSION_FULL=${WASI_VERSION}.0\nwget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-${WASI_ARCH}-${WASI_OS}.tar.gz\ntar xvf wasi-sdk-${WASI_VERSION_FULL}-${WASI_ARCH}-${WASI_OS}.tar.gz\n```\n\n## Use\n\nUse the clang installed in the `wasi-sdk` directory:\n\n```shell script\nWASI_SDK_PATH=`pwd`/wasi-sdk-${WASI_VERSION_FULL}-${WASI_ARCH}-${WASI_OS}\nCC=\"${WASI_SDK_PATH}/bin/clang --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot\"\n$CC foo.c -o foo.wasm\n```\n\nNote: `${WASI_SDK_PATH}/share/wasi-sysroot` contains the WASI-specific\nincludes/libraries/etc. The `--sysroot=...` option is not necessary if\n`WASI_SDK_PATH` is `/opt/wasi-sdk`. For troubleshooting, one can replace the\n`--sysroot` path with a manual build of [wasi-libc].\n\n### Integrating with a CMake build system\n\nUse a toolchain file to setup the *wasi-sdk* platform.\n\n```\n$ cmake -DCMAKE_TOOLCHAIN_FILE=${WASI_SDK_PATH}/share/cmake/wasi-sdk.cmake ...\n```\n\nor the *wasi-sdk-thread* platform\n\n```\n$ cmake -DCMAKE_TOOLCHAIN_FILE=${WASI_SDK_PATH}/share/cmake/wasi-sdk-pthread.cmake ...\n```\n\n## Notes for Autoconf\n\n[Autoconf] 2.70 now [recognizes WASI].\n\n[Autoconf]: https://www.gnu.org/software/autoconf/autoconf.html\n[recognizes WASI]: https://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob;f=build-aux/config.sub;h=19c9553b1825cafb182115513bc628e0ee801bd0;hb=97fbc5c184acc6fa591ad094eae86917f03459fa#l1723\n\nFor convenience when building packages that aren't yet updated, updated\nconfig.sub and config.guess files are installed at `share/misc/config.*`\nin the install directory.\n\n## Docker Image\n\nWe provide a [docker image] including WASI SDK that can be used for building\nprojects without a separate installation of the SDK. Autotools, CMake, and Ninja\nare included in this image, and standard environment variables are set to use\nWASI SDK for building.\n\n[docker image]: https://github.com/WebAssembly/wasi-sdk/pkgs/container/wasi-sdk\n\nFor example, this command can build a make-based project with the Docker\nimage.\n\n```\ndocker run -v `pwd`:/src -w /src ghcr.io/webassembly/wasi-sdk make\n```\n\nTake note of the [notable limitations](#notable-limitations) below when\nbuilding projects, for example many projects will need threads support\ndisabled in a configure step before building with WASI SDK.\n\n## Notable Limitations\n\nThis repository does not yet support __C++ exceptions__. C++ code is supported\nonly with -fno-exceptions for now.\nWork on support for [exception handling] is underway at the\nlanguage level which will support the features.\n\n[exception handling]: https://github.com/WebAssembly/exception-handling/\n\nSee [C setjmp/longjmp support] about setjmp/longjmp support.\n\n[C setjmp/longjmp support]: SetjmpLongjmp.md\n\nThis repository experimentally supports __threads__ with\n`--target=wasm32-wasi-threads`. It uses WebAssembly's [threads] primitives\n(atomics, `wait`/`notify`, shared memory) and [wasi-threads] for spawning\nthreads. Note: this is experimental \u0026mdash; do not expect long-term stability!\n\n[threads]: https://github.com/WebAssembly/threads\n[wasi-threads]: https://github.com/WebAssembly/wasi-threads\n\nThis repository does not yet support __dynamic libraries__. While there are\n[some efforts] to design a system for dynamic libraries in wasm, it is still in\ndevelopment and not yet generally usable.\n\n[some efforts]: https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md\n\nThere is no support for __networking__. It is a goal of WASI to support\nnetworking in the future though.\n","funding_links":[],"categories":["CMake","Tools"],"sub_categories":["Programming Language Support"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWebAssembly%2Fwasi-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWebAssembly%2Fwasi-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWebAssembly%2Fwasi-sdk/lists"}