>> You need to figure out how to pass -rdynamic to the linker, like Isaid before. http://llvm.org/docs/tutorial/OCamlLangImpl7.html mentions it, but I don't know enough about the ocaml build process to say whether that'll work. I believe I'm already doing that, properly by passing -ccopt -rdynamic to ocamlopt: ocamlopt -cc g++ -ccopt -rdynamic -linkall $(LIBFILES) -o alpha $(OBJFILES) I've also tried writing a dummy "puts" function in a C file and linking that with my executable. nm -D then shows the following: 000000000054b690 T camlRuntime__rt_fputs_208 000000000054b590 T camlRuntime__rt_puts_198 U fputs 0000000000c43044 T puts However, LLVM *still* gives me: LLVM ERROR: Tried to execute an unknown external function: i32 (i8*)* puts Something really wrong is happening. The following thread seems to indicate that this should all work easily: http://old.nabble.com/jit-with-external-functions-td7769793.html -- View this message in context: http://old.nabble.com/Linking-with-C-Library-tp28133460p28145523.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
On Mon, Apr 5, 2010 at 3:27 PM, Nyx <mcheva at cs.mcgill.ca> wrote:> >>> You need to figure out how to pass -rdynamic to the linker, like I > said before. http://llvm.org/docs/tutorial/OCamlLangImpl7.html > mentions it, but I don't know enough about the ocaml build process to > say whether that'll work. > > I believe I'm already doing that, properly by passing -ccopt -rdynamic to > ocamlopt: > ocamlopt -cc g++ -ccopt -rdynamic -linkall $(LIBFILES) -o alpha $(OBJFILES) > > I've also tried writing a dummy "puts" function in a C file and linking that > with my executable. nm -D then shows the following: > > 000000000054b690 T camlRuntime__rt_fputs_208 > 000000000054b590 T camlRuntime__rt_puts_198 > U fputs > 0000000000c43044 T puts > > However, LLVM *still* gives me: > LLVM ERROR: Tried to execute an unknown external function: i32 (i8*)* puts > > Something really wrong is happening. The following thread seems to indicate > that this should all work easily: > http://old.nabble.com/jit-with-external-functions-td7769793.html >Ok, you've passed my expertise. Maybe you have to link with -lc? Hopefully one of the ocaml experts will chime in.
If the OCaml bindings include the functionality in llvm::sys::DynamicLibrary, perhaps you can use the functions there to manually request the puts symbol? e.g. llvm::sys::DynamicLibrary::LoadLibraryPermanently() and llvm::sys::DynamicLibrary::SearchForAddressOfSymbol() ...? Just a thought. On Apr 5, 2010, at 6:56 PM, Jeffrey Yasskin wrote:> On Mon, Apr 5, 2010 at 3:27 PM, Nyx <mcheva at cs.mcgill.ca> wrote: >> >>>> You need to figure out how to pass -rdynamic to the linker, like I >> said before. http://llvm.org/docs/tutorial/OCamlLangImpl7.html >> mentions it, but I don't know enough about the ocaml build process to >> say whether that'll work. >> >> I believe I'm already doing that, properly by passing -ccopt - >> rdynamic to >> ocamlopt: >> ocamlopt -cc g++ -ccopt -rdynamic -linkall $(LIBFILES) -o alpha $ >> (OBJFILES) >> >> I've also tried writing a dummy "puts" function in a C file and >> linking that >> with my executable. nm -D then shows the following: >> >> 000000000054b690 T camlRuntime__rt_fputs_208 >> 000000000054b590 T camlRuntime__rt_puts_198 >> U fputs >> 0000000000c43044 T puts >> >> However, LLVM *still* gives me: >> LLVM ERROR: Tried to execute an unknown external function: i32 >> (i8*)* puts >> >> Something really wrong is happening. The following thread seems to >> indicate >> that this should all work easily: >> http://old.nabble.com/jit-with-external-functions-td7769793.html >> > > Ok, you've passed my expertise. Maybe you have to link with -lc? > Hopefully one of the ocaml experts will chime in. > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>> Ok, you've passed my expertise. Maybe you have to link with -lc?Hopefully one of the ocaml experts will chime in. I figured out what was wrong. LLVM needs to be compiled with --enable-libffi for the external symbol resolution to work properly. This is unfortunately not mentioned in the OCaml version of the LLVM Kaleidoscope tutorials! -- View this message in context: http://old.nabble.com/Linking-with-C-Library-tp28133460p28146796.html Sent from the LLVM - Dev mailing list archive at Nabble.com.