Fix nightlies by autoload dependency libraries

We had test failures in runtime nightlies such as this one:
https://epsft-jenkins.cern.ch/view/ROOT/job/root-nightly-runtime-cxxmodules/95/BUILDTYPE=Debug,COMPILER=gcc62,LABEL=slc6/testReport/junit/projectroot.roottest.root.math/smatrix/roottest_root_math_smatrix_testKalman/

Failures were due to what @pcanal commented in #2135, that some so files in
roottest doesn't have external linkage. (It means that if you call
    dlopen(libfoo.so), linux kernel can't find dependency libraries and it
    emits "undefined symbol" error when they try to initialize global
    variables in libfoo.so but couldn't find symbol definition)
With pch, rootmap files were providing information about the depending library.

However we stopped generating rootmap files in #2127 and that's why we
got these failures. To fix this issue, I implemented a callback to
TCling which gets called when DynamicLibraryManager fails. The callback
pass error message to TCling and it handles message if it contains "undefined error".
This commit is contained in:
Yuka Takahashi 2018-06-05 16:28:51 +02:00 committed by sftnight
parent 2d17c46c83
commit befa982fe3
3 changed files with 21 additions and 0 deletions

View File

@ -125,6 +125,12 @@ namespace cling {
virtual bool LookupObject(const clang::DeclContext*, clang::DeclarationName);
virtual bool LookupObject(clang::TagDecl*);
/// \brief This callback is invoked whenever the interpreter failed to load a library.
///
/// \param[in] - Error message and parameters passed to loadLibrary
/// \returns true if the error was handled.
virtual bool LibraryLoadingFailed(const std::string&, const std::string&, bool, bool) { return 0; }
///\brief This callback is invoked whenever interpreter has committed new
/// portion of declarations.
///

View File

@ -206,6 +206,12 @@ namespace cling {
std::string errMsg;
DyLibHandle dyLibHandle = platform::DLOpen(canonicalLoadedLib, &errMsg);
if (!dyLibHandle) {
// We emit callback to LibraryLoadingFailed when we get error with error message.
if (InterpreterCallbacks* C = getCallbacks()) {
if (C->LibraryLoadingFailed(errMsg, libStem, permanent, resolved))
return kLoadLibSuccess;
}
cling::errs() << "cling::DynamicLibraryManager::loadLibrary(): " << errMsg
<< '\n';
return kLoadLibLoadError;

View File

@ -77,6 +77,15 @@ namespace cling {
}
}
bool LibraryLoadingFailed(const std::string& errmessage, const std::string& libStem, bool permanent,
bool resolved) override {
for (auto&& cb : m_Callbacks) {
if (bool res = cb->LibraryLoadingFailed(errmessage, libStem, permanent, resolved))
return res;
}
return 0;
}
void TransactionUnloaded(const Transaction& T) override {
for (auto&& cb : m_Callbacks) {
cb->TransactionUnloaded(T);