[LLVMdev] Updating OCaml LLVM Language Implementation Tutorial

Logan Streondj streondj at gmail.com
Thu Aug 21 15:55:17 PDT 2014


Hi, 
I'm trying to implement a human speakable programming language.

Recently I discovered that OCaml is/was one of the most "ideal"
languages in relation to code-length:performance ratio.
http://blog.gmarceau.qc.ca/2009/05/speed-size-and-dependability-of.html
(contacted him to update his scripts to see if that's still the case).

Found the LLVM OCaml tutorial, which got me quite excited.
Unfortunately it does not work with the current version of LLVM/OCaml. 

I asked around on IRC, and Whitequark was able to help me get the
initial bits compiling again. However there still seems to be some
bugs before it will fully function.

As you may know the source code for the whole thing is available at:
http://llvm.org/docs/tutorial/OCamlLangImpl7.html

So far have had to modify
file _tags 
to include a line:
true: package(llvm)

and in file toy.ml 
the DataLayout line had to be changed to
 Llvm_target.DataLayout.add_to_pass_manager the_fpm (ExecutionEngine.data_layout the_execution_engine); 

also compilation must occur using
ocamlbuild -use-ocamlfind toy.byte 

even so error:

$ ocamlbuild -use-ocamlfind toy.byte
toy.byte 
Finished, 0 targets (0 cached) in 00:00:00.
+ ocamlfind ocamlc llvm.cma llvm_analysis.cma llvm_executionengine.cma
llvm_target.cma llvm_scalar_opts.cma -cc g++ -cclib -rdynamic -linkpkg
-package llvm ast.cmo token.cmo parser.cmo codegen.cmo lexer.cmo
toplevel.cmo toy.cmo bindings.o -o toy.byte
File "_none_", line 1:
Error: Error on dynamically loaded library:
/home/elspru/.opam/system/lib/llvm/./dllllvm.so:
/home/elspru/.opam/system/lib/llvm/./dllllvm.so: undefined symbol:
LLVMGetFirstUse
Command exited with code 2.
Compilation unsuccessful after building 16 targets (0 cached) in
00:00:02.


I'm using LLVM 3.4 (not sure how opam can install higher version)
OCaml version 3.12.1
Ubuntu 14.04 LTS Trusty

can view my version of the sources at:
http://mkaw.tk/lang/kalsco/ocaml/

Hopefully in the coming days, or weeks can get this sorted out.
I'm willing to test ideas for solutions, and report back. 
The maintainer could update the tutorial once there is a solution. 
I'd recomend having a zip or tarball available, at the end,
so people can more easily download and test Kaleidascope (kalsco),
with some kind of open source license perhaps. 

Anyways, I would really love to be able to implement my language in
OCaml LLVM, as it has to parse human-like language. Hope you can help.

--
Logan Streondj



More information about the llvm-dev mailing list