From 436d4b7cdfe31f3430d67b95c5d622d6ae9208ed Mon Sep 17 00:00:00 2001 From: ASDAlexander77 Date: Sun, 5 Jul 2026 01:17:35 +0100 Subject: [PATCH 1/2] Fall back to tslang lib path when locating GC runtime for JIT If the runtime lib isn't found via the default lib path, try the tslang lib path before giving up, instead of silently continuing with no shared lib loaded. --- tslang/tslang/jit.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tslang/tslang/jit.cpp b/tslang/tslang/jit.cpp index 341620fd9..c9bb8c4f4 100644 --- a/tslang/tslang/jit.cpp +++ b/tslang/tslang/jit.cpp @@ -38,6 +38,7 @@ extern cl::opt inputFilename; extern cl::opt TargetTriple; std::string getDefaultLibPath(); +std::string getTslangLibPath(); std::string mergeWithDefaultLibPath(std::string, std::string); std::string makeAbsolutePath(std::string); @@ -144,11 +145,20 @@ int runJit(int argc, char **argv, mlir::ModuleOp module, CompileOptions &compile auto absPath2 = makeAbsolutePath(pathTypeScriptLib); if (absPath2.empty()) { - /* - llvm::WithColor::error(llvm::errs(), "tslang") << "JIT initialization failed. Missing GC library. Did you forget to provide it via " - "'--shared-libs=" LIB_NAME "TypeScriptRuntime." LIB_EXT "'? or you can switch it off by using '-nogc'\n"; - return -1; - */ + // default lib path + auto absPath3 = mergeWithDefaultLibPath(getTslangLibPath(), pathTypeScriptLib); + if (absPath3.empty()) + { + /* + llvm::WithColor::error(llvm::errs(), "tslang") << "JIT initialization failed. Missing GC library. Did you forget to provide it via " + "'--shared-libs=" LIB_NAME "TypeScriptRuntime." LIB_EXT "'? or you can switch it off by using '-nogc'\n"; + return -1; + */ + } + else + { + clSharedLibs.push_back(absPath3); + } } else { From e44b8d4b50059da86696c525f6ddf30c869b0e60 Mon Sep 17 00:00:00 2001 From: ASDAlexander77 Date: Sun, 5 Jul 2026 01:25:36 +0100 Subject: [PATCH 2/2] Refactor JIT library path resolution for improved fallback handling --- tslang/tslang/jit.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/tslang/tslang/jit.cpp b/tslang/tslang/jit.cpp index c9bb8c4f4..837577449 100644 --- a/tslang/tslang/jit.cpp +++ b/tslang/tslang/jit.cpp @@ -138,36 +138,35 @@ int runJit(int argc, char **argv, mlir::ModuleOp module, CompileOptions &compile std::string pathTypeScriptLib("../lib/" LIB_NAME "TypeScriptRuntime." LIB_EXT); if (!disableGC.getValue()) { - auto absPath = makeAbsolutePath(pathTypeScriptLib); - if (absPath.empty()) - { - pathTypeScriptLib = LIB_NAME "TypeScriptRuntime." LIB_EXT; - auto absPath2 = makeAbsolutePath(pathTypeScriptLib); - if (absPath2.empty()) - { - // default lib path - auto absPath3 = mergeWithDefaultLibPath(getTslangLibPath(), pathTypeScriptLib); - if (absPath3.empty()) + auto absPath3 = makeAbsolutePath(mergeWithDefaultLibPath(getTslangLibPath(), LIB_NAME "TypeScriptRuntime." LIB_EXT)); + if (absPath3.empty()) + { + auto absPath = makeAbsolutePath(pathTypeScriptLib); + if (absPath.empty()) + { + pathTypeScriptLib = LIB_NAME "TypeScriptRuntime." LIB_EXT; + auto absPath2 = makeAbsolutePath(pathTypeScriptLib); + if (absPath2.empty()) { /* llvm::WithColor::error(llvm::errs(), "tslang") << "JIT initialization failed. Missing GC library. Did you forget to provide it via " "'--shared-libs=" LIB_NAME "TypeScriptRuntime." LIB_EXT "'? or you can switch it off by using '-nogc'\n"; return -1; */ - } + } else { - clSharedLibs.push_back(absPath3); + clSharedLibs.push_back(absPath2); } - } + } else { - clSharedLibs.push_back(absPath2); + clSharedLibs.push_back(absPath); } - } + } else { - clSharedLibs.push_back(absPath); + clSharedLibs.push_back(absPath3); } }