Repository navigation
[core] Fix Declare failing to autoload symbols for static initializers - #22939
Merged
Merged
Conversation
dpiparo
reviewed
Jul 28, 2026
dpiparo
left a comment
Member
There was a problem hiding this comment.
Thanks for fixing this long standing bug! I added a comment and Would like to solicit a statement by @devajithvs or @hahnjo
devajithvs
requested changes
Jul 28, 2026
TInterpreter::Declare of a global whose static initializer needs symbols from a not-yet-loaded library (e.g. TVectorT<float> from libMatrix) failed with "Failed to materialize symbols". It worked in 6.30 but regressed in 6.32. Declare wraps parsing in a SuspendAutoLoadingRAII to behave like a plain compiler; that is a parse-time, class/dictionary-autoloading concern. But commit e601bf8 ("Reduce symbol search only to when autoloading is enabled", first released in 6.32) gated the AutoloadLibraryGenerator ORC definition generator on IsAutoLoadingEnabled() for performance, which inadvertently coupled the two: during Declare the global's static initializer runs, the JIT needs the constructor symbol from libMatrix, and the generator bailed out because class autoloading was suspended. The generator's gate cannot be relaxed for all Static lookups: a passive address query such as TGlobal::GetAddress() also issues a Static lookup, and it must keep returning "not loaded" while autoloading is suspended (see the gGeoManager check in TClingDataMemberInfo.Offset). The distinguishing factor is that the issue's suspension is Declare-internal, not a user request. Therefore let Declare opt back into JIT symbol autoloading for exactly the window where it emits and runs code, via a dedicated TClingCallbacks::IsAutoLoadingForJITSymbols() flag the generator also honors. Passive lookups outside Declare are unaffected, so the gGeoManager semantics are preserved. Closes root-project#16601. 🤖 Done with the help of AI.
Member
|
The two failures seem unrelated to the changes proposed in this PR. |
Test Results 23 files 23 suites 3d 15h 30m 4s ⏱️ For more details on these failures, see this check. Results for commit 1fea5f1. |
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.
TInterpreter::Declare of a global whose static initializer needs symbols from a not-yet-loaded library (e.g. TVectorT from libMatrix) failed with "Failed to materialize symbols". It worked in 6.30 but regressed in 6.32.
Declare wraps parsing in a SuspendAutoLoadingRAII to behave like a plain compiler. That is a parse-time, class/dictionary-autoloading concern. But commit e601bf8 ("Reduce symbol search only to when autoloading is enabled", first released in 6.32) gated the AutoloadLibraryGenerator ORC definition generator on IsAutoLoadingEnabled() for performance, which inadvertently coupled the two: during Declare the global's static initializer runs, the JIT needs the constructor symbol from libMatrix, and the generator bailed out because class autoloading was suspended.
Gate the generator on the lookup kind instead: only skip the (costly) library scan for speculative DLSym probes, never for Static lookups, i.e. symbols genuinely required to link and run JITed code. This mirrors LLVM's own DynamicLibrarySearchGenerator / StaticLibraryDefinitionGenerator, which act only on Static lookups, and preserves the performance intent of the original gate.
Closes #16601.
🤖 Done with the help of AI.