[RISCV] Use RISCVSubtarget::is64Bit() instead of hasFeature(RISCV::Feature64Bit)...
[llvm-project.git] / llvm / test / Bindings / OCaml / linker.ml
blob6375be86363144f1134785af27246a015d007782
1 (* RUN: rm -rf %t && mkdir -p %t && cp %s %t/linker.ml
2 * RUN: %ocamlc -g -w +A -package llvm.linker -linkpkg %t/linker.ml -o %t/executable
3 * RUN: %t/executable
4 * RUN: %ocamlopt -g -w +A -package llvm.linker -linkpkg %t/linker.ml -o %t/executable
5 * RUN: %t/executable
6 * XFAIL: vg_leak
7 *)
9 (* Note: It takes several seconds for ocamlopt to link an executable with
10 libLLVMCore.a, so it's better to write a big test than a bunch of
11 little ones. *)
13 open Llvm
14 open Llvm_linker
16 let context = global_context ()
17 let void_type = Llvm.void_type context
19 let diagnostic_handler _ = ()
21 (* Tiny unit test framework - really just to help find which line is busted *)
22 let print_checkpoints = false
24 let suite name f =
25 if print_checkpoints then
26 prerr_endline (name ^ ":");
27 f ()
30 (*===-- Linker -----------------------------------------------------------===*)
32 let test_linker () =
33 set_diagnostic_handler context (Some diagnostic_handler);
35 let fty = function_type void_type [| |] in
37 let make_module name =
38 let m = create_module context name in
39 let fn = define_function ("fn_" ^ name) fty m in
40 ignore (build_ret_void (builder_at_end context (entry_block fn)));
44 let m1 = make_module "one"
45 and m2 = make_module "two" in
46 link_modules m1 m2;
47 dispose_module m1;
49 let m1 = make_module "one"
50 and m2 = make_module "two" in
51 link_modules m1 m2;
52 dispose_module m1;
54 let m1 = make_module "one"
55 and m2 = make_module "one" in
56 try
57 link_modules m1 m2;
58 failwith "must raise"
59 with Error _ ->
60 dispose_module m1
62 (*===-- Driver ------------------------------------------------------------===*)
64 let _ =
65 suite "linker" test_linker