Repository navigation
JIT: an import pointing to a .ts file is included with its bodies - #404
Merged
Merged
Conversation
mlirGenInclude generated an imported .ts module as declarations only, so a program run on its own (tslang main.ts, JIT) found no bodies for what it imported: 'Symbols not found: [ S..new ]' for new S() of an imported class. An import pointing to a .ts file now includes it with its bodies, like a referenced file; one pointing to a library (lib<name>.so / <name>.dll) still takes them from the library. A .d.ts stays declarations only. Known: test-runner still compiles each imported module into an object of its own and links it beside the importer, so the multi-module export-import, reference-path, shared-class-members and import-bindings tests now fail with 'multiple definition' link errors until the runner stops doing that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VPAHhg8c9NEdoYNw52AtTg
…t, not --shared-libs A library an `import` points to is loaded by the program at run time; passing it with --shared-libs as well is not how it is meant to be used (and matches the Windows runner, which already did not). The 56 test-jit-shared tests pass, including the reference-path diamond/cycle and shared-class-members ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VPAHhg8c9NEdoYNw52AtTg
…e JIT it is included Compiled, each .ts module is an object of its own and the objects are linked into one program, so an import pointing to a .ts file only declares what the module has. Under the JIT there is no other object: the file is included with its bodies. The import-source test now also runs compiled, with the module's object linked beside the program. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VPAHhg8c9NEdoYNw52AtTg
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.
Problem
Under the JIT, a program importing a class from another
.tsfile could not create an instance of it:tslang main.tsfailed withJIT session error: Symbols not found: [ S..new ].mlirGenIncludealways generated an imported.tsmodule as declarations only. Under the JIT nothing else provides the bodies, soS..newwas only declared.S..newwas just the first missing symbol;S.toStringand the vtable had no bodies either.Import rules after this change
.tsfile.dll/.so--emit=obj/exe/dll).tsimport (unchanged)--emit=jit)A
.d.tsfile is read as declarations either way.Changes
MLIRGenModule.cpp(mlirGenInclude):declarationMode = !compileOptions.isJit.test-runner.cpp: in-jit -sharedmode on Linux, the imported library is no longer passed with--shared-libs. Theimportloads it at run time. This matches the Windows runner, which already did this.test/tester/import-source/: the example above as a JIT test (test-jit-import-source-new-imported-class), plus compiled,-sharedand-jit -sharedvariants in which the module is built separately.Testing
Linux, Release build with the prebuilt LLVM 22.1.8: the full
ctestsuite passes (3121 passed, 0 failed, 1 test already disabled). Not built or tested on Windows.🤖 Generated with Claude Code
https://claude.ai/code/session_01VPAHhg8c9NEdoYNw52AtTg
Generated by Claude Code