Skip to content

Stop linking LLVMSupport and LLVMDemangle into compiled programs - #333

Merged
ASDAlexander77 merged 2 commits into
mainfrom
drop-llvm-support-runtime-dep
Sep 18, 2026
Merged

ASDAlexander77 merged 2 commits into
mainfrom
drop-llvm-support-runtime-dep

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

Compiled programs no longer link any LLVM library. Two things used to require it:

  • Async runtime thread pool. AsyncRuntimeCommon.inc used llvm::DefaultThreadPool. It now has its own std::thread pool that behaves the same way: one worker per hardware thread, started on demand, and wait() covers tasks queued by other tasks. The JIT's runtime shares this file.
  • Shared-library imports. The generated code called LLVMLoadLibraryPermanently / LLVMSearchForAddressOfSymbol. Those calls are renamed to tslang_load_library_permanently / tslang_search_for_address_of_symbol:
    • For executables, the new TypeScriptAsyncRuntime/DynamicRuntime.cpp defines them: LoadLibraryW/GetProcAddress on Windows, dlopen/dlsym on Linux. Like LLVM, it loads each library once and searches symbols in load order.
    • For the JIT, TypeScriptRuntime exports them under the new names (.def and the export table).

The driver, test runner, generated CMake template and docs/how/debug/debug-shared.bat no longer link LLVMSupport, LLVMDemangle, ntdll or -ltinfo. The last two were only there for LLVMSupport.

--llvm-lib-path / LLVM_LIB_PATH are still accepted but ignored, so CI, the default-lib build scripts and existing user scripts keep working.

Test plan

  • Windows Release suite: 2765/2765 pass, before and after the rename.
  • llvm-nm: TypeScriptAsyncRuntime.lib and the default lib (gc/rc/none) need no LLVM symbols.
  • tslang --emit=exe builds and runs async programs with LLVM_LIB_PATH unset.
  • Async tests link without ntdll.lib.
  • Linux CI: dlopen path, and linking without -lLLVMDemangle / -ltinfo. Not run locally.

Objects built by an older compiler still reference the LLVM* names and need rebuilding. The default lib is rebuilt per compiler version.

🤖 Generated with Claude Code

ASDAlexander77 and others added 2 commits September 18, 2026 12:07
Two things tied every AOT executable to LLVM:

- The async runtime resumed coroutines on llvm::DefaultThreadPool.
  AsyncRuntimeCommon.inc now has its own std::thread pool with the same
  behaviour (one worker per hardware thread, started on demand; wait()
  covers tasks queued by other tasks). The JIT runtime shares the file.
- Code for a shared-library import called LLVMLoadLibraryPermanently and
  LLVMSearchForAddressOfSymbol. They are renamed to
  tslang_load_library_permanently / tslang_search_for_address_of_symbol;
  TypeScriptAsyncRuntime now defines them for executables
  (LoadLibraryW/GetProcAddress, dlopen/dlsym), and TypeScriptRuntime
  exports them under the new names for the JIT.

The driver, test runner, generated CMake template and debug script no
longer link LLVMSupport, LLVMDemangle, ntdll or tinfo (the last two were
only there for LLVMSupport). --llvm-lib-path / LLVM_LIB_PATH are still
accepted, and ignored, so existing scripts keep working.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
On Linux every JIT run that imports a shared library failed with
"Symbols not found: tslang_load_library_permanently,
tslang_search_for_address_of_symbol". The old LLVM* names had resolved
from tslang's own LLVMSupport; the new ones exist only in
TypeScriptRuntime, which has no .def to rename exports on Linux and is
not loaded at all under -mm=rc or -mm=none.

The JIT now defines both on its main JITDylib, for every platform and
memory model, over this process's llvm::sys::DynamicLibrary. The
TypeScriptRuntime functions carry the generated names directly, so a
Linux build exports them under those names too.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit d8c883c into main Sep 18, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the drop-llvm-support-runtime-dep branch September 18, 2026 13:36
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