@ai-ecoverse/wasm-clang

中文文档
24.0.0-26发布于 2026/10/22Apache-2.0 WITH LLVM-exception构建来源已验证近 30 天下载 2482

The Clang and LLD 24 compilers, to build C and C++ programs in slicc.

原始使用文档
文档目录4 节
  1. Drivers
  2. One module for every tool
  3. Environment and paths
  4. Notices

@ai-ecoverse/wasm-clang

Clang/LLD 24 for the slicc wasm realm, linked in CI from @ai-ecoverse/llvm-emscripten (llvm-project b158b0ae compiled by the patched emscripten 6.0.9 tree) against current libslicc (Module.sliccKernel spawn, kernel credentials) with ENVIRONMENT=web,worker,node.

Companions:

  • @ai-ecoverse/wasix-sysroot (WASIXCC_SYSROOT_PREFIX)
  • @ai-ecoverse/wasm-binaryen (wasm-opt for fork Asyncify — on PATH)

Drivers

cc / gcc / c++ / g++ / wasixcc / wasix++ are #!/bin/sh scripts (slicc.commands { "script": "bin/…" }). Use them as the normal compilers — no extra WASI/EH flags needed for typical builds.

  • Target: --target=wasm32-wasip1 (sysroot ships a real lib/wasm32-wasip1).

  • C++ links -lc++ -lc++abi -lunwind (exnref exceptions, threads, iostream).

  • Output is a WASI program SLICC runs directly (no separate host wrapper).

  • Executable link that imports proc_fork / stack_checkpoint runs wasm-opt --asyncify (from @ai-ecoverse/wasm-binaryen) automatically so fork works on the SLICC host. Plain programs skip asyncify.

  • -shared: side module, -nostdlib (no libc) — resolve symbols against a PIE main that exports them.

  • PIE / dlopen main: cc -rdynamic … or cc -fPIC foo.c -o foo (no -shared) → -pie --export-all, libc whole-archive, tag stubs. Then dlopen("./libsq.so") works.

  • CMake: CC=cc CXX=c++ cmake … — Clang 24 is identified; pthread.h and the sysroot resolve under SLICC.

  • Assembly: for input that is only plain assembly (.s, .asm, or -x assembler), the driver leaves out the C flags clang ignores there (-D_WASI_EMULATED_*, -pthread when not linking, -mthread-model, -fno-trapping-math, -fbracket-depth, -ftls-model, -fvisibility), so cc -Werror -c foo.s works. .S and mixed C and assembly keep them.

  • No link, no link flags: with -fsyntax-only, -emit-ast or --analyze (as with -c, -S, -E and -M), the driver leaves out its link libraries and -Wl, flags, so cc -Werror -fsyntax-only foo.c (configure and CMake checks, editors) works. A .s under -fsyntax-only still gets clang's own 'assembler' input unused, as upstream clang does. -### and -fdriver-only keep them, since they show or check the full link plan.

One module for every tool

bin/llvm.wasm holds clang, lld, llvm-ar, llvm-nm, llvm-objcopy and llvm-symbolizer, linked together so they share one copy of LLVM; the tool is chosen by its name (argv[0]), or llvm <tool> args…. bin/ ships a glue file under every name emcc constructs under LLVM_ROOT (clang, clang++, lld, wasm-ld, ld.lld, llvm-ar, llvm-ranlib, llvm-nm, llvm-objcopy, llvm-strip, llvm-symbolizer): each is a byte-copy of bin/llvm, which locates llvm.wasm beside it. slicc.commands covers the same names plus ar, ranlib, nm, strip for PATH lookups.

Not shipped (emcc only needs these for -g / split-dwarf / coverage / emsize / sourcemap demangle): llvm-dwarfdump, llvm-dwp, clang-scan-deps, llvm-profdata, llvm-cov, llvm-size, llvm-cxxfilt.

cc hello.c -o hello
cc -fPIC -shared sq.c -o libsq.so
cc -rdynamic -fPIC dl.c -o dl   # PIE main exporting libc for dlopen
c++ -O2 t.cpp -o t              # iostream + exceptions + threads

CC=cc CXX=c++ cmake -S . -B build
cmake --build build

Environment and paths

bin/llvm links shims/slicc/slicc-env.js: the tools' environment is only what the kernel passes, with none of Emscripten's placeholders (USER=web_user, HOME=/home/web_user, PATH=/). After env -i, clang has no PATH, so it doesn't look for helpers such as wasm-opt in /.

The glue is linked with wasm-emscripten's package patches (0014: a path may go through 40 symbolic links, as on Linux, and the 41st is ELOOP).

Notices

THIRD-PARTY-NOTICES.md covers the Emscripten runtime, the wasix-sysroot compiler-rt builtins, llvm-project's LLVM Support notices and homescoop's own slicc shims (Apache-2.0).

版本与发布记录

@ai-ecoverse/wasm-clang 共发布 22 个版本,首次发布于 2026/10/01;过去 12 个月发布了 22 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
24.0.0-26latest2026/10/2216 天前
24.0.0-252026/10/2216 天前
24.0.0-242026/10/2217 天前
24.0.0-232026/10/2018 天前
24.0.0-222026/10/1919 天前
24.0.0-212026/10/1722 天前

关于 @ai-ecoverse/wasm-clang 的常见问题

@ai-ecoverse/wasm-clang 是什么?

The Clang and LLD 24 compilers, to build C and C++ programs in slicc.

如何安装 @ai-ecoverse/wasm-clang?

在项目目录运行 npm install @ai-ecoverse/wasm-clang,或使用 pnpm add / yarn add / bun add。

@ai-ecoverse/wasm-clang 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/ai-ecoverse__wasm-clang 是否存在。

@ai-ecoverse/wasm-clang 可以商用吗?

@ai-ecoverse/wasm-clang 使用 Apache-2.0 WITH LLVM-exception 许可。声明的许可为 Apache-2.0 WITH LLVM-exception,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@ai-ecoverse/wasm-clang 的下载量有多少?

根据 npm 官方下载统计,@ai-ecoverse/wasm-clang 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,482 次,日均约 83 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ai-ecoverse/wasm-clang 还在维护吗?

最新版本 24.0.0-26 发布于 2026/10/22(16 天前);至今共发布 22 个版本,其中过去 12 个月发布了 22 个;首次发布于 2026/10/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。