Hi
I hope this is a proper place to put my question.
I've compiled Kaleidoscope from "Adding JIT and Optimizer Support"
tutorial.
Basically it works just fine but when I try to run extern'ed putchard
function it aborts.
Please, tell me what am I doing wrong?
Here is more information:
My PC runs FreeBSD.
I've copied the toy source code exactly and didn't change it.
Here is the log:
# ./toy
ready> extern putchard(x);
ready> Read extern:
declare double @putchard(double)
ready> def asd (a) putchard(a);
ready> Read function definition:
define double @asd(double %a) {
entry:
%calltmp = call double @putchard( double %a ) ;
<double> [#uses=1]
ret double %calltmp
}
ready> asd(120);
ready> ERROR: Program used external function 'putchard' which could
not be resolved!
Abort (core dumped)
Here is the backtrace from the toy.core:
(gdb) backtrace
#0 0x4889cbb7 in kill () from /lib/libc.so.7
#1 0x4868d146 in raise () from /lib/libthr.so.3
#2 0x4889b76a in abort () from /lib/libc.so.7
#3 0x0831f8a0 in llvm::JIT::getPointerToNamedFunction ()
#4 0x0832177a in llvm::JIT::getPointerToFunction ()
#5 0x083275a2 in (anonymous namespace)::JITEmitter::getPointerToGlobal ()
#6 0x083280e4 in (anonymous namespace)::JITEmitter::finishFunction ()
#7 0x0805f8d0 in (anonymous namespace)::Emitter::runOnMachineFunction ()
#8 0x081deee8 in llvm::MachineFunctionPass::runOnFunction ()
#9 0x08561cd7 in llvm::FPPassManager::runOnFunction ()
#10 0x08562185 in llvm::FunctionPassManagerImpl::run ()
#11 0x08562337 in llvm::FunctionPassManager::run ()
#12 0x0831f9ec in llvm::JIT::runJITOnFunction ()
#13 0x08321847 in llvm::JIT::getPointerToFunction ()
#14 0x0804f680 in MainLoop () at toy.cpp:508
#15 0x0804ff12 in main () at toy.cpp:590
Link with -rdynamic or provide a mapping. /Stein Roger Andrii Vasyliev wrote:> Hi > > I hope this is a proper place to put my question. > > I've compiled Kaleidoscope from "Adding JIT and Optimizer Support" tutorial. > Basically it works just fine but when I try to run extern'ed putchard > function it aborts. > Please, tell me what am I doing wrong? > > Here is more information: > My PC runs FreeBSD. > I've copied the toy source code exactly and didn't change it. > > Here is the log: > # ./toy > ready> extern putchard(x); > ready> Read extern: > declare double @putchard(double) > > ready> def asd (a) putchard(a); > ready> Read function definition: > define double @asd(double %a) { > entry: > %calltmp = call double @putchard( double %a ) ; > <double> [#uses=1] > ret double %calltmp > } > > ready> asd(120); > ready> ERROR: Program used external function 'putchard' which could > not be resolved! > Abort (core dumped) > > Here is the backtrace from the toy.core: > (gdb) backtrace > #0 0x4889cbb7 in kill () from /lib/libc.so.7 > #1 0x4868d146 in raise () from /lib/libthr.so.3 > #2 0x4889b76a in abort () from /lib/libc.so.7 > #3 0x0831f8a0 in llvm::JIT::getPointerToNamedFunction () > #4 0x0832177a in llvm::JIT::getPointerToFunction () > #5 0x083275a2 in (anonymous namespace)::JITEmitter::getPointerToGlobal () > #6 0x083280e4 in (anonymous namespace)::JITEmitter::finishFunction () > #7 0x0805f8d0 in (anonymous namespace)::Emitter::runOnMachineFunction () > #8 0x081deee8 in llvm::MachineFunctionPass::runOnFunction () > #9 0x08561cd7 in llvm::FPPassManager::runOnFunction () > #10 0x08562185 in llvm::FunctionPassManagerImpl::run () > #11 0x08562337 in llvm::FunctionPassManager::run () > #12 0x0831f9ec in llvm::JIT::runJITOnFunction () > #13 0x08321847 in llvm::JIT::getPointerToFunction () > #14 0x0804f680 in MainLoop () at toy.cpp:508 > #15 0x0804ff12 in main () at toy.cpp:590 > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >
Thanks, -rdynamic helps! It's a pity that it's not written in the tutorial. Also I'm interested how can I provide a mapping? 2008/9/25 srs <skaflotten at gmail.com>:> Link with -rdynamic or provide a mapping.
Andrii Vasyliev wrote:> I've compiled Kaleidoscope from "Adding JIT and Optimizer Support" tutorial. > Basically it works just fine but when I try to run extern'ed putchard > function it aborts. > Please, tell me what am I doing wrong?Have you tried to link with -rdynamic (Linux-specific, not needed on OSX or Windows)? -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr.Graef at t-online.de, ag at muwiinfa.geschichte.uni-mainz.de WWW: http://www.musikinformatik.uni-mainz.de/ag