Pass libCling handle at construction time, resolve from it:
OrcV2 uses specific DyLibs to resolve symbols from, we need a dedicated resolver for libCling because its symbols cannot be found from the process. Remove now unused "ExposeHiddenSharedLibrarySymbols".
This commit is contained in:
parent
0362d3fcda
commit
d8c5c2a206
@ -199,14 +199,6 @@ namespace cling {
|
||||
return getSymbolLocation(reinterpret_cast<void*>(func));
|
||||
}
|
||||
|
||||
|
||||
///\brief Explicitly tell the execution engine to use symbols from
|
||||
/// a shared library that would otherwise not be used for symbol
|
||||
/// resolution, e.g. because it was dlopened with RTLD_LOCAL.
|
||||
///\param [in] handle - the system specific shared library handle.
|
||||
///
|
||||
static void ExposeHiddenSharedLibrarySymbols(void* handle);
|
||||
|
||||
static std::string normalizePath(llvm::StringRef path);
|
||||
|
||||
/// Returns true if file is a shared library.
|
||||
|
@ -344,7 +344,8 @@ namespace cling {
|
||||
/// constructors. parentInterp might be nullptr.
|
||||
///
|
||||
Interpreter(int argc, const char* const* argv, const char* llvmdir,
|
||||
const ModuleFileExtensions& moduleExtensions, bool noRuntime,
|
||||
const ModuleFileExtensions& moduleExtensions,
|
||||
void *extraLibHandle, bool noRuntime,
|
||||
const Interpreter* parentInterp);
|
||||
|
||||
public:
|
||||
@ -353,13 +354,14 @@ namespace cling {
|
||||
///\param[in] argc - no. of args.
|
||||
///\param[in] argv - arguments passed when driver is invoked.
|
||||
///\param[in] llvmdir - ???
|
||||
///\param[in] extraLibHandle - resolve symbols also from this dylib
|
||||
///\param[in] noRuntime - flag to control the presence of runtime universe
|
||||
///
|
||||
Interpreter(int argc, const char* const* argv, const char* llvmdir = 0,
|
||||
const ModuleFileExtensions& moduleExtensions = {},
|
||||
bool noRuntime = false)
|
||||
: Interpreter(argc, argv, llvmdir, moduleExtensions, noRuntime,
|
||||
nullptr) {}
|
||||
void *extraLibHandle = nullptr, bool noRuntime = false)
|
||||
: Interpreter(argc, argv, llvmdir, moduleExtensions, extraLibHandle,
|
||||
noRuntime, nullptr) {}
|
||||
|
||||
///\brief Constructor for child Interpreter.
|
||||
/// If the parent Interpreter has a replacement DiagnosticConsumer, it is
|
||||
@ -368,12 +370,13 @@ namespace cling {
|
||||
///\param[in] argc - no. of args.
|
||||
///\param[in] argv - arguments passed when driver is invoked.
|
||||
///\param[in] llvmdir - ???
|
||||
///\param[in] extraLibHandle - resolve symbols also from this dylib
|
||||
///\param[in] noRuntime - flag to control the presence of runtime universe
|
||||
///
|
||||
Interpreter(const Interpreter& parentInterpreter, int argc,
|
||||
const char* const* argv, const char* llvmdir = 0,
|
||||
const ModuleFileExtensions& moduleExtensions = {},
|
||||
bool noRuntime = true);
|
||||
void *extraLibHandle = nullptr, bool noRuntime = true);
|
||||
|
||||
virtual ~Interpreter();
|
||||
|
||||
|
@ -444,10 +444,6 @@ namespace cling {
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicLibraryManager::ExposeHiddenSharedLibrarySymbols(void* handle) {
|
||||
llvm::sys::DynamicLibrary::addPermanentLibrary(const_cast<void*>(handle));
|
||||
}
|
||||
|
||||
bool DynamicLibraryManager::isSharedLibrary(llvm::StringRef libFullPath,
|
||||
bool* exists /*=0*/) {
|
||||
using namespace llvm;
|
||||
|
@ -109,7 +109,7 @@ CreateHostTargetMachine(const clang::CompilerInstance& CI) {
|
||||
|
||||
IncrementalExecutor::IncrementalExecutor(clang::DiagnosticsEngine& /*diags*/,
|
||||
const clang::CompilerInstance& CI,
|
||||
bool Verbose):
|
||||
void *ExtraLibHandle, bool Verbose):
|
||||
m_Callbacks(nullptr), m_externalIncrementalExecutor(nullptr)
|
||||
#if 0
|
||||
: m_Diags(diags)
|
||||
@ -125,7 +125,7 @@ IncrementalExecutor::IncrementalExecutor(clang::DiagnosticsEngine& /*diags*/,
|
||||
llvm::Error Err = llvm::Error::success();
|
||||
auto EPC = llvm::cantFail(llvm::orc::SelfExecutorProcessControl::Create());
|
||||
m_JIT.reset(new IncrementalJIT(*this, std::move(TM), std::move(EPC), Err,
|
||||
Verbose));
|
||||
ExtraLibHandle, Verbose));
|
||||
if (Err) {
|
||||
llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "Fatal: ");
|
||||
llvm_unreachable("Propagate this error and exit gracefully");
|
||||
|
@ -154,7 +154,8 @@ namespace cling {
|
||||
|
||||
IncrementalExecutor(clang::DiagnosticsEngine& diags,
|
||||
const clang::CompilerInstance& CI,
|
||||
bool Verbose);
|
||||
void *ExtraLibHandle = nullptr,
|
||||
bool Verbose = false);
|
||||
|
||||
~IncrementalExecutor();
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace cling {
|
||||
IncrementalJIT::IncrementalJIT(
|
||||
IncrementalExecutor& Executor, std::unique_ptr<TargetMachine> TM,
|
||||
std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC, Error& Err,
|
||||
bool Verbose)
|
||||
void *ExtraLibHandle, bool Verbose)
|
||||
: SkipHostProcessLookup(false),
|
||||
TM(std::move(TM)),
|
||||
SingleThreadedContext(std::make_unique<LLVMContext>()) {
|
||||
@ -81,6 +81,14 @@ IncrementalJIT::IncrementalJIT(
|
||||
}
|
||||
Jit->getMainJITDylib().addGenerator(std::move(*HostProcessLookup));
|
||||
|
||||
// This must come after process resolution, to consistently resolve global
|
||||
// symbols (e.g. std::cout) to the same address.
|
||||
auto LibLookup = std::make_unique<DynamicLibrarySearchGenerator>(
|
||||
llvm::sys::DynamicLibrary(ExtraLibHandle), LinkerPrefix,
|
||||
[&](const SymbolStringPtr &Sym) {
|
||||
return !m_ForbidDlSymbols.contains(*Sym); });
|
||||
Jit->getMainJITDylib().addGenerator(std::move(LibLookup));
|
||||
|
||||
// This replaces llvm::orc::ExecutionSession::logErrorsToStdErr:
|
||||
auto&& ErrorReporter = [&Executor, LinkerPrefix, Verbose](Error Err) {
|
||||
Err = handleErrors(std::move(Err),
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
IncrementalJIT(IncrementalExecutor& Executor,
|
||||
std::unique_ptr<llvm::TargetMachine> TM,
|
||||
std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC,
|
||||
llvm::Error &Err, bool Verbose = false);
|
||||
llvm::Error &Err, void *ExtraLibHandle, bool Verbose);
|
||||
|
||||
/// Register a DefinitionGenerator to dynamically provide symbols for
|
||||
/// generated code that are not already available within the process.
|
||||
|
@ -200,7 +200,8 @@ namespace cling {
|
||||
Interpreter::Interpreter(int argc, const char* const *argv,
|
||||
const char* llvmdir /*= 0*/,
|
||||
const ModuleFileExtensions& moduleExtensions,
|
||||
bool noRuntime, const Interpreter* parentInterp) :
|
||||
void *extraLibHandle, bool noRuntime,
|
||||
const Interpreter* parentInterp) :
|
||||
m_Opts(argc, argv),
|
||||
m_UniqueCounter(parentInterp ? parentInterp->m_UniqueCounter + 1 : 0),
|
||||
m_PrintDebug(false), m_DynamicLookupDeclared(false),
|
||||
@ -258,7 +259,7 @@ namespace cling {
|
||||
|
||||
if (!isInSyntaxOnlyMode()) {
|
||||
m_Executor.reset(new IncrementalExecutor(SemaRef.Diags, *getCI(),
|
||||
m_Opts.Verbose()));
|
||||
extraLibHandle, m_Opts.Verbose()));
|
||||
|
||||
if (!m_Executor)
|
||||
return;
|
||||
@ -350,8 +351,8 @@ namespace cling {
|
||||
const char* const *argv,
|
||||
const char* llvmdir /*= 0*/,
|
||||
const ModuleFileExtensions& moduleExtensions/*={}*/,
|
||||
bool noRuntime /*= true*/) :
|
||||
Interpreter(argc, argv, llvmdir, moduleExtensions, noRuntime,
|
||||
void *ExtraLibHandle, bool noRuntime /*= true*/) :
|
||||
Interpreter(argc, argv, llvmdir, moduleExtensions, ExtraLibHandle, noRuntime,
|
||||
&parentInterpreter) {
|
||||
// Do the "setup" of the connection between this interpreter and
|
||||
// its parent interpreter.
|
||||
@ -1769,7 +1770,8 @@ namespace cling {
|
||||
std::string llvmdir
|
||||
= getCI()->getHeaderSearchOpts().ResourceDir + "/../../../";
|
||||
cling::Interpreter fwdGen(1, &dummy, llvmdir.c_str(),
|
||||
/*moduleExtensions*/ {}, /*noRuntime=*/true);
|
||||
/*moduleExtensions*/ {},
|
||||
/*ExtraLibHandle*/ nullptr, /*noRuntime=*/true);
|
||||
|
||||
// Copy the same header search options to the new instance.
|
||||
Preprocessor& fwdGenPP = fwdGen.getCI()->getPreprocessor();
|
||||
|
Loading…
x
Reference in New Issue
Block a user