From 6f4dfae7d77f7b8501a9e775f0512d03a50d1f84 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Sat, 25 Nov 2017 03:08:13 -0800 Subject: [PATCH 01/21] [cxxmodules] Refactor LoadCoreModules. NFC beside fixing the nullptr deref's in the previous LoadCoreModules implementation. --- core/metacling/src/TCling.cxx | 86 +++++++++++++++-------------------- 1 file changed, 37 insertions(+), 49 deletions(-) diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index e0e343ad6c12e..eff582880a85a 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1065,8 +1065,10 @@ inline bool TCling::TUniqueString::Append(const std::string& str) return notPresent; } +//////////////////////////////////////////////////////////////////////////////// ///\returns true if the module was loaded. -static bool LoadModule(const std::string &ModuleName, cling::Interpreter &interp) { +static bool LoadModule(const std::string &ModuleName, cling::Interpreter &interp, bool Complain = true) +{ clang::CompilerInstance &CI = *interp.getCI(); assert(CI.getLangOpts().Modules && "Function only relevant when C++ modules are turned on!"); @@ -1080,57 +1082,30 @@ static bool LoadModule(const std::string &ModuleName, cling::Interpreter &interp clang::IdentifierInfo *II = PP.getIdentifierInfo(M->Name); SourceLocation ValidLoc = M->DefinitionLoc; bool success = !CI.getSema().ActOnModuleImport(ValidLoc, ValidLoc, std::make_pair(II, ValidLoc)).isInvalid(); - // Also make the module visible in the preprocessor to export its macros. - PP.makeModuleVisible(M, ValidLoc); - return success; + if (success) { + // Also make the module visible in the preprocessor to export its macros. + PP.makeModuleVisible(M, ValidLoc); + return success; + } + if (Complain) { + if (M->IsSystem) + Error("TCling::LoadModule", "Module %s failed to load", M->Name.c_str()); + else + Info("TCling::LoadModule", "Module %s failed to load", M->Name.c_str()); + } } + if (Complain) + Error("TCling::LoadModule", "Module %s not found!", ModuleName.c_str()); return false; } //////////////////////////////////////////////////////////////////////////////// -/// Loads the basic C++ modules that we require to run any ROOT program. -/// This is just supposed to make the declarations in their headers available -/// to the interpreter. -static void LoadCoreModules(cling::Interpreter &interp) +/// Loads the C++ modules that we require to run any ROOT program. This is just +/// supposed to make a C++ module from a modulemap available to the interpreter. +static void LoadModules(const std::vector &modules, cling::Interpreter &interp) { - clang::CompilerInstance &CI = *interp.getCI(); - // Without modules, this function is just a no-op. - if (!CI.getLangOpts().Modules) - return; - - clang::HeaderSearch &headerSearch = CI.getPreprocessor().getHeaderSearchInfo(); - clang::ModuleMap &moduleMap = headerSearch.getModuleMap(); - // List of core modules we can load, but it's ok if they are missing because - // the system doesn't have these modules. - if (clang::Module *LIBCM = moduleMap.findModule("libc")) - if (!LoadModule(LIBCM->Name, interp)) - Error("TCling::LoadCoreModules", "Cannot load module %s", LIBCM->Name.c_str()); - - if (clang::Module *STLM = moduleMap.findModule("stl")) - if (!LoadModule(STLM->Name, interp)) - Error("TCling::LoadCoreModules", "Cannot load module %s", STLM->Name.c_str()); - - // ROOT_Types is a module outside core because we need C and -no-rtti compatibility. - // Preload it as it is an integral part of module Core. - if (!LoadModule(moduleMap.findModule("ROOT_Types")->Name, interp)) - Error("TCling::LoadCoreModules", "Cannot load module ROOT_Types"); - - if (!LoadModule(moduleMap.findModule("Core")->Name, interp)) - Error("TCling::LoadCoreModules", "Cannot load module Core"); - - if (!LoadModule(moduleMap.findModule("RIO")->Name, interp)) - Error("TCling::LoadCoreModules", "Cannot load module RIO"); - - // Check that the gROOT macro was exported by any core module. - assert(interp.getMacro("gROOT") && "Couldn't load gROOT macro?"); - - // C99 decided that it's a very good idea to name a macro `I` (the letter I). - // This seems to screw up nearly all the template code out there as `I` is - // common template parameter name and iterator variable name. - // Let's follow the GCC recommendation and undefine `I` in case any of the - // core modules have defined it: - // https://www.gnu.org/software/libc/manual/html_node/Complex-Numbers.html - interp.declare("#ifdef I\n #undef I\n #endif\n"); + for (const auto &modName : modules) + LoadModule(modName, interp); } static bool FileExists(const char *file) @@ -1274,6 +1249,22 @@ TCling::TCling(const char *name, const char *title) static llvm::raw_fd_ostream fMPOuts (STDOUT_FILENO, /*ShouldClose*/false); fMetaProcessor = new cling::MetaProcessor(*fInterpreter, fMPOuts); + if (fInterpreter->getCI()->getLangOpts().Modules) { + // Setup core C++ modules if we have any to setup. + LoadModules({"libc", "stl", "ROOT_Types", "Core", "RIO"}, *fInterpreter); + + // Check that the gROOT macro was exported by any core module. + assert(fInterpreter->getMacro("gROOT") && "Couldn't load gROOT macro?"); + + // C99 decided that it's a very good idea to name a macro `I` (the letter I). + // This seems to screw up nearly all the template code out there as `I` is + // common template parameter name and iterator variable name. + // Let's follow the GCC recommendation and undefine `I` in case any of the + // core modules have defined it: + // https://www.gnu.org/software/libc/manual/html_node/Complex-Numbers.html + fInterpreter->declare("#ifdef I\n #undef I\n #endif\n"); + } + // For the list to also include string, we have to include it now. // rootcling does parts already if needed, e.g. genreflex does not want using // namespace std. @@ -1293,9 +1284,6 @@ TCling::TCling(const char *name, const char *title) "#include \n"); } - // Setup core C++ modules if we have any to setup. - LoadCoreModules(*fInterpreter); - // We are now ready (enough is loaded) to init the list of opaque typedefs. fNormalizedCtxt = new ROOT::TMetaUtils::TNormalizedCtxt(fInterpreter->getLookupHelper()); fLookupHelper = new ROOT::TMetaUtils::TClingLookupHelper(*fInterpreter, *fNormalizedCtxt, TClingLookupHelper__ExistingTypeCheck, TClingLookupHelper__AutoParse); From 08043ab47e6d5c53cc59032bd924758639cbe25c Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 30 Nov 2017 10:20:34 +0100 Subject: [PATCH 02/21] [cxxmodules] Add flag if module has C++ module alongside it --- cmake/modules/RootNewMacros.cmake | 3 ++- core/base/inc/TROOT.h | 3 ++- core/base/src/TROOT.cxx | 23 ++++++++++++++--------- core/dictgen/src/TModuleGenerator.cxx | 2 +- core/meta/inc/TInterpreter.h | 3 ++- core/metacling/src/TCling.cxx | 5 +++-- core/metacling/src/TCling.h | 3 ++- 7 files changed, 26 insertions(+), 16 deletions(-) diff --git a/cmake/modules/RootNewMacros.cmake b/cmake/modules/RootNewMacros.cmake index a4ad269c48b39..d6a5664001989 100644 --- a/cmake/modules/RootNewMacros.cmake +++ b/cmake/modules/RootNewMacros.cmake @@ -366,7 +366,8 @@ function(ROOT_GENERATE_DICTIONARY dictionary) endforeach() endif() - if(runtime_cxxmodules AND ARG_MODULE) + set(runtime_cxxmodules_env) + if(runtime_cxxmodules AND ARG_MODULE AND NOT ARG_MULTIDICT) # FIXME: Once modules work better, we should use some other value like "1" # to disable the module-build remarks from clang. set(runtime_cxxmodules_env "ROOT_MODULES=DEBUG") diff --git a/core/base/inc/TROOT.h b/core/base/inc/TROOT.h index 2717f079c21fd..f7d31ecdee63a 100644 --- a/core/base/inc/TROOT.h +++ b/core/base/inc/TROOT.h @@ -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=""); diff --git a/core/base/src/TROOT.cxx b/core/base/src/TROOT.cxx index 7efe1911841f1..5400ec84dd539 100644 --- a/core/base/src/TROOT.cxx +++ b/core/base/src/TROOT.cxx @@ -258,7 +258,8 @@ 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), @@ -266,7 +267,8 @@ namespace { 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 @@ -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& GetModuleHeaderInfoBuffer() { @@ -2068,7 +2071,8 @@ void TROOT::InitInterpreter() li->fTriggerFunc, li->fFwdNargsToKeepColl, li->fClassesHeaders, - kTRUE /*lateRegistration*/); + kTRUE /*lateRegistration*/, + li->fHasCxxModule); } GetModuleHeaderInfoBuffer().clear(); @@ -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. @@ -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)); } } diff --git a/core/dictgen/src/TModuleGenerator.cxx b/core/dictgen/src/TModuleGenerator.cxx index 4abfbbde9cb70..646e0171b3f97 100644 --- a/core/dictgen/src/TModuleGenerator.cxx +++ b/core/dictgen/src/TModuleGenerator.cxx @@ -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" diff --git a/core/meta/inc/TInterpreter.h b/core/meta/inc/TInterpreter.h index b7af7ac610fd3..158e4e7445ee3 100644 --- a/core/meta/inc/TInterpreter.h +++ b/core/meta/inc/TInterpreter.h @@ -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; diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index eff582880a85a..71de86596e6fb 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1661,7 +1661,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 @@ -1901,7 +1902,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) { diff --git a/core/metacling/src/TCling.h b/core/metacling/src/TCling.h index f726cf5ecea0c..11ec4c950ea9f 100644 --- a/core/metacling/src/TCling.h +++ b/core/metacling/src/TCling.h @@ -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); From 2fc72e0cd1e1aff497ebb10a2039b5f1c63dd500 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 23 Nov 2017 15:50:39 +0100 Subject: [PATCH 03/21] [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. --- CMakeLists.txt | 6 +++++- core/metacling/src/TCling.cxx | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 957825e88ddac..3ee3c7aba119c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -343,7 +343,11 @@ endif() if(runtime_cxxmodules) # Dummy target that does nothing, we don't need a PCH for modules. - add_custom_target(onepcm) + # However, we require that TMVA/Graf/Treeplayer are built here as + # we will always load them to workaround the fact that we can't + # load the decls in them via rootmap files (as they are inside + # namespaces which isn't supported). + add_custom_target(onepcm DEPENDS TreePlayer TMVA Graf) else() add_custom_command(OUTPUT etc/allDict.cxx.pch 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 diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 71de86596e6fb..bbbeb7ac42f7c 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1356,6 +1356,11 @@ TCling::~TCling() void TCling::Initialize() { fClingCallbacks->Initialize(); + if (fInterpreter->getCI()->getLangOpts().Modules && !IsFromRootCling()) { + // Load modules that we can't automatically load via rootmap files as they + // contain decls in namespaces which aren't supported. + LoadModules({"TMVA", "TreePlayer", "Graf"}, *fInterpreter); + } } //////////////////////////////////////////////////////////////////////////////// From fddd8e926f3dacd24d1f3fdc9c6eea8e92f13dd0 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 30 Nov 2017 20:37:43 +0100 Subject: [PATCH 04/21] Fixed Vc abi check warning --- core/metacling/src/TCling.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index bbbeb7ac42f7c..2d919f48fc4f1 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1179,6 +1179,7 @@ TCling::TCling(const char *name, const char *title) clingArgsStorage.push_back("-Wno-undefined-inline"); clingArgsStorage.push_back("-fsigned-char"); } + clingArgsStorage.push_back("-DVc_NO_VERSION_CHECK"); std::vector interpArgs; for (std::vector::const_iterator iArg = clingArgsStorage.begin(), From 3f508e13f6365be323ffef0bc7f53538b58dc07b Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 30 Nov 2017 21:35:25 +0100 Subject: [PATCH 05/21] Add LD_LIBRARY_PATH to module path (broken commit?) --- core/metacling/src/TCling.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 2d919f48fc4f1..1707d9acaf2b6 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1120,6 +1120,22 @@ static bool IsFromRootCling() { return foundSymbol; } +static void loadModulePath(HeaderSearch& hdrSearch, const char* environmentVariable) { + const char* LD_LIBRARY_PATH = getenv(environmentVariable); + if (LD_LIBRARY_PATH) { + StringRef path = LD_LIBRARY_PATH; + SmallVector paths; + path.split(paths, ":"); + for (StringRef path : paths) { + SmallString<128> ModuleMapFilePath = path; + llvm::sys::path::append(ModuleMapFilePath, "module.modulemap"); + + if (auto file = hdrSearch.getFileMgr().getFile(ModuleMapFilePath)) + hdrSearch.loadModuleMapFile(file, false, FileID()); + } + } +} + //////////////////////////////////////////////////////////////////////////////// /// Initialize the cling interpreter interface. @@ -1251,6 +1267,10 @@ TCling::TCling(const char *name, const char *title) fMetaProcessor = new cling::MetaProcessor(*fInterpreter, fMPOuts); if (fInterpreter->getCI()->getLangOpts().Modules) { + HeaderSearch& hdrSearch = fInterpreter->getCI()->getPreprocessor().getHeaderSearchInfo(); + hdrSearch.loadTopLevelSystemModules(); + loadModulePath(hdrSearch, "LD_LIBRARY_PATH"); + // Setup core C++ modules if we have any to setup. LoadModules({"libc", "stl", "ROOT_Types", "Core", "RIO"}, *fInterpreter); From 91cb046ff93b6d19eabba8da9c5a87f22fe682d5 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 30 Nov 2017 21:37:14 +0100 Subject: [PATCH 06/21] Also preload Gpad/RooStats --- CMakeLists.txt | 2 +- core/metacling/src/TCling.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ee3c7aba119c..6be8fcf52fb28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,7 +347,7 @@ if(runtime_cxxmodules) # we will always load them to workaround the fact that we can't # load the decls in them via rootmap files (as they are inside # namespaces which isn't supported). - add_custom_target(onepcm DEPENDS TreePlayer TMVA Graf) + add_custom_target(onepcm DEPENDS RooStats Gpad TreePlayer TMVA Graf) else() add_custom_command(OUTPUT etc/allDict.cxx.pch 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 diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 1707d9acaf2b6..4bcc949891b2c 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1380,7 +1380,7 @@ void TCling::Initialize() if (fInterpreter->getCI()->getLangOpts().Modules && !IsFromRootCling()) { // Load modules that we can't automatically load via rootmap files as they // contain decls in namespaces which aren't supported. - LoadModules({"TMVA", "TreePlayer", "Graf"}, *fInterpreter); + LoadModules({"TMVA", "Gpad", "RooStats", "TreePlayer", "Graf"}, *fInterpreter); } } From 57c235d03e263125f2fe62b07f27854df72900d8 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 30 Nov 2017 22:01:52 +0100 Subject: [PATCH 07/21] Also load GenVector --- CMakeLists.txt | 2 +- core/metacling/src/TCling.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6be8fcf52fb28..41bca3ecd3424 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,7 +347,7 @@ if(runtime_cxxmodules) # we will always load them to workaround the fact that we can't # load the decls in them via rootmap files (as they are inside # namespaces which isn't supported). - add_custom_target(onepcm DEPENDS RooStats Gpad TreePlayer TMVA Graf) + add_custom_target(onepcm DEPENDS RooStats Gpad TreePlayer TMVA Graf GenVector) else() add_custom_command(OUTPUT etc/allDict.cxx.pch 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 diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 4bcc949891b2c..b9eac18a371c9 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1380,7 +1380,7 @@ void TCling::Initialize() if (fInterpreter->getCI()->getLangOpts().Modules && !IsFromRootCling()) { // Load modules that we can't automatically load via rootmap files as they // contain decls in namespaces which aren't supported. - LoadModules({"TMVA", "Gpad", "RooStats", "TreePlayer", "Graf"}, *fInterpreter); + LoadModules({"TMVA", "Gpad", "RooStats", "GenVector", "TreePlayer", "Graf"}, *fInterpreter); } } From a0963eb682fe22463b3c287866e3e79878fa410c Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 30 Nov 2017 22:33:24 +0100 Subject: [PATCH 08/21] Another attempt at loading from library path --- core/metacling/src/TCling.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index b9eac18a371c9..17d4da87c0e29 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1120,18 +1120,18 @@ static bool IsFromRootCling() { return foundSymbol; } -static void loadModulePath(HeaderSearch& hdrSearch, const char* environmentVariable) { - const char* LD_LIBRARY_PATH = getenv(environmentVariable); - if (LD_LIBRARY_PATH) { - StringRef path = LD_LIBRARY_PATH; +static void loadModulePath(HeaderSearch& hdrSearch, const char* inputPath) { + if (inputPath) { + StringRef path = inputPath; SmallVector paths; path.split(paths, ":"); + for (StringRef path : paths) { SmallString<128> ModuleMapFilePath = path; - llvm::sys::path::append(ModuleMapFilePath, "module.modulemap"); - if (auto file = hdrSearch.getFileMgr().getFile(ModuleMapFilePath)) + if (auto file = hdrSearch.getFileMgr().getFile(ModuleMapFilePath)) { hdrSearch.loadModuleMapFile(file, false, FileID()); + } } } } @@ -1269,7 +1269,7 @@ TCling::TCling(const char *name, const char *title) if (fInterpreter->getCI()->getLangOpts().Modules) { HeaderSearch& hdrSearch = fInterpreter->getCI()->getPreprocessor().getHeaderSearchInfo(); hdrSearch.loadTopLevelSystemModules(); - loadModulePath(hdrSearch, "LD_LIBRARY_PATH"); + loadModulePath(hdrSearch, gSystem->GetDynamicPath()); // Setup core C++ modules if we have any to setup. LoadModules({"libc", "stl", "ROOT_Types", "Core", "RIO"}, *fInterpreter); From a1c8a35b3e7ebc6ce04b986f6acfb63e79690927 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 30 Nov 2017 23:41:11 +0100 Subject: [PATCH 09/21] Also preload Hist --- CMakeLists.txt | 2 +- core/metacling/src/TCling.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 41bca3ecd3424..3f1962ff9eec2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,7 +347,7 @@ if(runtime_cxxmodules) # we will always load them to workaround the fact that we can't # load the decls in them via rootmap files (as they are inside # namespaces which isn't supported). - add_custom_target(onepcm DEPENDS RooStats Gpad TreePlayer TMVA Graf GenVector) + add_custom_target(onepcm DEPENDS RooStats Hist Gpad TreePlayer TMVA Graf GenVector) else() add_custom_command(OUTPUT etc/allDict.cxx.pch 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 diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 17d4da87c0e29..167d3866d8430 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1380,7 +1380,7 @@ void TCling::Initialize() if (fInterpreter->getCI()->getLangOpts().Modules && !IsFromRootCling()) { // Load modules that we can't automatically load via rootmap files as they // contain decls in namespaces which aren't supported. - LoadModules({"TMVA", "Gpad", "RooStats", "GenVector", "TreePlayer", "Graf"}, *fInterpreter); + LoadModules({"TMVA", "Gpad", "RooStats", "GenVector", "Hist", "TreePlayer", "Graf"}, *fInterpreter); } } From d72805b72d6a857c9584e68513cd73a243d0af7f Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 30 Nov 2017 23:42:36 +0100 Subject: [PATCH 10/21] Also preload Net --- CMakeLists.txt | 2 +- core/metacling/src/TCling.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f1962ff9eec2..b4f66c75070ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,7 +347,7 @@ if(runtime_cxxmodules) # we will always load them to workaround the fact that we can't # load the decls in them via rootmap files (as they are inside # namespaces which isn't supported). - add_custom_target(onepcm DEPENDS RooStats Hist Gpad TreePlayer TMVA Graf GenVector) + add_custom_target(onepcm DEPENDS Net RooStats Hist Gpad TreePlayer TMVA Graf GenVector) else() add_custom_command(OUTPUT etc/allDict.cxx.pch 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 diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 167d3866d8430..575ca37cb3582 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1380,7 +1380,7 @@ void TCling::Initialize() if (fInterpreter->getCI()->getLangOpts().Modules && !IsFromRootCling()) { // Load modules that we can't automatically load via rootmap files as they // contain decls in namespaces which aren't supported. - LoadModules({"TMVA", "Gpad", "RooStats", "GenVector", "Hist", "TreePlayer", "Graf"}, *fInterpreter); + LoadModules({"TMVA", "Gpad", "RooStats", "GenVector", "Hist", "Net", "TreePlayer", "Graf"}, *fInterpreter); } } From cae72d1ed091b87486f82c7652d910a564e3b202 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Fri, 1 Dec 2017 10:08:57 +0100 Subject: [PATCH 11/21] Fixed library loading --- core/metacling/src/TCling.cxx | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 575ca37cb3582..d3ab31bb2b5a6 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1127,11 +1127,12 @@ static void loadModulePath(HeaderSearch& hdrSearch, const char* inputPath) { path.split(paths, ":"); for (StringRef path : paths) { - SmallString<128> ModuleMapFilePath = path; + SmallString<128> ModuleMapFilePath = path; + llvm::sys::path::append(ModuleMapFilePath, "module.modulemap"); - if (auto file = hdrSearch.getFileMgr().getFile(ModuleMapFilePath)) { - hdrSearch.loadModuleMapFile(file, false, FileID()); - } + if (auto file = hdrSearch.getFileMgr().getFile(ModuleMapFilePath)) { + hdrSearch.loadModuleMapFile(file, false, FileID()); + } } } } @@ -5119,6 +5120,20 @@ Int_t TCling::LoadLibraryMap(const char* rootmapfile) } if (!skip) { void* dirp = gSystem->OpenDirectory(d); + + // Load the modulemap from the dir and add it to the prebuilt module + // path. + // FIXME: This is ROOT quality code, refactor me. + fInterpreter->getCI()->getHeaderSearchOpts().AddPrebuiltModulePath(d.Data()); + auto& hdrSearch = fInterpreter->getCI()->getPreprocessor().getHeaderSearchInfo(); + SmallString<128> ModuleMapFilePath = StringRef(d.Data()); + llvm::sys::path::append(ModuleMapFilePath, "module.modulemap"); + + if (auto file = hdrSearch.getFileMgr().getFile(ModuleMapFilePath)) { + hdrSearch.loadModuleMapFile(file, false, FileID()); + } + + if (dirp) { if (gDebug > 3) { Info("LoadLibraryMap", "%s", d.Data()); From 2e3d606f471cc103fcb0c4ef8a5ff369ecb3dc8d Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Fri, 1 Dec 2017 10:24:27 +0100 Subject: [PATCH 12/21] Re-enable header parsing on demand --- core/metacling/src/TCling.cxx | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index d3ab31bb2b5a6..373f3ed560d26 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1152,8 +1152,6 @@ TCling::TCling(const char *name, const char *title) #ifdef R__USE_CXXMODULES useCxxModules = true; #endif - if (useCxxModules) - fHeaderParsingOnDemand = false; llvm::install_fatal_error_handler(&exceptionErrorHandler); @@ -1789,7 +1787,22 @@ void TCling::RegisterModule(const char* modulename, } // if (dyLibName) } // if (!lateRegistration) - if (hasHeaderParsingOnDemand && fwdDeclsCode){ + clang::Sema &TheSema = fInterpreter->getSema(); + bool ModuleWasSuccessfullyLoaded = false; + if (hasCxxModule) { + std::string ModuleName = llvm::StringRef(modulename).substr(3).str(); + ModuleWasSuccessfullyLoaded = LoadModule(ModuleName, *fInterpreter); + if (!ModuleWasSuccessfullyLoaded) { + // Only report if we found the module in the modulemap. + clang::Preprocessor &PP = TheSema.getPreprocessor(); + clang::HeaderSearch &headerSearch = PP.getHeaderSearchInfo(); + clang::ModuleMap &moduleMap = headerSearch.getModuleMap(); + if (moduleMap.findModule(ModuleName)) + Info("TCling::RegisterModule", "Module %s in modulemap failed to load.", ModuleName.c_str()); + } + } + + if (!ModuleWasSuccessfullyLoaded && hasHeaderParsingOnDemand && fwdDeclsCode){ // We now parse the forward declarations. All the classes are then modified // in order for them to have an external lexical storage. std::string fwdDeclsCodeLessEnums; @@ -1926,21 +1939,7 @@ void TCling::RegisterModule(const char* modulename, if (fClingCallbacks) oldValue = SetClassAutoloading(false); - clang::Sema &TheSema = fInterpreter->getSema(); - bool ModuleWasSuccessfullyLoaded = false; - if (hasCxxModule) { - std::string ModuleName = llvm::StringRef(modulename).substr(3).str(); - ModuleWasSuccessfullyLoaded = LoadModule(ModuleName, *fInterpreter); - if (!ModuleWasSuccessfullyLoaded) { - // Only report if we found the module in the modulemap. - clang::Preprocessor &PP = TheSema.getPreprocessor(); - clang::HeaderSearch &headerSearch = PP.getHeaderSearchInfo(); - clang::ModuleMap &moduleMap = headerSearch.getModuleMap(); - if (moduleMap.findModule(ModuleName)) - Info("TCling::RegisterModule", "Module %s in modulemap failed to load.", ModuleName.c_str()); - } - } { // scope within which diagnostics are de-activated // For now we disable diagnostics because we saw them already at From 67003b01755de4bbbe45d8e5e7efcc18fbdce05b Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Fri, 1 Dec 2017 10:28:22 +0100 Subject: [PATCH 13/21] Also preload TreeViewer --- CMakeLists.txt | 2 +- core/metacling/src/TCling.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4f66c75070ab..f01b88b678dce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,7 +347,7 @@ if(runtime_cxxmodules) # we will always load them to workaround the fact that we can't # load the decls in them via rootmap files (as they are inside # namespaces which isn't supported). - add_custom_target(onepcm DEPENDS Net RooStats Hist Gpad TreePlayer TMVA Graf GenVector) + add_custom_target(onepcm DEPENDS Net TreeViewer RooStats Hist Gpad TreePlayer TMVA Graf GenVector) else() add_custom_command(OUTPUT etc/allDict.cxx.pch 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 diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 373f3ed560d26..4e1e8adaa6585 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1379,7 +1379,7 @@ void TCling::Initialize() if (fInterpreter->getCI()->getLangOpts().Modules && !IsFromRootCling()) { // Load modules that we can't automatically load via rootmap files as they // contain decls in namespaces which aren't supported. - LoadModules({"TMVA", "Gpad", "RooStats", "GenVector", "Hist", "Net", "TreePlayer", "Graf"}, *fInterpreter); + LoadModules({"TMVA", "Gpad", "RooStats", "GenVector", "Hist", "Net", "TreePlayer", "TreeViewer", "Graf"}, *fInterpreter); } } From 07883567b834eb839a96df0156f288d2e4def6e8 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Fri, 1 Dec 2017 11:43:16 +0100 Subject: [PATCH 14/21] Also add cwd to prebuilt module path --- core/metacling/src/TCling.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 4e1e8adaa6585..405ae3d979e5e 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1269,6 +1269,7 @@ TCling::TCling(const char *name, const char *title) HeaderSearch& hdrSearch = fInterpreter->getCI()->getPreprocessor().getHeaderSearchInfo(); hdrSearch.loadTopLevelSystemModules(); loadModulePath(hdrSearch, gSystem->GetDynamicPath()); + fInterpreter->getCI()->getHeaderSearchOpts().AddPrebuiltModulePath("."); // Setup core C++ modules if we have any to setup. LoadModules({"libc", "stl", "ROOT_Types", "Core", "RIO"}, *fInterpreter); From 59819b1e2dd5b4bbb2c5b5350d6a2cda65925773 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Fri, 1 Dec 2017 11:43:46 +0100 Subject: [PATCH 15/21] also preload math --- CMakeLists.txt | 2 +- core/metacling/src/TCling.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f01b88b678dce..72f7472e9d790 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,7 +347,7 @@ if(runtime_cxxmodules) # we will always load them to workaround the fact that we can't # load the decls in them via rootmap files (as they are inside # namespaces which isn't supported). - add_custom_target(onepcm DEPENDS Net TreeViewer RooStats Hist Gpad TreePlayer TMVA Graf GenVector) + add_custom_target(onepcm DEPENDS Net Math TreeViewer RooStats Hist Gpad TreePlayer TMVA Graf GenVector) else() add_custom_command(OUTPUT etc/allDict.cxx.pch 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 diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 405ae3d979e5e..555a52321689a 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1380,7 +1380,7 @@ void TCling::Initialize() if (fInterpreter->getCI()->getLangOpts().Modules && !IsFromRootCling()) { // Load modules that we can't automatically load via rootmap files as they // contain decls in namespaces which aren't supported. - LoadModules({"TMVA", "Gpad", "RooStats", "GenVector", "Hist", "Net", "TreePlayer", "TreeViewer", "Graf"}, *fInterpreter); + LoadModules({"TMVA", "Gpad", "RooStats", "GenVector", "Hist", "Math", "Net", "TreePlayer", "TreeViewer", "Graf"}, *fInterpreter); } } From 5b04cee9ef520169f25209862dcb85554ec3e7e3 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Fri, 1 Dec 2017 11:46:44 +0100 Subject: [PATCH 16/21] Also preload TMVAGui --- CMakeLists.txt | 2 +- core/metacling/src/TCling.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 72f7472e9d790..39a358b0f5d00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,7 +347,7 @@ if(runtime_cxxmodules) # we will always load them to workaround the fact that we can't # load the decls in them via rootmap files (as they are inside # namespaces which isn't supported). - add_custom_target(onepcm DEPENDS Net Math TreeViewer RooStats Hist Gpad TreePlayer TMVA Graf GenVector) + add_custom_target(onepcm DEPENDS Net Math TreeViewer RooStats Hist Gpad TreePlayer TMVA TMVAGui Graf GenVector) else() add_custom_command(OUTPUT etc/allDict.cxx.pch 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 diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 555a52321689a..94cb90bc04c0e 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1380,7 +1380,7 @@ void TCling::Initialize() if (fInterpreter->getCI()->getLangOpts().Modules && !IsFromRootCling()) { // Load modules that we can't automatically load via rootmap files as they // contain decls in namespaces which aren't supported. - LoadModules({"TMVA", "Gpad", "RooStats", "GenVector", "Hist", "Math", "Net", "TreePlayer", "TreeViewer", "Graf"}, *fInterpreter); + LoadModules({"TMVA", "TMVAGui", "Gpad", "RooStats", "GenVector", "Hist", "Math", "Net", "TreePlayer", "TreeViewer", "Graf"}, *fInterpreter); } } From 034558dee86382fd09f0635bf0727e9be8d17726 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Fri, 1 Dec 2017 11:48:07 +0100 Subject: [PATCH 17/21] Also preload RooFit --- CMakeLists.txt | 2 +- core/metacling/src/TCling.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 39a358b0f5d00..3e1c69b28536a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,7 +347,7 @@ if(runtime_cxxmodules) # we will always load them to workaround the fact that we can't # load the decls in them via rootmap files (as they are inside # namespaces which isn't supported). - add_custom_target(onepcm DEPENDS Net Math TreeViewer RooStats Hist Gpad TreePlayer TMVA TMVAGui Graf GenVector) + add_custom_target(onepcm DEPENDS Net Math TreeViewer RooStats Hist Gpad TreePlayer RooFit TMVA TMVAGui Graf GenVector) else() add_custom_command(OUTPUT etc/allDict.cxx.pch 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 diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 94cb90bc04c0e..7d526771316c0 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1380,7 +1380,7 @@ void TCling::Initialize() if (fInterpreter->getCI()->getLangOpts().Modules && !IsFromRootCling()) { // Load modules that we can't automatically load via rootmap files as they // contain decls in namespaces which aren't supported. - LoadModules({"TMVA", "TMVAGui", "Gpad", "RooStats", "GenVector", "Hist", "Math", "Net", "TreePlayer", "TreeViewer", "Graf"}, *fInterpreter); + LoadModules({"TMVA", "RooFit", "TMVAGui", "Gpad", "RooStats", "GenVector", "Hist", "Math", "Net", "TreePlayer", "TreeViewer", "Graf"}, *fInterpreter); } } From dd365a4eaa2d6ee0992e4c23def3ab204bd8f40e Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Fri, 1 Dec 2017 11:49:52 +0100 Subject: [PATCH 18/21] Also preload RGL --- CMakeLists.txt | 2 +- core/metacling/src/TCling.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e1c69b28536a..14d69673e3bf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,7 +347,7 @@ if(runtime_cxxmodules) # we will always load them to workaround the fact that we can't # load the decls in them via rootmap files (as they are inside # namespaces which isn't supported). - add_custom_target(onepcm DEPENDS Net Math TreeViewer RooStats Hist Gpad TreePlayer RooFit TMVA TMVAGui Graf GenVector) + add_custom_target(onepcm DEPENDS Net Math TreeViewer RooStats Hist Gpad TreePlayer RooFit RGL TMVA TMVAGui Graf GenVector) else() add_custom_command(OUTPUT etc/allDict.cxx.pch 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 diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 7d526771316c0..ebfe9af49dbfe 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1380,7 +1380,7 @@ void TCling::Initialize() if (fInterpreter->getCI()->getLangOpts().Modules && !IsFromRootCling()) { // Load modules that we can't automatically load via rootmap files as they // contain decls in namespaces which aren't supported. - LoadModules({"TMVA", "RooFit", "TMVAGui", "Gpad", "RooStats", "GenVector", "Hist", "Math", "Net", "TreePlayer", "TreeViewer", "Graf"}, *fInterpreter); + LoadModules({"TMVA", "RGL", "RooFit", "TMVAGui", "Gpad", "RooStats", "GenVector", "Hist", "Math", "Net", "TreePlayer", "TreeViewer", "Graf"}, *fInterpreter); } } From 2331cb32e3d17a9313d4beb969a6d690f0f3541e Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Fri, 1 Dec 2017 11:50:54 +0100 Subject: [PATCH 19/21] Also preload EG --- CMakeLists.txt | 2 +- core/metacling/src/TCling.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 14d69673e3bf7..fb914f2cafa06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,7 +347,7 @@ if(runtime_cxxmodules) # we will always load them to workaround the fact that we can't # load the decls in them via rootmap files (as they are inside # namespaces which isn't supported). - add_custom_target(onepcm DEPENDS Net Math TreeViewer RooStats Hist Gpad TreePlayer RooFit RGL TMVA TMVAGui Graf GenVector) + add_custom_target(onepcm DEPENDS Net Math TreeViewer RooStats Hist Gpad TreePlayer RooFit EG RGL TMVA TMVAGui Graf GenVector) else() add_custom_command(OUTPUT etc/allDict.cxx.pch 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 diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index ebfe9af49dbfe..03cb73b69d5b1 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1380,7 +1380,7 @@ void TCling::Initialize() if (fInterpreter->getCI()->getLangOpts().Modules && !IsFromRootCling()) { // Load modules that we can't automatically load via rootmap files as they // contain decls in namespaces which aren't supported. - LoadModules({"TMVA", "RGL", "RooFit", "TMVAGui", "Gpad", "RooStats", "GenVector", "Hist", "Math", "Net", "TreePlayer", "TreeViewer", "Graf"}, *fInterpreter); + LoadModules({"TMVA", "EG", "RGL", "RooFit", "TMVAGui", "Gpad", "RooStats", "GenVector", "Hist", "Math", "Net", "TreePlayer", "TreeViewer", "Graf"}, *fInterpreter); } } From 02e971a6bbef327016437965cdfc37393b3755a5 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Fri, 1 Dec 2017 11:59:29 +0100 Subject: [PATCH 20/21] Math -> MathCore --- CMakeLists.txt | 2 +- core/metacling/src/TCling.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb914f2cafa06..5dd0b6ea74c5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,7 +347,7 @@ if(runtime_cxxmodules) # we will always load them to workaround the fact that we can't # load the decls in them via rootmap files (as they are inside # namespaces which isn't supported). - add_custom_target(onepcm DEPENDS Net Math TreeViewer RooStats Hist Gpad TreePlayer RooFit EG RGL TMVA TMVAGui Graf GenVector) + add_custom_target(onepcm DEPENDS Net MathCore TreeViewer RooStats Hist Gpad TreePlayer RooFit EG RGL TMVA TMVAGui Graf GenVector) else() add_custom_command(OUTPUT etc/allDict.cxx.pch 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 diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 03cb73b69d5b1..e468236440166 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1380,7 +1380,7 @@ void TCling::Initialize() if (fInterpreter->getCI()->getLangOpts().Modules && !IsFromRootCling()) { // Load modules that we can't automatically load via rootmap files as they // contain decls in namespaces which aren't supported. - LoadModules({"TMVA", "EG", "RGL", "RooFit", "TMVAGui", "Gpad", "RooStats", "GenVector", "Hist", "Math", "Net", "TreePlayer", "TreeViewer", "Graf"}, *fInterpreter); + LoadModules({"TMVA", "EG", "RGL", "RooFit", "TMVAGui", "Gpad", "RooStats", "GenVector", "Hist", "MathCore", "Net", "TreePlayer", "TreeViewer", "Graf"}, *fInterpreter); } } From c8311df9c560bfd38a2ac76dd1be4a92d45dc083 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Tue, 5 Dec 2017 13:26:32 +0100 Subject: [PATCH 21/21] Use sparse vector in LoadedSLocEntryTable --- .../clang/include/clang/Basic/SourceManager.h | 57 ++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/interpreter/llvm/src/tools/clang/include/clang/Basic/SourceManager.h b/interpreter/llvm/src/tools/clang/include/clang/Basic/SourceManager.h index 0b0534406f4c0..6f6fb80bc6fe6 100644 --- a/interpreter/llvm/src/tools/clang/include/clang/Basic/SourceManager.h +++ b/interpreter/llvm/src/tools/clang/include/clang/Basic/SourceManager.h @@ -625,11 +625,66 @@ class SourceManager : public RefCountedBase { /// expansion. SmallVector LocalSLocEntryTable; + template + class SparseVector { + typedef std::array Chunk; + std::vector Chunks; + std::size_t realSize = 0; + std::size_t allocatedChunks = 0; + + Chunk *getChunk(std::size_t i) { + std::size_t ChunkIndex = i / ChunkSize; + + Chunk* Result = Chunks.at(ChunkIndex); + if (Result == nullptr) { + Result = new Chunk(); + Chunks[ChunkIndex] = Result; + allocatedChunks++; + } + return Result; + } + public: + SparseVector() { + } + + typedef T value_type; + + T& operator[](std::size_t i) { + Chunk *C = getChunk(i); + std::size_t Rem = i % ChunkSize; + return (*C)[Rem]; + } + + std::size_t size() const { + return realSize; + } + + std::size_t capacity() const { + return allocatedChunks * ChunkSize; + } + + void resize(std::size_t s) { + realSize = s; + Chunks.resize((s / ChunkSize) + 1); + } + + void clear() { + Chunks.clear(); + realSize = 0; + allocatedChunks = 0; + } + + bool empty() const { + return realSize == 0; + } + }; + /// \brief The table of SLocEntries that are loaded from other modules. /// /// Negative FileIDs are indexes into this table. To get from ID to an index, /// use (-ID - 2). - mutable SmallVector LoadedSLocEntryTable; + mutable SparseVector LoadedSLocEntryTable; + //mutable SmallVector LoadedSLocEntryTable; /// \brief The starting offset of the next local SLocEntry. ///