Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 9399b84

Browse files
committed
Merging r309321:
------------------------------------------------------------------------ r309321 | mgorny | 2017-07-27 14:13:25 -0700 (Thu, 27 Jul 2017) | 12 lines [OCaml] Fix undefined reference to LLVMDumpType() with NDEBUG Account for the possibility of LLVMDumpType() not being available with NDEBUG in the OCaml bindings. If it is not built into LLVM, make the dump function raise an exception. Since rL293359, the dump functions are built only if either NDEBUG is not defined, or LLVM_ENABLE_DUMP is defined. As a result, if the dump functions are not built in LLVM, the dynamic OCaml libraries fail to load due to undefined LLVMDumpType symbol. Differential Revision: https://reviews.llvm.org/D35899 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_50@309590 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 94d06b0 commit 9399b84

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

bindings/ocaml/llvm/llvm.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ type llattribute
2020
type llmemorybuffer
2121
type llmdkind
2222

23+
exception FeatureDisabled of string
24+
25+
let () = Callback.register_exception "Llvm.FeatureDisabled" (FeatureDisabled "")
26+
2327
module TypeKind = struct
2428
type t =
2529
| Void

bindings/ocaml/llvm/llvm.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ type ('a, 'b) llrev_pos =
371371

372372
(** {6 Exceptions} *)
373373

374+
exception FeatureDisabled of string
375+
374376
exception IoError of string
375377

376378

bindings/ocaml/llvm/llvm_ocaml.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,12 @@ CAMLprim LLVMContextRef llvm_type_context(LLVMTypeRef Ty) {
336336

337337
/* lltype -> unit */
338338
CAMLprim value llvm_dump_type(LLVMTypeRef Val) {
339+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
339340
LLVMDumpType(Val);
341+
#else
342+
caml_raise_with_arg(*caml_named_value("Llvm.FeatureDisabled"),
343+
caml_copy_string("dump"));
344+
#endif
340345
return Val_unit;
341346
}
342347

0 commit comments

Comments
 (0)