Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[cxxmodules] Only load modules if one was generated
If we generate a dictionary with a C++ module with rootcling we
should write in the payload that we generated a C++ module.
This way we can actually print a *reliable* warning when we fail
to load the C++ module during runtime. Without this we can only
speculate if a missing C++ module is intentional.
  • Loading branch information
Teemperor committed Dec 13, 2017
commit 37d34a5ccd2128f82a2ec12f1878b112a2e2a67b
3 changes: 2 additions & 1 deletion core/base/inc/TROOT.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ friend TROOT *ROOT::Internal::GetROOT2();
const char* fwdDeclCode,
void (*triggerFunc)(),
const FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
const char** classesHeaders);
const char** classesHeaders,
bool hasCxxModule = false);
TObject *Remove(TObject*);
void RemoveClass(TClass *);
void Reset(Option_t *option="");
Expand Down
23 changes: 14 additions & 9 deletions core/base/src/TROOT.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,17 @@ namespace {
const char* fwdDeclCode,
void (*triggerFunc)(),
const TROOT::FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
const char** classesHeaders):
const char **classesHeaders,
bool hasCxxModule):
fModuleName(moduleName),
fHeaders(headers),
fPayloadCode(payloadCode),
fFwdDeclCode(fwdDeclCode),
fIncludePaths(includePaths),
fTriggerFunc(triggerFunc),
fClassesHeaders(classesHeaders),
fFwdNargsToKeepColl(fwdDeclsArgToSkip){}
fFwdNargsToKeepColl(fwdDeclsArgToSkip),
fHasCxxModule(hasCxxModule) {}

const char* fModuleName; // module name
const char** fHeaders; // 0-terminated array of header files
Expand All @@ -277,6 +279,7 @@ namespace {
const char** fClassesHeaders; // 0-terminated list of classes and related header files
const TROOT::FwdDeclArgsToKeepCollection_t fFwdNargsToKeepColl; // Collection of
// pairs of template fwd decls and number of
bool fHasCxxModule; // Whether this module has a C++ module alongside it.
};

std::vector<ModuleHeaderInfo_t>& GetModuleHeaderInfoBuffer() {
Expand Down Expand Up @@ -2068,7 +2071,8 @@ void TROOT::InitInterpreter()
li->fTriggerFunc,
li->fFwdNargsToKeepColl,
li->fClassesHeaders,
kTRUE /*lateRegistration*/);
kTRUE /*lateRegistration*/,
li->fHasCxxModule);
}
GetModuleHeaderInfoBuffer().clear();

Expand Down Expand Up @@ -2477,7 +2481,8 @@ void TROOT::RegisterModule(const char* modulename,
const char* fwdDeclCode,
void (*triggerFunc)(),
const TInterpreter::FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
const char** classesHeaders)
const char** classesHeaders,
bool hasCxxModule)
{

// First a side track to insure proper end of process behavior.
Expand Down Expand Up @@ -2539,12 +2544,12 @@ void TROOT::RegisterModule(const char* modulename,

// Now register with TCling.
if (gCling) {
gCling->RegisterModule(modulename, headers, includePaths, payloadCode, fwdDeclCode,
triggerFunc, fwdDeclsArgToSkip, classesHeaders);
gCling->RegisterModule(modulename, headers, includePaths, payloadCode, fwdDeclCode, triggerFunc,
fwdDeclsArgToSkip, classesHeaders, false, hasCxxModule);
} else {
GetModuleHeaderInfoBuffer()
.push_back(ModuleHeaderInfo_t (modulename, headers, includePaths, payloadCode, fwdDeclCode,
triggerFunc, fwdDeclsArgToSkip,classesHeaders));
GetModuleHeaderInfoBuffer().push_back(ModuleHeaderInfo_t(modulename, headers, includePaths, payloadCode,
fwdDeclCode, triggerFunc, fwdDeclsArgToSkip,
classesHeaders, hasCxxModule));
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/dictgen/src/TModuleGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ void TModuleGenerator::WriteRegistrationSource(std::ostream &out,
" if (!isInitialized) {\n"
" TROOT::RegisterModule(\"" << GetDemangledDictionaryName() << "\",\n"
" headers, includePaths, payloadCode, fwdDeclCode,\n"
" TriggerDictionaryInitialization_" << GetDictionaryName() << "_Impl, " << fwdDeclnArgsToKeepString << ", classesHeaders);\n"
" TriggerDictionaryInitialization_" << GetDictionaryName() << "_Impl, " << fwdDeclnArgsToKeepString << ", classesHeaders, " << (fCI->getLangOpts().Modules ? "/*has C++ module*/true" : "/*has no C++ module*/false") << ");\n"
" isInitialized = true;\n"
" }\n"
" }\n"
Expand Down
3 changes: 2 additions & 1 deletion core/meta/inc/TInterpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ class TInterpreter : public TNamed {
void (* /*triggerFunc*/)(),
const FwdDeclArgsToKeepCollection_t& fwdDeclArgsToKeep,
const char** classesHeaders,
Bool_t lateRegistration = false) = 0;
Bool_t lateRegistration = false,
Bool_t hasCxxModule = false) = 0;
virtual void RegisterTClassUpdate(TClass *oldcl,DictFuncPtr_t dict) = 0;
virtual void UnRegisterTClassUpdate(const TClass *oldcl) = 0;
virtual Int_t SetClassSharedLibs(const char *cls, const char *libs) = 0;
Expand Down
5 changes: 3 additions & 2 deletions core/metacling/src/TCling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,8 @@ void TCling::RegisterModule(const char* modulename,
void (*triggerFunc)(),
const FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
const char** classesHeaders,
Bool_t lateRegistration /*=false*/)
Bool_t lateRegistration /*=false*/,
Bool_t hasCxxModule /*=false*/)
{
const bool fromRootCling = IsFromRootCling();
// We need the dictionary initialization but we don't want to inject the
Expand Down Expand Up @@ -1913,7 +1914,7 @@ void TCling::RegisterModule(const char* modulename,
clang::Sema &TheSema = fInterpreter->getSema();

bool ModuleWasSuccessfullyLoaded = false;
if (TheSema.getLangOpts().Modules) {
if (hasCxxModule) {
std::string ModuleName = llvm::StringRef(modulename).substr(3).str();
ModuleWasSuccessfullyLoaded = LoadModule(ModuleName, *fInterpreter);
if (!ModuleWasSuccessfullyLoaded) {
Expand Down
3 changes: 2 additions & 1 deletion core/metacling/src/TCling.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ class TCling : public TInterpreter {
void (*triggerFunc)(),
const FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
const char** classesHeaders,
Bool_t lateRegistration = false);
Bool_t lateRegistration = false,
Bool_t hasCxxModule = false);
void RegisterTClassUpdate(TClass *oldcl,DictFuncPtr_t dict);
void UnRegisterTClassUpdate(const TClass *oldcl);

Expand Down