[llvm] r224993 - Make the __morestack function available to the JIT memory manager under Linux.

Peter Collingbourne peter at pcc.me.uk
Tue Dec 30 14:54:37 PST 2014


It may be that we will need to introduce some API function to allow clients
to supply the address of the __morestack function. Or we could see if we
can arrange to link another copy of the split stack runtime into our DSO,
which seems to be what libgo's DSO does.

Until then, making the reference to __morestack weak seems to fix the build
break (done in r225014), but breaks clients that need to be able to use this
function from JIT if LLVM is built as a DSO.

Peter

On Tue, Dec 30, 2014 at 02:08:41PM -0800, Reid Kleckner wrote:
> This breaks linking LLDB on Linux:
> 
> /usr/bin/ld: bin/lldb-3.6.0: hidden symbol `__morestack' in
> /usr/local/google/home/rnk/gcc/install/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/libgcc.a(morestack.o)
> is referenced by DSO
> /usr/bin/ld: final link failed: Bad value
> 
> It also breaks building lli if you use cmake -DBUILD_SHARED_LIBS=ON.
> 
> Ideas? It's not clear to me how to reference __morestack from a DSO.
> 
> On Tue, Dec 30, 2014 at 10:06 AM, Peter Collingbourne <peter at pcc.me.uk>
> wrote:
> 
> > Author: pcc
> > Date: Tue Dec 30 12:06:52 2014
> > New Revision: 224993
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=224993&view=rev
> > Log:
> > Make the __morestack function available to the JIT memory manager under
> > Linux.
> >
> > This function's implementation lives in libgcc, a static library, so we
> > need
> > to expose it explicitly, like the other such functions.
> >
> > Differential Revision: http://reviews.llvm.org/D6788
> >
> > Modified:
> >     llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp
> >
> > Modified: llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp?rev=224993&r1=224992&r2=224993&view=diff
> >
> > ==============================================================================
> > --- llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp (original)
> > +++ llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp Tue Dec 30
> > 12:06:52 2014
> > @@ -210,6 +210,10 @@ ARM_MATH_IMPORTS(ARM_MATH_DECL)
> >  #undef ARM_MATH_DECL
> >  #endif
> >
> > +#if defined(__linux__) && defined(__GLIBC__)
> > +extern "C" void __morestack();
> > +#endif
> > +
> >  uint64_t
> >  RTDyldMemoryManager::getSymbolAddressInProcess(const std::string &Name) {
> >    // This implementation assumes that the host program is the target.
> > @@ -233,6 +237,9 @@ RTDyldMemoryManager::getSymbolAddressInP
> >    if (Name == "lstat64") return (uint64_t)&lstat64;
> >    if (Name == "atexit") return (uint64_t)&atexit;
> >    if (Name == "mknod") return (uint64_t)&mknod;
> > +
> > +  // __morestack lives in libgcc, a static library.
> > +  if (Name == "__morestack") return (uint64_t)&__morestack;
> >  #endif // __linux__ && __GLIBC__
> >
> >    // See ARM_MATH_IMPORTS definition for explanation
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >

-- 
Peter



More information about the llvm-commits mailing list