1 (* RUN: cp %s %T/linker.ml
2 * RUN: %ocamlcomp -warn-error A -package llvm.linker -linkpkg %T/linker.ml -o %t
7 (* Note: It takes several seconds for ocamlopt to link an executable with
8 libLLVMCore.a, so it's better to write a big test than a bunch of
14 let context = global_context ()
15 let void_type = Llvm.void_type context
17 (* Tiny unit test framework - really just to help find which line is busted *)
18 let print_checkpoints = false
21 if print_checkpoints then
22 prerr_endline (name ^ ":");
26 (*===-- Linker -----------------------------------------------------------===*)
29 let fty = function_type void_type [| |] in
31 let make_module name =
32 let m = create_module context name in
33 let fn = define_function ("fn_" ^ name) fty m in
34 ignore (build_ret_void (builder_at_end context (entry_block fn)));
38 let m1 = make_module "one"
39 and m2 = make_module "two" in
40 link_modules m1 m2 Mode.PreserveSource;
44 let m1 = make_module "one"
45 and m2 = make_module "two" in
46 link_modules m1 m2 Mode.DestroySource;
49 let m1 = make_module "one"
50 and m2 = make_module "one" in
52 link_modules m1 m2 Mode.PreserveSource;
58 (*===-- Driver ------------------------------------------------------------===*)
61 suite "linker" test_linker