Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion cmake/modules/RootMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ function(ROOT_GENERATE_DICTIONARY dictionary)
set(rootmap_name ${library_output_dir}/${libprefix}${deduced_arg_module}.rootmap)
endif()

if(CMAKE_ROOTTEST_NOROOTMAP)
if(CMAKE_ROOTTEST_NOROOTMAP OR cpp_module_file)
set(rootmap_name )
set(rootmapargs )
else()
Expand Down
67 changes: 48 additions & 19 deletions core/base/src/TSystem.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ that the method should be overridden in a derived class), which
allows a simple partial implementation for new OS'es.
*/

#ifdef WIN32
#include <io.h>
#endif
#include <stdlib.h>
#include <errno.h>
#include <algorithm>
#include <sys/stat.h>

#include <ROOT/FoundationUtils.hxx>
#include "Riostream.h"
#include "TSystem.h"
Expand All @@ -55,6 +47,14 @@ allows a simple partial implementation for new OS'es.
#include "RConfigure.h"
#include "THashList.h"

#include <sstream>
#include <string>
#include <sys/stat.h>

#ifdef WIN32
#include <io.h>
#endif

const char *gRootDir;
const char *gProgName;
const char *gProgPath;
Expand Down Expand Up @@ -3353,6 +3353,36 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
linkDepLibraries = linkLibs & 0x1;
}

// FIXME: Triggers clang false positive warning -Wunused-lambda-capture.
/*constexpr const*/ bool useCxxModules =
#ifdef R__USE_CXXMODULES
true;
#else
false;
#endif

auto LoadLibrary = [useCxxModules, produceRootmap](const TString& lib) {
// We have no rootmap files or modules to construct `-l` flags enabling
// explicit linking. We have to resolve the dependencies by ourselves
// taking the job of the dyld.
// FIXME: This is a rare case where we have rootcling running with
// modules disabled. Remove this code once we fully switch to modules,
// or implement a special flag in rootcling which selective enables
// modules for dependent libraries and does not produce a module for
// the ACLiC library.
if (useCxxModules && !produceRootmap) {
using namespace std;
string deps = gInterpreter->GetSharedLibDeps(lib, /*tryDyld*/true);
istringstream iss(deps);
vector<string> libs {istream_iterator<std::string>{iss}, istream_iterator<string>{}};
// Skip the first element: it is a relative path to `lib`.
for (auto I = libs.begin() + 1, E = libs.end(); I != E; ++I)
if (gInterpreter->Load(I->c_str(), /*system*/false) < 0)
return false; // failure
}
return !gSystem->Load(lib);
};

if (!recompile) {
// The library already exist, let's just load it.
if (loadLib) {
Expand All @@ -3367,7 +3397,7 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
gInterpreter->LoadLibraryMap(libmapfilename);
}

return !gSystem->Load(library);
return LoadLibrary(library);
}
else return kTRUE;
}
Expand Down Expand Up @@ -3478,9 +3508,11 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
TString mapfileout = mapfile + ".out";

Bool_t needLoadMap = kFALSE;
if (gInterpreter->GetSharedLibDeps(libname) !=0 ) {
gInterpreter->UnloadLibraryMap(libname);
needLoadMap = kTRUE;
if (!useCxxModules) {
if (gInterpreter->GetSharedLibDeps(libname) !=0 ) {
gInterpreter->UnloadLibraryMap(libname);
needLoadMap = kTRUE;
}
}

std::ofstream mapfileStream( mapfilein, std::ios::out );
Expand Down Expand Up @@ -3511,11 +3543,6 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
}
mapfileStream.close();

bool useCxxModules = false;
#ifdef R__USE_CXXMODULES
useCxxModules = true;
#endif

// ======= Generate the rootcling command line
TString rcling = "rootcling";
PrependPathName(TROOT::GetBinDir(), rcling);
Expand Down Expand Up @@ -3770,8 +3797,10 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
gInterpreter->LoadLibraryMap(libmapfilename);
}
if (verboseLevel>3 && withInfo) ::Info("ACLiC","loading the shared library");
if (loadLib) result = !gSystem->Load(library);
else result = kTRUE;
if (loadLib)
result = LoadLibrary(library);
else
result = kTRUE;

if ( !result ) {
if (verboseLevel>3 && withInfo) {
Expand Down
5 changes: 3 additions & 2 deletions core/dictgen/src/TModuleGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,9 @@ void TModuleGenerator::WriteRegistrationSource(std::ostream &out, const std::str
{
if (hasCxxModule) {
std::string emptyStr = "\"\"";
WriteRegistrationSourceImpl(out, GetDictionaryName(), GetDemangledDictionaryName(), {}, {}, emptyStr, "{}",
emptyStr, "0", "0",
WriteRegistrationSourceImpl(out, GetDictionaryName(), GetDemangledDictionaryName(), {}, {},
fwdDeclString, "{}",
emptyStr, headersClassesMapString, "0",
/*HasCxxModule*/ true);
return;
}
Expand Down
21 changes: 10 additions & 11 deletions core/dictgen/src/rootcling_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3370,8 +3370,8 @@ void ExtractHeadersForDecls(const RScanner::ClassColl_t &annotatedRcds,
////////////////////////////////////////////////////////////////////////////////
/// Generate the fwd declarations of the selected entities

std::string GenerateFwdDeclString(const RScanner &scan,
const cling::Interpreter &interp)
static std::string GenerateFwdDeclString(const RScanner &scan,
const cling::Interpreter &interp)
{
std::string newFwdDeclString;

Expand Down Expand Up @@ -4839,18 +4839,17 @@ int RootClingMain(int argc,
}


const std::string headersClassesMapString = GenerateStringFromHeadersForClasses(headersDeclsMap,
detectedUmbrella,
true);
std::string headersClassesMapString = "\"\"";
std::string fwdDeclsString = "\"\"";
if (!gDriverConfig->fBuildingROOTStage1) {
if (writeEmptyRootPCM) {
fwdDeclsString = "nullptr";
} else {
fwdDeclsString = GenerateFwdDeclString(scan, interp);
if (!cxxmodule) {
headersClassesMapString = GenerateStringFromHeadersForClasses(headersDeclsMap,
detectedUmbrella,
true);
if (!gDriverConfig->fBuildingROOTStage1) {
if (!writeEmptyRootPCM)
fwdDeclsString = GenerateFwdDeclString(scan, interp);
}
}

modGen.WriteRegistrationSource(dictStream, fwdDeclnArgsToKeepString, headersClassesMapString, fwdDeclsString,
extraIncludes, cxxmodule);
// If we just want to inline the input header, we don't need
Expand Down
2 changes: 1 addition & 1 deletion core/meta/inc/TInterpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class TInterpreter : public TNamed {
virtual char *GetPrompt() = 0;
virtual const char *GetSharedLibs() = 0;
virtual const char *GetClassSharedLibs(const char *cls) = 0;
virtual const char *GetSharedLibDeps(const char *lib) = 0;
virtual const char *GetSharedLibDeps(const char *lib, bool tryDyld = false) = 0;
virtual const char *GetIncludePath() = 0;
virtual const char *GetSTLIncludePath() const { return ""; }
virtual TObjArray *GetRootMapFiles() const = 0;
Expand Down
Loading