Repository navigation
A library's modules are declared whatever order its symbol table lists them in - #834
Merged
Merged
Conversation
…s them in A -shared library of several modules carries a __decls_<module> for each, and they name each other's classes (one module's State holds the Profiler another declares). The importer parsed them in the order the library's symbol table listed them and gave up at the first that named a class not declared yet: "can't find type by name: Profiler". A DLL lists them by name, an ELF shared object as the linker laid it out - which is how test-compile-shared-import-chain-rtti- skipped failed with Ubuntu 26.04's binutils (rtti_middle listed before rtti_bottom) and passed with 22.04's and on Windows (rtti_bottom < rtti_middle by name). Now a module's declarations that fail are read again after the others; only a pass that declares none of them fails the import. Test: import-chain-decl-order, rtti_skipped_import.ts with the modules named the other way round (order_a_saves, order_m_state, order_z_profiler), which failed on Windows too. 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.
test-compile-shared-import-chain-rtti-skippedfailed every run on Ubuntu 26.04 (WSL) withcan't find type by name: Profiler. It passed on Windows and on CI's Ubuntu 22.04.Cause
A
-sharedlibrary of several modules carries one__decls_<module>per module, and their declarations name each other's classes:rtti_middle'sStateholdsrtti_bottom'sProfiler.mlirGenImportSharedLibparsed them in the order the library's symbol table lists them, and gave up at the first one that named a class not yet declared. That order isn't something the program controls:rtti_bottom<rtti_middle.__decls_rtti_middlebefore__decls_rtti_bottom; 22.04's did not.So the same failure happens on Windows whenever a module sorts by name before a module it depends on.
Fix
The import collects the library's declaration texts first, then parses them in passes. A module whose declarations fail is read again after the others, and the import fails only if a pass declares none of the remaining ones; the last pass's errors explain why. Generic declarations still come first.
Test
import-chain-decl-order(compile, compile-shared, JIT-shared) isrtti_skipped_import.tswith its modules named the other way round:order_a_saves,order_m_state,order_z_profiler. Before this change it failed on Windows with the same "can't find type by name: Profiler" (checked with the previous compiler build).Verified locally
rtti-skipped.🤖 Generated with Claude Code