Skip to content

Commit 3e75e26

Browse files
committed
[cxxmodules] Also preload TMVA/TreePlayer/Graf
ROOT can't autoparse classes inside namespaces with the rootmap system (as the loading callbacks don't correctly land where they are supposed to land with our injected namespaces). As this turns out to be a feature of some kind, let's preload TMVA/TreePlayer/Graf to fix all failing tests that are related to this feature/bug with modules enabled. This commit can be dropped if we solve on of those problems: 1. figure out how to fix this bug in the rootmap-based loading without regressin in performance. 2. replace the rootmap system with something else like attaching all C++ modules on startup. Note that we already do something like this in normal ROOT by including these packages into the PCH which also makes those decls available in the normal clang lookup.
1 parent 7e13899 commit 3e75e26

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,11 @@ endif()
343343

344344
if(runtime_cxxmodules)
345345
# Dummy target that does nothing, we don't need a PCH for modules.
346-
add_custom_target(onepcm)
346+
# However, we require that TMVA/Graf/Treeplayer are built here as
347+
# we will always load them to workaround the fact that we can't
348+
# load the decls in them via rootmap files (as they are inside
349+
# namespaces which isn't supported).
350+
add_custom_target(onepcm DEPENDS TreePlayer TMVA Graf)
347351
else()
348352
add_custom_command(OUTPUT etc/allDict.cxx.pch
349353
COMMAND ${CMAKE_COMMAND} -E env ROOTIGNOREPREFIX=1 ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/etc/dictpch/makepch.py etc/allDict.cxx.pch ${__allIncludes} -I${CMAKE_BINARY_DIR}/include

core/metacling/src/TCling.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,11 @@ TCling::~TCling()
13791379
void TCling::Initialize()
13801380
{
13811381
fClingCallbacks->Initialize();
1382+
if (fInterpreter->getCI()->getLangOpts().Modules && !isFromRootCling()) {
1383+
// Load modules that we can't automatically load via rootmap files as they
1384+
// contain decls in namespaces which aren't supported.
1385+
LoadModules({"TMVA", "TreePlayer", "Graf"}, *fInterpreter);
1386+
}
13821387
}
13831388

13841389
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)