Teach ACLiC to build modules.

ACLiC now synthesizes a modulemap with a suffix _ACLiC_dict.modulemap. The file
contains the source file to be compiled and the corresponding library.

The modulemap is then passed to rootcling via -fmodule-map-file= flag to avoid
naming clashes with possibly existing other modulemap files.

This patch teaches cling to work with the -fmodule-map-file= flag.

ACLiC supports automatic inclusion of Rtypes.h (making ClassDef macro
available). Modules are built in isolation and are resilient to #include
of Rtypes.h at rootcling startup time. We make module Core (containing Rtypes.h)
visible via a newly implemented callback.
This commit is contained in:
Vassil Vassilev 2019-05-14 14:12:08 +03:00 committed by SFT Nightlies
parent 70df14a1c7
commit da626b392d
4 changed files with 22 additions and 0 deletions

View File

@ -110,6 +110,9 @@ namespace cling {
llvm::StringRef /*SearchPath*/,
llvm::StringRef /*RelativePath*/,
const clang::Module* /*Imported*/) {}
virtual void EnteredSubmodule(clang::Module* M,
clang::SourceLocation ImportLoc,
bool ForPragma) {}
virtual bool FileNotFound(llvm::StringRef FileName,
llvm::SmallVectorImpl<char>& RecoveryPath);

View File

@ -1236,6 +1236,13 @@ static void stringifyPreprocSetting(PreprocessorOptions& PPOpts,
PP.getTargetInfo().getTriple());
}
for (const auto& Filename : FrontendOpts.ModuleMapFiles) {
if (auto* File = FM.getFile(Filename))
PP.getHeaderSearchInfo().loadModuleMapFile(File, /*IsSystem*/ false);
else
CI->getDiagnostics().Report(diag::err_module_map_not_found) << Filename;
}
return CI.release(); // Passes over the ownership to the caller.
}

View File

@ -49,6 +49,12 @@ namespace cling {
SearchPath, RelativePath, Imported);
}
void EnteredSubmodule(clang::Module* M,
clang::SourceLocation ImportLoc,
bool ForPragma) override {
m_Callbacks->EnteredSubmodule(M, ImportLoc, ForPragma);
}
virtual bool FileNotFound(llvm::StringRef FileName,
llvm::SmallVectorImpl<char>& RecoveryPath) {
if (m_Callbacks)

View File

@ -41,6 +41,12 @@ namespace cling {
Imported);
}
void EnteredSubmodule(clang::Module* M, clang::SourceLocation ImportLoc,
bool ForPragma) override {
for (auto&& cb : m_Callbacks)
cb->EnteredSubmodule(M, ImportLoc, ForPragma);
}
bool FileNotFound(llvm::StringRef FileName,
llvm::SmallVectorImpl<char>& RecoveryPath) override {
bool result = false;