Skip to content

Commit a49e8db

Browse files
committed
[cxxmodules] Add flag if module has C++ module alongside it
1 parent 5b3c6d5 commit a49e8db

File tree

7 files changed

+21
-12
lines changed

7 files changed

+21
-12
lines changed

cmake/modules/RootNewMacros.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ function(ROOT_GENERATE_DICTIONARY dictionary)
366366
endforeach()
367367
endif()
368368

369-
if(runtime_cxxmodules AND ARG_MODULE)
369+
set(runtime_cxxmodules_env)
370+
if(runtime_cxxmodules AND ARG_MODULE AND NOT ARG_MULTIDICT)
370371
# FIXME: Once modules work better, we should use some other value like "1"
371372
# to disable the module-build remarks from clang.
372373
set(runtime_cxxmodules_env "ROOT_MODULES=DEBUG")

core/base/inc/TROOT.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ friend TROOT *ROOT::Internal::GetROOT2();
309309
const char* fwdDeclCode,
310310
void (*triggerFunc)(),
311311
const FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
312-
const char** classesHeaders);
312+
const char** classesHeaders,
313+
bool hasCxxModule = false);
313314
TObject *Remove(TObject*);
314315
void RemoveClass(TClass *);
315316
void Reset(Option_t *option="");

core/base/src/TROOT.cxx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,17 @@ namespace {
258258
const char* fwdDeclCode,
259259
void (*triggerFunc)(),
260260
const TROOT::FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
261-
const char** classesHeaders):
261+
const char** classesHeaders,
262+
bool hasCxxModule):
262263
fModuleName(moduleName),
263264
fHeaders(headers),
264265
fPayloadCode(payloadCode),
265266
fFwdDeclCode(fwdDeclCode),
266267
fIncludePaths(includePaths),
267268
fTriggerFunc(triggerFunc),
268269
fClassesHeaders(classesHeaders),
269-
fFwdNargsToKeepColl(fwdDeclsArgToSkip){}
270+
fFwdNargsToKeepColl(fwdDeclsArgToSkip),
271+
fHasCxxModule(hasCxxModule){}
270272

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

282285
std::vector<ModuleHeaderInfo_t>& GetModuleHeaderInfoBuffer() {
@@ -2477,7 +2480,8 @@ void TROOT::RegisterModule(const char* modulename,
24772480
const char* fwdDeclCode,
24782481
void (*triggerFunc)(),
24792482
const TInterpreter::FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
2480-
const char** classesHeaders)
2483+
const char** classesHeaders,
2484+
bool hasCxxModule)
24812485
{
24822486

24832487
// First a side track to insure proper end of process behavior.
@@ -2540,11 +2544,11 @@ void TROOT::RegisterModule(const char* modulename,
25402544
// Now register with TCling.
25412545
if (gCling) {
25422546
gCling->RegisterModule(modulename, headers, includePaths, payloadCode, fwdDeclCode,
2543-
triggerFunc, fwdDeclsArgToSkip, classesHeaders);
2547+
triggerFunc, fwdDeclsArgToSkip, classesHeaders, hasCxxModule);
25442548
} else {
25452549
GetModuleHeaderInfoBuffer()
25462550
.push_back(ModuleHeaderInfo_t (modulename, headers, includePaths, payloadCode, fwdDeclCode,
2547-
triggerFunc, fwdDeclsArgToSkip,classesHeaders));
2551+
triggerFunc, fwdDeclsArgToSkip,classesHeaders, hasCxxModule));
25482552
}
25492553
}
25502554

core/dictgen/src/TModuleGenerator.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ void TModuleGenerator::WriteRegistrationSource(std::ostream &out,
462462
" if (!isInitialized) {\n"
463463
" TROOT::RegisterModule(\"" << GetDemangledDictionaryName() << "\",\n"
464464
" headers, includePaths, payloadCode, fwdDeclCode,\n"
465-
" TriggerDictionaryInitialization_" << GetDictionaryName() << "_Impl, " << fwdDeclnArgsToKeepString << ", classesHeaders);\n"
465+
" TriggerDictionaryInitialization_" << GetDictionaryName() << "_Impl, " << fwdDeclnArgsToKeepString << ", classesHeaders, " << (fCI->getLangOpts().Modules ? "/*has C++ module*/true" : "/*has no C++ module*/false") <<");\n"
466466
" isInitialized = true;\n"
467467
" }\n"
468468
" }\n"

core/meta/inc/TInterpreter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ class TInterpreter : public TNamed {
154154
void (* /*triggerFunc*/)(),
155155
const FwdDeclArgsToKeepCollection_t& fwdDeclArgsToKeep,
156156
const char** classesHeaders,
157-
Bool_t lateRegistration = false) = 0;
157+
Bool_t lateRegistration = false,
158+
Bool_t hasCxxModule = false) = 0;
158159
virtual void RegisterTClassUpdate(TClass *oldcl,DictFuncPtr_t dict) = 0;
159160
virtual void UnRegisterTClassUpdate(const TClass *oldcl) = 0;
160161
virtual Int_t SetClassSharedLibs(const char *cls, const char *libs) = 0;

core/metacling/src/TCling.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,8 @@ void TCling::RegisterModule(const char* modulename,
16771677
void (*triggerFunc)(),
16781678
const FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
16791679
const char** classesHeaders,
1680-
Bool_t lateRegistration /*=false*/)
1680+
Bool_t lateRegistration /*=false*/,
1681+
Bool_t hasCxxModule /*=false*/)
16811682
{
16821683
// rootcling also uses TCling for generating the dictionary ROOT files.
16831684
static const bool fromRootCling = dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym");
@@ -1918,7 +1919,7 @@ void TCling::RegisterModule(const char* modulename,
19181919
clang::Sema &TheSema = fInterpreter->getSema();
19191920

19201921
bool ModuleWasSuccessfullyLoaded = false;
1921-
if (TheSema.getLangOpts().Modules) {
1922+
if (hasCxxModule) {
19221923
std::string ModuleName = llvm::StringRef(modulename).substr(3).str();
19231924
ModuleWasSuccessfullyLoaded = LoadModule(ModuleName, *fInterpreter);
19241925
if (!ModuleWasSuccessfullyLoaded) {

core/metacling/src/TCling.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ class TCling : public TInterpreter {
205205
void (*triggerFunc)(),
206206
const FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
207207
const char** classesHeaders,
208-
Bool_t lateRegistration = false);
208+
Bool_t lateRegistration = false,
209+
Bool_t hasCxxModule = false);
209210
void RegisterTClassUpdate(TClass *oldcl,DictFuncPtr_t dict);
210211
void UnRegisterTClassUpdate(const TClass *oldcl);
211212

0 commit comments

Comments
 (0)