Skip to content

Commit

Permalink
[TCling] Invoke InterOp interpreter API in metacling
Browse files Browse the repository at this point in the history
This uses provides InterOp with the TInterpreter instance created by ROOT in TCling.
The InterOp API can now be used without providing interpreter ownership.
  • Loading branch information
aaronj0 committed Dec 2, 2024
1 parent 6e0e6da commit ef871f9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion core/metacling/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ if(MSVC)
endif()

add_dependencies(MetaCling CLING clangCppInterOp)
# target_include_directories(MetaCling SYSTEM PUBLIC ${source_dir}/include/)

##### libCling #############################################################

Expand Down
8 changes: 8 additions & 0 deletions core/metacling/src/TCling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ clang/LLVM technology.
#include "cling/Utils/SourceNormalization.h"
#include "cling/Interpreter/Exception.h"

#include "clang/Interpreter/CppInterOp.h"

#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Module.h"

Expand Down Expand Up @@ -1612,6 +1614,12 @@ TCling::TCling(const char *name, const char *title, const char* const argv[], vo
// Initialize the dyld for AutoloadLibraryGenerator.
DLM.initializeDyld(ShouldPermanentlyIgnore);
}

// Tell CppInterOp that the cling::Interpreter instance is managed externally by ROOT
// We pass the handle so it sets the ownership flags and sets the interpreter as soon as TCling is initialized
if (!Cpp::GetInterpreter()) {
Cpp::UseExternalInterpreter((Cpp::TInterp_t*)fInterpreter.get());
}
}


Expand Down
2 changes: 2 additions & 0 deletions core/metacling/src/TClingCallFunc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ C++ interpreter and the Clang C++ compiler, not CINT.

#include "clang/Sema/SemaInternal.h"

#include "clang/Interpreter/CppInterOp.h"

#include <map>
#include <string>
#include <sstream>
Expand Down

0 comments on commit ef871f9

Please sign in to comment.