Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCM filename contains libName + dictName #17

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
32 changes: 7 additions & 25 deletions core/meta/src/TCling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ namespace{
TCling::TCling(const char *name, const char *title)
: TInterpreter(name, title), fGlobalsListSerial(-1), fInterpreter(0),
fMetaProcessor(0), fNormalizedCtxt(0), fPrevLoadedDynLibInfo(0),
fClingCallbacks(0), fHaveSinglePCM(kFALSE), fAutoLoadCallBack(0),
fClingCallbacks(0), fAutoLoadCallBack(0),
fTransactionCount(0), fHeaderParsingOnDemand(getenv("HEADER_PARSING_ON_DEMAND"))
{
// Initialize the cling interpreter interface.
Expand Down Expand Up @@ -851,14 +851,6 @@ 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 (getenv("ROOT_MODULES")) {
fHaveSinglePCM =
LoadPCM(ROOT::TMetaUtils::GetModuleFileName("allDict").c_str(),
0 /*headers*/, 0 /*triggerFunc*/);
}
if (fHaveSinglePCM)
::Info("TCling::TCling", "Using one PCM.");

// 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.
Expand Down Expand Up @@ -1039,17 +1031,15 @@ void TCling::RegisterModule(const char* modulename,
// The payload code is injected "as is" in the interpreter.
// The value of 'triggerFunc' is used to find the shared library location.

bool rootModulesDefined (getenv("ROOT_MODULES"));
// rootcling also uses TCling for generating the dictionary ROOT files.
bool fromRootCling = dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym");
// We need the dictionary initialization but we don't want to inject the
// declarations into the interpreter, except for those we really need for
// I/O; see rootcling.cxx after the call to TCling__GetInterpreter().
if (fromRootCling) return;

if (fHaveSinglePCM && !strncmp(modulename, "G__", 3))
modulename = "allDict";
TString pcmFileName(ROOT::TMetaUtils::GetModuleFileName(modulename).c_str());
const char* dyLibName = FindLibraryName(triggerFunc);
TString pcmFileName = ROOT::TMetaUtils::GetPCMFileName(dyLibName, modulename);

for (const char** inclPath = includePaths; *inclPath; ++inclPath) {
TCling::AddIncludePath(*inclPath);
Expand Down Expand Up @@ -1093,7 +1083,6 @@ void TCling::RegisterModule(const char* modulename,
// requested by the JIT from it: as the library is currently being dlopen'ed,
// its symbols are not yet reachable from the process.
// Recursive dlopen seems to work just fine.
const char* dyLibName = FindLibraryName(triggerFunc);
if (dyLibName) {
// We were able to determine the library name.
void* dyLibHandle = dlopen(dyLibName, RTLD_LAZY | RTLD_GLOBAL);
Expand Down Expand Up @@ -1134,13 +1123,9 @@ void TCling::RegisterModule(const char* modulename,
}


if (rootModulesDefined) {
fInterpreter->declare(code.Data());
code = "";
if (!LoadPCM(pcmFileName, headers, triggerFunc)) {
::Error("TCling::RegisterModule", "cannot find dictionary module %s",
ROOT::TMetaUtils::GetModuleFileName(modulename).c_str());
}
if (!LoadPCM(pcmFileName, headers, triggerFunc)) {
::Error("TCling::RegisterModule", "cannot find dictionary module %s",
pcmFileName.Data());
}

bool oldValue = false;
Expand All @@ -1151,10 +1136,7 @@ void TCling::RegisterModule(const char* modulename,
if (gDebug > 5) {
::Info("TCling::RegisterModule", " #including %s...", *hdr);
}
if(!rootModulesDefined)
code += TString::Format("#include \"%s\"\n", *hdr);
else
fInterpreter->loadModuleForHeader(*hdr);
code += TString::Format("#include \"%s\"\n", *hdr);
}

{ // scope within which diagnostics are de-activated
Expand Down
3 changes: 1 addition & 2 deletions core/meta/src/TCling.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ class TCling : public TInterpreter {
void* fPrevLoadedDynLibInfo; // Internal info to mark the last loaded libray.
std::vector<void*> fRegisterModuleDyLibs; // Stack of libraries currently running RegisterModule
TClingCallbacks* fClingCallbacks; // cling::Interpreter owns it.
Bool_t fHaveSinglePCM; // Whether a single ROOT PCM was provided
struct CharPtrCmp_t {
bool operator()(const char* a, const char *b) const {
return strcmp(a, b) < 0;
Expand All @@ -136,7 +135,7 @@ class TCling : public TInterpreter {
DeclId_t GetDeclId(const llvm::GlobalValue *gv) const;

bool fHeaderParsingOnDemand;


public: // Public Interface
virtual ~TCling();
Expand Down
3 changes: 2 additions & 1 deletion core/metautils/inc/TMetaUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ llvm::StringRef GetFileName(const clang::Decl& decl,

//______________________________________________________________________________
// Return the dictionary file name for a module
std::string GetModuleFileName(const char* moduleName);
std::string GetPCMFileName(const char* libraryName,
const std::string& moduleName);

//______________________________________________________________________________
// Declare a virtual module.map to clang. Returns Module on success.
Expand Down
19 changes: 15 additions & 4 deletions core/metautils/src/TMetaUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3629,11 +3629,22 @@ std::string ROOT::TMetaUtils::GetROOTIncludeDir(bool rootbuild)
}

//______________________________________________________________________________
std::string ROOT::TMetaUtils::GetModuleFileName(const char* moduleName)
std::string ROOT::TMetaUtils::GetPCMFileName(const char* libraryName,
const std::string& moduleName)
{
// Return the dictionary file name for a module
std::string dictFileName(moduleName);
dictFileName += "_rdict.pcm";
// Return the dictionary file name for a module. libraryName might be NULL
// if it was not provided to rootcling; moduleName must not be NULL.
std::string dictFileName;
if (libraryName) {
dictFileName = libraryName;
// Remove extension
size_t posExt = dictFileName.find_last_of('.');
if (posExt != std::string::npos) {
dictFileName.erase(posExt);
}
dictFileName += "_";
}
dictFileName += moduleName + "_rdict.pcm";
return dictFileName;
}

Expand Down
10 changes: 6 additions & 4 deletions core/utils/src/TModuleGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ using namespace ROOT;
using namespace clang;

TModuleGenerator::TModuleGenerator(CompilerInstance* CI,
const char* shLibFileName):
const char* shLibFileName,
const char* dictName):
fCI(CI),
fShLibFileName(shLibFileName),
fIsPCH(!strcmp(shLibFileName, "etc/allDict.cxx")),
fDictionaryName(llvm::sys::path::stem(shLibFileName)),
fDictionaryName(dictName),
fModuleDirName(llvm::sys::path::parent_path(shLibFileName))
{

Expand All @@ -61,8 +62,9 @@ TModuleGenerator::TModuleGenerator(CompilerInstance* CI,
fModuleDirName += "/";
}

fModuleFileName = fModuleDirName
+ ROOT::TMetaUtils::GetModuleFileName(fDictionaryName.c_str());
std::string fullPCMFileName
= ROOT::TMetaUtils::GetPCMFileName(shLibFileName, fDictionaryName);
fModuleFileName = fModuleDirName + llvm::sys::path::filename(fullPCMFileName).str();
// .pcm -> .pch
if (IsPCH()) fModuleFileName[fModuleFileName.length() - 1] = 'h';

Expand Down
3 changes: 2 additions & 1 deletion core/utils/src/TModuleGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class TModuleGenerator {
};

TModuleGenerator(clang::CompilerInstance* CI,
const char* shLibFileName);
const char* shLibFileName,
const char* dictName);
~TModuleGenerator();

// FIXME: remove once PCH is gone.
Expand Down
29 changes: 15 additions & 14 deletions core/utils/src/rootcling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3911,12 +3911,22 @@ int RootCling(int argc,
string incCurDir = "-I";
incCurDir += currentDirectory;
pcmArgs.push_back(incCurDir);

TModuleGenerator modGen(interp.getCI(),
sharedLibraryPathName.c_str());


string main_dictname = llvm::sys::path::filename(dictpathname).str();
size_t dh = main_dictname.rfind('.');
if (dh != std::string::npos) {
main_dictname.erase(dh);
}
// Need to replace all the characters not allowed in a symbol ...
std::string main_dictname_copy(main_dictname);
TMetaUtils::GetCppName(main_dictname, main_dictname_copy.c_str());

TModuleGenerator modGen(interp.getCI(),
sharedLibraryPathName.c_str(),
main_dictname.c_str());

interp.declare("#pragma clang diagnostic ignored \"-Wdeprecated-declarations\"");

// Add the diagnostic pragmas distilled from the -Wno-xyz
for (std::list<std::string>::iterator dPrIt = diagnosticPragmas.begin();
dPrIt != diagnosticPragmas.end(); dPrIt++){
Expand Down Expand Up @@ -3951,7 +3961,6 @@ int RootCling(int argc,

// Check if code goes to stdout or rootcling file
std::ofstream fileout;
string main_dictname(dictpathname);
std::ostream* dictStreamPtr = NULL;
if (!ignoreExistingDict){
if (!dictpathname.empty()) {
Expand All @@ -3976,14 +3985,6 @@ int RootCling(int argc,
std::ostream& dictStream = *dictStreamPtr;
std::ostream& splitDictStream = *splitDictStreamPtr;

size_t dh = main_dictname.rfind('.');
if (dh != std::string::npos) {
main_dictname.erase(dh);
}
// Need to replace all the characters not allowed in a symbol ...
std::string main_dictname_copy(main_dictname);
TMetaUtils::GetCppName(main_dictname, main_dictname_copy.c_str());

CreateDictHeader(dictStream,main_dictname);
if (doSplit)
CreateDictHeader(splitDictStream,main_dictname);
Expand Down