You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Importing a -shared module's export declare C binding crashes #368
Importing a function that a -shared module binds to a C runtime function with export declare crashes the importing program.
// export_declare_linkname.ts - built with -sharednamespaceC{
@linkname("strlen")// @dllname("strlen") behaves the same wayexportdeclarefunctionlen(s: string): index;}
test-runner -shared import_declare_linkname.ts export_declare_linkname.ts compiles both files, then the program faults when it calls C.len.
Cause
The importer re-prints the declaration from __decls as @dllimport @dllname("strlen").
At startup it looks strlen up in the loaded tslang libraries (tslang_search_for_address_of_symbol).
The exporting DLL never contains strlen: nothing in that module calls it, so the unused declaration is dropped.
The lookup returns null, and the call jumps through it.
This is older than @linkname: the @dllname spelling crashes the same way on a 2026-09-23 build.
Test
test-compile-shared-export-import-declare-linkname (added in #366) is registered DISABLED until this is fixed. Its static-link twin, test-compile-export-import-declare-linkname, passes.
Possible fixes:
the importer resolves a declared binding against the process's own symbols, not the tslang library's;
Activity