Repository navigation
Borrow facts: name the symbol after the module's own file (JIT cache duplicate symbol) - #628
Merged
Merged
Conversation
The JIT cache compiles each imported module through runMLIRPasses with isJit off, so the borrow-facts export ran for every import too, but its symbol was named from inputFilename - the main program. Every cached import then defined the same __tsborrow_<main>_<hash>, and the JIT failed to add the second one with a duplicate definition. Take the name from the module's main source buffer instead; for an --emit=obj build that is the same canonical path, so its symbol is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The JIT cache compiles each imported module with isJit off and jitCache on. Those objects are only ever loaded into the JIT, never linked, and the program run there drops imported facts (StackPromotionPass), so the facts they carried were never read. Co-Authored-By: Claude Opus 5.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.
Problem
Since #609, running a program that imports modules under the JIT (with the JIT cache) fails:
The JIT cache compiles each imported module through
runMLIRPasseswithisJitoff (jitcache.cpp), soBorrowFactsExportPassruns for every import. But the symbol name came frominputFilename, which is always the main program. So every cached import defined the same__tsborrow_<main>_<hash>.Fix
transform.cppnow builds the name from the module's main source buffer, which is the file actually being compiled. Stdin (-) still usesinputFilename.moduleSymbolSuffixcanonicalizes the path, so a normal--emit=objbuild gives the same symbol as before.Also: the modules the JIT cache compiles (
isJitoff,jitCacheon) no longer export facts at all. Their objects are only loaded into the JIT, never linked, and the program run there drops imported facts (StackPromotionPass.cpp:58-63), so nothing ever read them.Verified
examples/compute_nbody.ts -- -testunder the JIT: Test PASSED. Before the fix it failed with the error above.__tsborrow_symbol. With the first commit alone, each had its own (__tsborrow_donut_…,__tsborrow_input_pass_…, …).test-borrow-facts-defaultlib.--emit=obj core/args.ts, old vs new compiler: same__tsborrow_args_11047768023027654085and identical facts (--print-borrow-facts).Caches already written by pre-alpha105 hold the bad objects. A new compiler build gets a new compiler id, so it recompiles them.
🤖 Generated with Claude Code