Simplify symbol overrides
There is no need to force symbol emission, get the address from the JIT, and then replace the symbol once more.
This commit is contained in:
parent
900be1d0e8
commit
c201269a09
@ -334,12 +334,10 @@ namespace cling {
|
|||||||
///
|
///
|
||||||
///\param[in] NoRuntime - Don't include the runtime headers / gCling
|
///\param[in] NoRuntime - Don't include the runtime headers / gCling
|
||||||
///\param[in] SyntaxOnly - In SyntaxOnly mode
|
///\param[in] SyntaxOnly - In SyntaxOnly mode
|
||||||
///\param[out] Globals - Global symbols that need to be emitted
|
|
||||||
///
|
///
|
||||||
///\returns The resulting Transation of initialization.
|
///\returns The resulting Transation of initialization.
|
||||||
///
|
///
|
||||||
Transaction* Initialize(bool NoRuntime, bool SyntaxOnly,
|
Transaction* Initialize(bool NoRuntime, bool SyntaxOnly);
|
||||||
llvm::SmallVectorImpl<llvm::StringRef>& Globals);
|
|
||||||
|
|
||||||
///\ Shut down the interpreter runtime.
|
///\ Shut down the interpreter runtime.
|
||||||
///
|
///
|
||||||
|
@ -327,8 +327,7 @@ namespace cling {
|
|||||||
setupCallbacks(*this, parentInterp);
|
setupCallbacks(*this, parentInterp);
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::SmallVector<llvm::StringRef, 6> Syms;
|
Initialize(noRuntime || m_Opts.NoRuntime, isInSyntaxOnlyMode());
|
||||||
Initialize(noRuntime || m_Opts.NoRuntime, isInSyntaxOnlyMode(), Syms);
|
|
||||||
|
|
||||||
// Commit the transactions, now that gCling is set up. It is needed for
|
// Commit the transactions, now that gCling is set up. It is needed for
|
||||||
// static initialization in these transactions through
|
// static initialization in these transactions through
|
||||||
@ -336,24 +335,6 @@ namespace cling {
|
|||||||
for (auto&& I: IncrParserTransactions)
|
for (auto&& I: IncrParserTransactions)
|
||||||
m_IncrParser->commitTransaction(I);
|
m_IncrParser->commitTransaction(I);
|
||||||
|
|
||||||
// Now that the transactions have been commited, force symbol emission
|
|
||||||
// and overrides.
|
|
||||||
if (!isInSyntaxOnlyMode() && !m_Opts.CompilerOpts.CUDADevice) {
|
|
||||||
for (const llvm::StringRef& Sym : Syms) {
|
|
||||||
void* Addr = m_Executor->getPointerToGlobalFromJIT(Sym);
|
|
||||||
#if defined(__linux__)
|
|
||||||
// We need to look for the mangled name of at_quick_exit on linux.
|
|
||||||
if (!Addr && Sym.equals("at_quick_exit"))
|
|
||||||
Addr = m_Executor->getPointerToGlobalFromJIT("_Z13at_quick_exitPFvvE");
|
|
||||||
#endif
|
|
||||||
if (!Addr) {
|
|
||||||
cling::errs() << "Replaced symbol " << Sym << " cannot be found in JIT!\n";
|
|
||||||
} else {
|
|
||||||
m_Executor->replaceSymbol(Sym.str().c_str(), Addr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_IncrParser->SetTransformers(parentInterp);
|
m_IncrParser->SetTransformers(parentInterp);
|
||||||
|
|
||||||
if (!TSCtx->getContext()) {
|
if (!TSCtx->getContext()) {
|
||||||
@ -423,8 +404,7 @@ namespace cling {
|
|||||||
m_IncrParser.reset(nullptr);
|
m_IncrParser.reset(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transaction* Interpreter::Initialize(bool NoRuntime, bool SyntaxOnly,
|
Transaction* Interpreter::Initialize(bool NoRuntime, bool SyntaxOnly) {
|
||||||
llvm::SmallVectorImpl<llvm::StringRef>& Globals) {
|
|
||||||
// The Initialize() function is called twice in CUDA mode. The first time
|
// The Initialize() function is called twice in CUDA mode. The first time
|
||||||
// the host interpreter is initialized and the second time the device
|
// the host interpreter is initialized and the second time the device
|
||||||
// interpreter is initialized. Without this if statement, a redefinition
|
// interpreter is initialized. Without this if statement, a redefinition
|
||||||
@ -521,7 +501,6 @@ namespace cling {
|
|||||||
<< " { return __cxa_atexit((void(*)(void*))f, 0, __dso_handle); }\n";
|
<< " { return __cxa_atexit((void(*)(void*))f, 0, __dso_handle); }\n";
|
||||||
else
|
else
|
||||||
Strm << ";\n";
|
Strm << ";\n";
|
||||||
Globals.push_back("at_quick_exit");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
@ -539,7 +518,6 @@ namespace cling {
|
|||||||
" return f; }\n";
|
" return f; }\n";
|
||||||
else
|
else
|
||||||
Strm << ";\n";
|
Strm << ";\n";
|
||||||
Globals.push_back("__dllonexit");
|
|
||||||
#if !defined(_M_CEE_PURE)
|
#if !defined(_M_CEE_PURE)
|
||||||
Strm << Linkage << " " << Spec << " int (*_onexit("
|
Strm << Linkage << " " << Spec << " int (*_onexit("
|
||||||
<< "int (" << Spec << " *f)()))()";
|
<< "int (" << Spec << " *f)()))()";
|
||||||
@ -548,7 +526,6 @@ namespace cling {
|
|||||||
" return f; }\n";
|
" return f; }\n";
|
||||||
else
|
else
|
||||||
Strm << ";\n";
|
Strm << ";\n";
|
||||||
Globals.push_back("_onexit");
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user