Skip to content

Default library binaries split by target triple, then build, then memory model - #526

Merged
ASDAlexander77 merged 1 commit into
mainfrom
default-lib-triple-layout
Oct 6, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
default-lib-triple-layout

Conversation

@ASDAlexander77

@ASDAlexander77 ASDAlexander77 commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

The compiled default library is now split by target triple for every target (the host included), then by build mode, then by memory model:

defaultlib/{lib,dll}/<arch>/<vendor>/<os>/<env>/{debug,release}/{gc,rc,none}/
  x64 Windows  x86_64/pc/windows/msvc      x86 Windows  i386/pc/windows/msvc
  Linux        x86_64/unknown/linux/gnu    Android      aarch64|x86_64/unknown/linux/android
defaultlib/*.d.ts, generics/, ...          shared by every build
  • Each segment is LLVM's canonical name for the parsed triple component (getArchTypeName etc.), so i686/i386, an Android API level (android29) or an MSVC version share one tree. The x86 arch is therefore i386. The environment is included because Android's OS is linux: without it Android and glibc Linux would collide.
  • Everything other than the binaries stays at the defaultlib root, common to all builds. Android no longer has its own __build/android/<abi>/defaultlib tree: it takes --default-lib-path=<the folder holding defaultlib> like every other target.
  • getDefaultLibSubDir moves from Defines.h (which the async runtime includes without LLVM) to defaultlib.cpp and takes an llvm::Triple. The linker (exe.cpp), the JIT (host triple), --install-default-lib and the new option all call it. The old DEFAULT_LIB_ARCH_X86 special case is gone.
  • New tslang --print-default-lib-dir=<lib|dll> [-mtriple=...] [--di] -mm=<model> prints the folder. Build scripts, CMake templates and tests ask it instead of spelling the layout out, so producer and consumer cannot drift. test-default-lib-dir pins the strings.
  • The missing-library error now names the triple: no default library built for x86_64-pc-windows-msvc -mm=rc: ....

Consumers updated: defaultlib-collector.cmake, android-link.cmake, check-x86-libs.sh, check-x86-run.sh, the VSCode/CMake template in Files.h, docs/how/cmake_{tslang,dll,bgfx}, create-release.yml (the Android default library now ships in the shared defaultlib tree; android/<abi>/lib keeps only libgc.a and libTypeScriptAsyncRuntime.a).

Also: check-x86-libs.sh's stand-in default-library trees get a lib.d.ts, missing since #371 made an unreadable reference an error. Three of its cases were failing before this change.

Merge order

DefaultLib counterpart: ASDAlexander77/TypeScriptCompilerDefaultLib#30. Merge this one first: the DefaultLib build scripts call --print-default-lib-dir and refuse to run with a tslang that lacks it. Old release zips and a new compiler are incompatible (and vice versa), so the next tag needs a full default-library rebuild, which create-release.yml already does.

Test plan

  • test-default-lib-dir, test-compile-android-codegen
  • DefaultLib rebuilt into the new layout: x64 and x86 Windows (debug and release, gc/rc/none), Android arm64-v8a and x86_64 (all 12)
  • test-jit-gc-defaultlib-collector, test-compile-gc-defaultlib-collector with TSLANG_REQUIRE_DEFAULT_LIB=1 (not skipped)
  • test-compile-android-link against the shared tree (not skipped)
  • check-x86-libs.sh all ok, including the x64 control against the real library
  • check-x86-run.sh default-library section all ok against the i386 tree. Two unrelated failures (both --no-default-lib) are pre-existing: the -mm=none frame-allocator IR check expects aligned_alloc but frames now come from __tslang_heap_malloc, and await_order -mm=gc output order is flaky. Filed separately.
  • tslang --cmake project configures and resolves defaultlib/lib/x86_64/pc/windows/msvc/release/rc for -DTSLANG_MEMORY_MODEL=rc
  • Linux: DefaultLib scripts/build.sh only syntax-checked locally; the build_on_linux release job is the real test

🤖 Generated with Claude Code

…ory model

defaultlib/{lib,dll}/<arch>/<vendor>/<os>/<env>/{debug,release}/{gc,rc,none}/ for every
target (the host included), each segment the canonical name LLVM gives the parsed triple
component, so i686/i386, an Android API level or an MSVC version share one tree. The
declarations and everything else stay at the defaultlib root, shared by every build, so
Android no longer needs a tree of its own.

getDefaultLibSubDir moves from Defines.h (which the runtime includes without LLVM) to
defaultlib.cpp and takes the triple; the linker, the JIT, --install-default-lib and the new
--print-default-lib-dir=<lib|dll> all call it. Build scripts and CMake templates ask
--print-default-lib-dir instead of spelling the layout out; test-default-lib-dir pins it.

check-x86-libs.sh: the stand-in default-library trees get a lib.d.ts, missing since #371
made an unreadable reference an error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 5de6690 into main Oct 6, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the default-lib-triple-layout branch October 6, 2026 17:15
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