Repository navigation
A library tslang built no longer exports the heap entry points - #784
Merged
Merged
Conversation
Since #779 ProcessHeapExports.inc exported __tslang_heap_malloc, calloc, realloc, free and aligned_alloc from every module that links the async runtime, libraries included. A library's exports become its import library's, so a DLL linking the default library's DLL - which comes first on the link line - took the five from TypeScriptDefaultLib.lib, then pulled ProcessHeap.obj in for -include:__tslang_heap_shared and had each twice: TypeScriptAsyncRuntime.lib(ProcessHeap.obj) : error LNK2005: __tslang_heap_free already defined in TypeScriptDefaultLib.lib(TypeScriptDefaultLib.dll) Any --emit=dll that allocates against a default library rebuilt since #779 failed this way; test-compile-shared-defaultlib-data shows it once that library is built. Only the program's entry points are ever looked up (GetProcAddress on the executable), and the ones that lend a heap - TypeScriptMimalloc's and tslang.exe's under the JIT - are defined and exported apart. These are the process heap, which a library falls back to when the program exports none, so exporting them added nothing. The marker __tslang_heap_shared stays exported. The default library has to be rebuilt for its import library to lose the five. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ASDAlexander77
added a commit
that referenced
this pull request
Nov 8, 2026
…ANG 34-36) (#790) 34: LLVM's UTF-16 to UTF-8 conversion takes a leading U+FEFF for a byte order mark and skips it (and byte-swaps a string starting with U+FFFE), so a string literal starting with that character lost it. Literals are converted as they are. 35 ("\\n" read as a line feed) does not reproduce; the new test covers it. 36: a runtime library older than #784 failed every --emit=dll with a bare LNK2001 for __tslang_heap_shared. tslang checks TypeScriptAsyncRuntime.lib first and says the runtime is older than the compiler. -v is an alias for --verbose, so the linker's "use -v" hint works. Also records the open -mm=own items 31-33 in TSLANG_ISSUES.md. 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.
Since #779,
ProcessHeapExports.incexported__tslang_heap_malloc,calloc,realloc,freeandaligned_allocfrom every module that links the async runtime, libraries included. A library's exports end up in its import library, so a DLL that links the default library's DLL (which comes first on the link line) took the five fromTypeScriptDefaultLib.lib. It then pulled inProcessHeap.objfor-include:__tslang_heap_sharedand had each one twice:Any
--emit=dllbuild that allocates failed this way once the default library had been rebuilt after #779.Fix
The five functions are no longer exported; the
__tslang_heap_sharedmarker still is. Nothing depends on the exports:GetProcAddresson the program's module).tslang.exeunder the JIT.Testing
test-compile-shared-defaultlib-datacovers this bug, but only once the default library has been rebuilt after A library tslang built allocates from the program's heap; mimalloc on Linux #779; with an older build it passes without the fix. Against a rebuilt default library it fails with LNK2005 on the old compiler and passes with this change.new RegExpagainst the default library now links. The rebuilt default library's DLL exports only__tslang_heap_shared.test-compile-mimalloc-heapand the shared-import, default-library and JIT-native tests pass.test-own-facts-objectsandtest-own-keepers-objectsfailed in the parallel run and passed when rerun alone. They check ownership facts at compile time and don't touch the heap code.Every default-library build needs a rebuild for its import library to drop the five exports.
🤖 Generated with Claude Code