root-project / root

The official repository for ROOT: analyzing, storing and visualizing big data, scientifically
https://root.cern
Other
2.72k stars 1.3k forks source link

module.idx creation can easily cause missing symbols #12988

Open Axel-Naumann opened 1 year ago

Axel-Naumann commented 1 year ago

Check duplicate issues.

Describe the bug

In an ongoing development we have an external pulled into a header (SYCL related); that header has a static variable. JITting that header triggers static initialization which need the library to be loaded to resolve the symbol. That library doesn't get loaded when generating module.idx causing a missing symbol. (We had a similar case with Vc in the past, IIRC.)

What is the expected behaviour?

No error message when generating module.idx.

How to reproduce?

This can be reproduced with a modified ROOT:

diff --git a/tree/dataframe/inc/ROOT/RDataFrame.hxx b/tree/dataframe/inc/ROOT/RDataFrame.hxx
index 7a094cc01f..d74c69aa2b 100644
--- a/tree/dataframe/inc/ROOT/RDataFrame.hxx
+++ b/tree/dataframe/inc/ROOT/RDataFrame.hxx
@@ -73,4 +73,6 @@ namespace cling {
 std::string printValue(ROOT::RDataFrame *tdf);
 } // ns cling

+static ROOT::RDataFrame thisWillBeBadForTheModulesIdx(17);
+
 #endif // ROOT_RDATAFRAME

This causes

[522/527] Generating lib/modules.idx
[runStaticInitializersOnce]: Failed to materialize symbols: { (main, { __cxx_global_var_initcling_module_1_.2, __cxx_global_var_initcling_module_1_, _ZL29thisWillBeBadForTheModulesIdx, _ZN4ROOT8InternalL13gVersionCheckE, $.cling-module-1.__inits.0, _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_releaseEv, _ZNSt10shared_ptrIN4ROOT6Detail3RDF12RLoopManagerEED2Ev, _ZNSt12__shared_ptrIN4ROOT6Detail3RDF12RLoopManagerELN9__gnu_cxx12_Lock_policyE2EED2Ev, _ZN4ROOT10RDataFrameD2Ev, _ZN4ROOT3RDF10RInterfaceINS_6Detail3RDF12RLoopManagerEvED2Ev, _ZN4ROOT10RDataFrameD1Ev, _ZN4ROOT3RDF14RInterfaceBaseD2Ev, _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE19_M_release_last_useEv, _GLOBAL__sub_I_cling_module_1, _ZNSt10shared_ptrIN4ROOT6Detail3RDF12RLoopManagerEED1Ev, _ZNSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EED2Ev, _ZStL8__ioinit, __cxx_global_var_initcling_module_1_.1, _ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE24_M_release_last_use_coldEv, __orc_init_func.cling-module-1, _ZNSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EED1Ev }) }

[523/527] Generating tutorials/hsimple.root

Processing hsimple.C...
hsimple   : Real Time =   0.04 seconds Cpu Time =   0.04 seconds
(TFile *) 0x56335b1cf6e0
[527/527] Linking CXX executable tree/dataframe/test/dataframe_simple

As you can see, the RDataFrame library is built happily, no missing symbols. Yet the JIT complains because it cannot load the library.

ROOT version

master + modification

How did you install ROOT?

built myself

Which operating system are you using?

Ubuntu 22.04

Additional context

No response

Axel-Naumann commented 1 year ago

What would happen if we provide a new flag to ROOT signalling that we are building module.idx, and then not actually use the execution engine (just like we do in rootcling)?