[PATCH] D35899: [OCaml] Fix undefined reference to LLVMDumpType() with NDEBUG
Michał Górny via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 26 09:29:31 PDT 2017
mgorny created this revision.
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 https://reviews.llvm.org/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.
Repository:
rL LLVM
https://reviews.llvm.org/D35899
Files:
bindings/ocaml/llvm/llvm.ml
bindings/ocaml/llvm/llvm.mli
bindings/ocaml/llvm/llvm_ocaml.c
Index: bindings/ocaml/llvm/llvm_ocaml.c
===================================================================
--- bindings/ocaml/llvm/llvm_ocaml.c
+++ bindings/ocaml/llvm/llvm_ocaml.c
@@ -336,7 +336,12 @@
/* lltype -> unit */
CAMLprim value llvm_dump_type(LLVMTypeRef Val) {
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVMDumpType(Val);
+#else
+ char Message[] = "dump";
+ llvm_raise(*caml_named_value("Llvm.FeatureDisabled"), Message);
+#endif
return Val_unit;
}
Index: bindings/ocaml/llvm/llvm.mli
===================================================================
--- bindings/ocaml/llvm/llvm.mli
+++ bindings/ocaml/llvm/llvm.mli
@@ -371,6 +371,8 @@
(** {6 Exceptions} *)
+exception FeatureDisabled of string
+
exception IoError of string
Index: bindings/ocaml/llvm/llvm.ml
===================================================================
--- bindings/ocaml/llvm/llvm.ml
+++ bindings/ocaml/llvm/llvm.ml
@@ -20,6 +20,10 @@
type llmemorybuffer
type llmdkind
+exception FeatureDisabled of string
+
+let () = Callback.register_exception "Llvm.FeatureDisabled" (FeatureDisabled "")
+
module TypeKind = struct
type t =
| Void
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35899.108305.patch
Type: text/x-patch
Size: 1169 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170726/cfea94cb/attachment.bin>
More information about the llvm-commits
mailing list