Skip to content

Debug builds: the fewer-parameters thunk has a debug location; ___range_check is private to each module - #747

Merged
ASDAlexander77 merged 1 commit into
mainfrom
debug-info-release-fixes
Oct 30, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
debug-info-release-fixes

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Two failures that only a Debug build hits, so PR CI (Release only) can't see them. Both would have failed the next release's Windows Debug default-library pass. I found them by building the Debug default library the way create-release.yml does (TSLANG_DEBUG_CRT=/MT, with the release compiler's libraries) and running the full tests.ps1.

1. --di: the fewer-parameters thunk had no debug location

const ok = [1, 30, 39].every((v) => v < 40);
// error: inlinable function call in a function with a DISubprogram location must have a debug location

This failed in every memory model, in 18 of DefaultLib's tests (array_every, array_map, string_localeCompare, date_parse2, …). Since array callbacks take the element's index too (DefaultLib #59), any one-parameter callback goes through fewerParametersThunk (#733).

Cause. The thunk was built with no location. With --di, the debug-info pass still gave the thunk a subprogram, so the call inside it had no debug location, and LLVM rejected the module.

Fix. The thunk gets its own subprogram at the first place that needs it, with its body scoped under it. This is the same fix alpha85 needed for the catch-copy thunk (mlirGenCatchCopyThunk).

2. Debug link: ___range_check defined twice

TypeScriptDefaultLib.lib(lib.obj) : error LNK2005: ___range_check already defined in map_get-069943.obj

Every program linked against the Debug default library (--emit=exe) failed this way: 43 of its tests in every model.

Cause. The RangeError check (#731) is generated from source as a public function in every module that uses it, the library included. An optimized link drops one copy, which is why Release builds linked.

Fix. The check is now private to each module, with internal linkage, as the thunks are.

Tests

  • New: test-compile-debug-info-glue (debug-info-glue.cmake) emits the two fewer-parameter tests with --di --opt_level=0 under every model. Each makes six thunks. In a Release build test-runner never compiles with --di, which is how A finally that throws during unwinding replaces the exception; fewer-parameter functions as wider function types #733's tests missed this.
  • Results on Windows:
    • ctest: 6420/6420.
    • DefaultLib Release and Debug libraries both build.
    • Full tests.ps1 (Release and Debug passes, compile and JIT, plus the declarations check): gc 182/182, rc 181, none 181, own 171 (11 skipped by design), in both passes.
    • Before this PR the own Debug pass was compile 128/182 and JIT 153/182.

Found on the way, not fixed here

They fail with or without --di and aren't in any test:

  • a.every((v: number) => v < 40) on an s32 array: "can't assign '(p0: number) => boolean' to '(p0: s32, p1: number) => boolean'".
  • a.every(function (v) { return v < 40; }): "'ts.Call' op '.f_main..fe…' does not reference a valid function".

🤖 Generated with Claude Code

…ge_check is private to each module

Two failures only a debug build sees, found building the debug default library as the release
workflow does (`--di --opt_level=0`, TSLANG_DEBUG_CRT=/MT) and running its tests:

- `a.every((v) => v < 40)` - since array callbacks take the element's index too, any one-parameter
  callback - was rejected by LLVM in every model: "inlinable function call in a function with a
  DISubprogram location must have a debug location". fewerParametersThunk (#733) made the thunk with
  no location; with --di the debug-info pass gave it a subprogram and its call had none. It now gets a
  subprogram at the place that first needs it and its body is scoped under it, as the catch copy
  thunk (mlirGenCatchCopyThunk) does.
- A program linked against the debug default library failed with "LNK2005: ___range_check already
  defined": the RangeError check (#731) is generated from source as a public function in every module
  that checks, the library's included. It is private to each module now (internal linkage, as the
  thunks). An optimized link dropped one copy, which is why release builds linked.

test-compile-debug-info-glue (debug-info-glue.cmake): the fewer-parameter tests emitted with
`--di --opt_level=0` under every model - test-runner in a release build never compiles with --di.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 61b93ae into main Oct 30, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the debug-info-release-fixes branch October 30, 2026 01:49
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