Stop linking LLVMSupport and LLVMDemangle into compiled programs - #333
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Compiled programs no longer link any LLVM library. Two things used to require it:
AsyncRuntimeCommon.incusedllvm::DefaultThreadPool. It now has its ownstd::threadpool that behaves the same way: one worker per hardware thread, started on demand, andwait()covers tasks queued by other tasks. The JIT's runtime shares this file.LLVMLoadLibraryPermanently/LLVMSearchForAddressOfSymbol. Those calls are renamed totslang_load_library_permanently/tslang_search_for_address_of_symbol:TypeScriptAsyncRuntime/DynamicRuntime.cppdefines them:LoadLibraryW/GetProcAddresson Windows,dlopen/dlsymon Linux. Like LLVM, it loads each library once and searches symbols in load order.TypeScriptRuntimeexports them under the new names (.defand the export table).The driver, test runner, generated CMake template and
docs/how/debug/debug-shared.batno longer link LLVMSupport, LLVMDemangle,ntdllor-ltinfo. The last two were only there for LLVMSupport.--llvm-lib-path/LLVM_LIB_PATHare still accepted but ignored, so CI, the default-lib build scripts and existing user scripts keep working.Test plan
llvm-nm:TypeScriptAsyncRuntime.liband the default lib (gc/rc/none) need no LLVM symbols.tslang --emit=exebuilds and runs async programs withLLVM_LIB_PATHunset.ntdll.lib.dlopenpath, 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