Skip to content

[core] Fix Declare failing to autoload symbols for static initializers - #22939

Merged
guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:issue-16601
Jul 29, 2026
Merged

guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:issue-16601

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

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.

@dpiparo dpiparo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this long standing bug! I added a comment and Would like to solicit a statement by @devajithvs or @hahnjo

Comment thread core/metacling/src/TCling.cxx Outdated
@dpiparo
dpiparo requested review from devajithvs and hahnjo July 28, 2026 13:32
Comment thread core/metacling/src/TCling.cxx
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.
@dpiparo

dpiparo commented Jul 29, 2026

Copy link
Copy Markdown
Member

The two failures seem unrelated to the changes proposed in this PR.

@github-actions

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 15h 30m 4s ⏱️
 3 875 tests  3 873 ✅ 0 💤 2 ❌
79 842 runs  79 840 ✅ 0 💤 2 ❌

For more details on these failures, see this check.

Results for commit 1fea5f1.

@devajithvs devajithvs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@guitargeek
guitargeek merged commit 7eca9ea into root-project:master Jul 29, 2026
30 of 34 checks passed
@guitargeek
guitargeek deleted the issue-16601 branch July 29, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[6.32/master] Fail to materialise symbols from libMatrix

3 participants