From 8ef426baa36639458f6777309db25c1768dc9c8a Mon Sep 17 00:00:00 2001 From: Gordon Henriksen Date: Tue, 18 Sep 2007 12:49:39 +0000 Subject: Adding ocaml language bindings for the vmcore and bitwriter libraries. These are built atop the C language bindings, and user programs can link with them as such: # Bytecode ocamlc -cc g++ llvm.cma llvmbitwriter.cma -o example example.ml # Native ocamlopt -cc g++ llvm.cmxa llvmbitwriter.cmxa -o example.opt example.ml The vmcore.ml test exercises most/all of the APIs thus far bound. Unfortunately, they're not yet numerous enough to write hello world. But: $ cat example.ml (* example.ml *) open Llvm open Llvm_bitwriter let _ = let filename = Sys.argv.(1) in let m = create_module filename in let v = make_int_constant i32_type 42 false in let g = define_global "hello_world" v m in if not (write_bitcode_file m filename) then exit 1; dispose_module m; $ ocamlc -cc g++ llvm.cma llvm_bitwriter.cma -o example example.ml File "example.ml", line 11, characters 6-7: Warning Y: unused variable g. $ ./example example.bc $ llvm-dis < example.bc ; ModuleID = '' @hello_world = global i32 42 ; [#uses=0] The ocaml test cases provide effective tests for the C interfaces. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42093 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/lib/llvm.exp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test/lib') diff --git a/test/lib/llvm.exp b/test/lib/llvm.exp index 9a85a1c87a..921bcb5ddd 100644 --- a/test/lib/llvm.exp +++ b/test/lib/llvm.exp @@ -43,7 +43,7 @@ proc execOneLine { test PRS outcome lineno line } { # cases. proc substitute { line test tmpFile } { global srcroot objroot srcdir objdir subdir target_triplet prcontext - global llvmgcc llvmgxx llvmgcc_version llvmgccmajvers + global llvmgcc llvmgxx llvmgcc_version llvmgccmajvers ocamlc global gccpath gxxpath compile_c compile_cxx link shlibext llvmlibsdir set path [file join $srcdir $subdir] @@ -64,6 +64,8 @@ proc substitute { line test tmpFile } { regsub -all {%link} $new_line "$link" new_line #replace %shlibext with shared library extension regsub -all {%shlibext} $new_line "$shlibext" new_line + #replace %ocamlc with ocaml compiler command + regsub -all {%ocamlc} $new_line "$ocamlc" new_line #replace %llvmlibsdir with configure library directory regsub -all {%llvmlibsdir} $new_line "$llvmlibsdir" new_line #replace %p with path to source, -- cgit v1.2.3