Repository navigation
Linux --emit=exe: read the default library's facts from the archive its ld script names - #748
Merged
Merged
Conversation
…ts ld script names The v0.0-pre-alpha111 release run failed on every Linux job: DefaultLib's tests under -mm=own, compile pass only (release and debug 135/182; the JIT and Windows passed), with errors inside lib.generics.ts - "'this value' borrows a field but is used here after it may be released or overwritten", "'this value' borrows 'this._entries' ...". On Linux libTypeScriptDefaultLib.a is a GNU ld script, `INPUT(-lTypeScriptDefaultLibCore -lcurl)` (the default library's build.sh). readOwnFacts and readBorrowFacts read the facts of the static library an --emit=exe program links from that file: not an archive, so none. Under own every call into the library could then destroy anything. The JIT reads the shared library, which is why it passed. Windows reproduces the errors with the own facts left out. staticDefaultLibFactsFile: for a file that is not a link input, the archive of the first `-l` its INPUT(...) names that sits beside it; anything else is itself. The link is unchanged - the script, its folder searched (exe.cpp) - so the archive read is the archive linked. 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.
Why
The
v0.0-pre-alpha111release run (40988118886) failed on every Linux job in "Test Default Library". The failures were in DefaultLib's tests under-mm=own, compile pass only: 135/182 compiled, in both release and debug. The JIT pass and Windows passed. The errors came from insidelib.generics.ts, for example:Cause
On Linux,
libTypeScriptDefaultLib.ais a GNU ld script,INPUT(-lTypeScriptDefaultLibCore -lcurl)(DefaultLib'sbuild.sh). Under--emit=exe,readOwnFactsandreadBorrowFactsread the default library's facts from that file. It isn't an archive, so they found no facts. Without facts, own must assume any call into the library can destroy anything. The JIT reads the shared library instead, which is why its pass was clean.Fix
staticDefaultLibFactsFile(tslang/tslang/borrowfacts.cpp) handles a default library that is not a link input itself. It reads the facts from the archive of the first-lthat the script'sINPUT(...)names, if that archive sits next to the script. Any other file is read as before. Linking is unchanged:exe.cppstill links the script and searches its folder, so the archive the facts come from is the archive that gets linked.Testing
tests.sh own. All four passes (release and debug, compiled and JIT) gave 171/182, with the usual 11 not-own skips.array_class_shared.tswith--emit=exe -mm=owngives 1 error without the fix and 0 with it.lib.generics.ts:662:16error. That probe was temporary and has been reverted.🤖 Generated with Claude Code