Skip to content

JIT: load the GC runtime before the default library - #632

Merged
ASDAlexander77 merged 1 commit into
mainfrom
jit-runtime-before-defaultlib
Oct 21, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
jit-runtime-before-defaultlib

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

On Linux, --emit=jit with the default library failed on GC_malloc unless libTypeScriptRuntime.so was passed with --shared-libs.

The default library .so leaves GC_* undefined and takes them from the process. libTypeScriptRuntime.so links Boehm in statically and provides them. That is by design, and no libgc.so is needed: a second copy of the collector would bring back the two-collector bug. But prepareJitProcess added the default library to the load list before the runtime, so it was loaded first and dlopen could not resolve GC_malloc. A runtime passed with --shared-libs sits at the front of the list, which is why the tests never hit this.

  • jit.cpp: the default library goes into the list after the runtime. The duplicate-runtime check and the runtime search order are unchanged. Windows is unaffected: the default library imports gc.dll directly.
  • defaultlib-collector.cmake: the JIT mode gains a Linux-only run without --shared-libs, so tslang finds the runtime itself through --tslang-lib-path. The Linux release job runs this test with TSLANG_REQUIRE_DEFAULT_LIB=1.

Tested: Windows Release, all 2133 test-jit* tests pass, including test-jit-gc-defaultlib-collector with the real default library. The Linux run is checked by the Linux release workflow; it was not run locally.

🤖 Generated with Claude Code

On Linux the default library leaves GC_* undefined and takes them from the
process (TypeScriptRuntime links Boehm in), so it has to be loaded after the
runtime or dlopen fails on GC_malloc. prepareJitProcess added the default
library first; a runtime passed with --shared-libs was ahead of it anyway,
which hid the bug from every test.

The JIT collector test gains a Linux run that leaves the runtime for tslang
to find (--tslang-lib-path).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit b161cd2 into main Oct 21, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the jit-runtime-before-defaultlib branch October 21, 2026 17:40
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