Skip to content

wasm32 and wasm64: the default library for -mm=rc, none and own - #92

Merged
ASDAlexander77 merged 1 commit into
mainfrom
wasm-defaultlib
Nov 11, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
wasm-defaultlib

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

The default library for wasm32-unknown-unknown and wasm64-unknown-unknown, under -mm=rc, none and own.

  • scripts/build_wasm.bat (Windows) and scripts/build_wasm.sh (Linux) build lib/<wasm32|wasm64>/unknown/unknown/unknown/<release|debug>/<rc|none|own>/libTypeScriptDefaultLib.a, from lib.ts and the new OS layer src/lib.wasm.ts, archived with llvm-ar.
  • No C++ wrappers: these targets have no C library. tslang links a wasm program with --allow-undefined, so the C functions and the wrappers' functions are imports from env. The host implements them; the compiler repo's docs/how/wasm/test/host.mjs is that host, for Node and browsers.
  • lib.wasm.ts declares no C data, because an undefined data symbol is never resolved; the time zone comes from the host. Its signatures match the declarations in lib.ts exactly, because wasm-ld checks them (convertInteger takes a long, snprintf returns an int).
  • No gc build: the collector is not built for wasm.

Goes with the compiler PR (wasm-defaultlib), which reads this archive's borrow facts under -mm=own.

Tests

The compiler repo's docs/how/wasm/test/run_tests.mjs --suite=defaultlib compiles tests/*.ts against the wasm archives and runs them under Node 26. On wasm32 and wasm64, in release and in debug, 181 pass under none and rc and 180 under own.

  • Skipped:
    • tests that catch an exception: try/catch does not catch on wasm yet
    • async and threads
    • fetch.ts: the host has no network
    • tests marked // gc only and // linux only, and, under own, // not own
  • Not run: build_wasm.sh on a Linux host. It was run from Git Bash against the Windows tslang.

🤖 Generated with Claude Code

scripts/build_wasm.bat (and build_wasm.sh for a Linux host) build
lib/<wasm32|wasm64>/unknown/unknown/unknown/<release|debug>/<rc|none|own>/libTypeScriptDefaultLib.a:
lib.ts and the OS layer src/lib.wasm.ts, archived with llvm-ar.

These targets have no C library, so there are no C++ wrappers: tslang links a wasm
program with --allow-undefined, and the C functions and the wrappers' functions are
imports the host implements (the compiler repo's docs/how/wasm/test/host.mjs).
lib.wasm.ts declares no C data (an undefined data symbol is never resolved): the time
zone comes from the host. Its signatures match lib.ts's declarations exactly, as
wasm-ld checks them (convertInteger takes a long, snprintf returns an int). No gc
build: the collector is not built for wasm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 5091064 into main Nov 11, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant