summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--llvm/bindings/go/llvm/linker.go11
-rw-r--r--llvm/bindings/ocaml/linker/linker_ocaml.c6
-rw-r--r--llvm/bindings/ocaml/linker/llvm_linker.ml8
-rw-r--r--llvm/bindings/ocaml/linker/llvm_linker.mli9
-rw-r--r--llvm/docs/ReleaseNotes.rst3
-rw-r--r--llvm/include/llvm-c/Linker.h10
-rw-r--r--llvm/lib/Linker/LinkModules.cpp2
-rw-r--r--llvm/test/Bindings/OCaml/linker.ml2
8 files changed, 41 insertions, 10 deletions
diff --git a/llvm/bindings/go/llvm/linker.go b/llvm/bindings/go/llvm/linker.go
index 64d794efb94e..31e9ad24bf52 100644
--- a/llvm/bindings/go/llvm/linker.go
+++ b/llvm/bindings/go/llvm/linker.go
@@ -20,9 +20,16 @@ package llvm
import "C"
import "errors"
-func LinkModules(Dest, Src Module) error {
+type LinkerMode C.LLVMLinkerMode
+
+const (
+ LinkerDestroySource = C.LLVMLinkerDestroySource
+ LinkerPreserveSource = C.LLVMLinkerPreserveSource
+)
+
+func LinkModules(Dest, Src Module, Mode LinkerMode) error {
var cmsg *C.char
- failed := C.LLVMLinkModules(Dest.C, Src.C, 0, &cmsg)
+ failed := C.LLVMLinkModules(Dest.C, Src.C, C.LLVMLinkerMode(Mode), &cmsg)
if failed != 0 {
err := errors.New(C.GoString(cmsg))
C.LLVMDisposeMessage(cmsg)
diff --git a/llvm/bindings/ocaml/linker/linker_ocaml.c b/llvm/bindings/ocaml/linker/linker_ocaml.c
index 3b8512aa5953..ed37777d852c 100644
--- a/llvm/bindings/ocaml/linker/linker_ocaml.c
+++ b/llvm/bindings/ocaml/linker/linker_ocaml.c
@@ -23,11 +23,11 @@
void llvm_raise(value Prototype, char *Message);
-/* llmodule -> llmodule -> unit */
-CAMLprim value llvm_link_modules(LLVMModuleRef Dst, LLVMModuleRef Src) {
+/* llmodule -> llmodule -> Mode.t -> unit */
+CAMLprim value llvm_link_modules(LLVMModuleRef Dst, LLVMModuleRef Src, value Mode) {
char* Message;
- if (LLVMLinkModules(Dst, Src, 0, &Message))
+ if (LLVMLinkModules(Dst, Src, Int_val(Mode), &Message))
llvm_raise(*caml_named_value("Llvm_linker.Error"), Message);
return Val_unit;
diff --git a/llvm/bindings/ocaml/linker/llvm_linker.ml b/llvm/bindings/ocaml/linker/llvm_linker.ml
index 3044abd8b6cf..5854d70bb525 100644
--- a/llvm/bindings/ocaml/linker/llvm_linker.ml
+++ b/llvm/bindings/ocaml/linker/llvm_linker.ml
@@ -11,5 +11,11 @@ exception Error of string
let () = Callback.register_exception "Llvm_linker.Error" (Error "")
-external link_modules : Llvm.llmodule -> Llvm.llmodule -> unit
+module Mode = struct
+ type t =
+ | DestroySource
+ | PreserveSource
+end
+
+external link_modules : Llvm.llmodule -> Llvm.llmodule -> Mode.t -> unit
= "llvm_link_modules"
diff --git a/llvm/bindings/ocaml/linker/llvm_linker.mli b/llvm/bindings/ocaml/linker/llvm_linker.mli
index 06c3b92a577e..4def7a8cc983 100644
--- a/llvm/bindings/ocaml/linker/llvm_linker.mli
+++ b/llvm/bindings/ocaml/linker/llvm_linker.mli
@@ -14,6 +14,13 @@
exception Error of string
+(** Linking mode. *)
+module Mode : sig
+ type t =
+ | DestroySource
+ | PreserveSource
+end
+
(** [link_modules dst src mode] links [src] into [dst], raising [Error]
if the linking fails. *)
-val link_modules : Llvm.llmodule -> Llvm.llmodule -> unit \ No newline at end of file
+val link_modules : Llvm.llmodule -> Llvm.llmodule -> Mode.t -> unit \ No newline at end of file
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index edd202781585..04d7f5266510 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -383,6 +383,9 @@ The PreserveSource linker mode was removed
It was fairly broken and was removed.
+The mode is currently still available in the C API for source
+compatibility, but it doesn't have any effect.
+
Garbage Collection
------------------
diff --git a/llvm/include/llvm-c/Linker.h b/llvm/include/llvm-c/Linker.h
index cedde5ea8e3a..a932c6d0f078 100644
--- a/llvm/include/llvm-c/Linker.h
+++ b/llvm/include/llvm-c/Linker.h
@@ -20,13 +20,21 @@
extern "C" {
#endif
+
+/* Note: LLVMLinkerPreserveSource has no effect. */
+typedef enum {
+ LLVMLinkerDestroySource = 0, /* Allow source module to be destroyed. */
+ LLVMLinkerPreserveSource = 1 /* Preserve the source module. */
+} LLVMLinkerMode;
+
+
/* Links the source module into the destination module, taking ownership
* of the source module away from the caller. Optionally returns a
* human-readable description of any errors that occurred in linking.
* OutMessage must be disposed with LLVMDisposeMessage. The return value
* is true if an error occurred, false otherwise. */
LLVMBool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src,
- unsigned Unused, char **OutMessage);
+ LLVMLinkerMode Mode, char **OutMessage);
#ifdef __cplusplus
}
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index 767d465d1bee..d5170adb36a3 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -1749,7 +1749,7 @@ bool Linker::LinkModules(Module *Dest, Module *Src) {
//===----------------------------------------------------------------------===//
LLVMBool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src,
- unsigned Unused, char **OutMessages) {
+ LLVMLinkerMode Mode, char **OutMessages) {
Module *D = unwrap(Dest);
std::string Message;
raw_string_ostream Stream(Message);
diff --git a/llvm/test/Bindings/OCaml/linker.ml b/llvm/test/Bindings/OCaml/linker.ml
index 1ea0be9d3dc3..0a365ff81487 100644
--- a/llvm/test/Bindings/OCaml/linker.ml
+++ b/llvm/test/Bindings/OCaml/linker.ml
@@ -45,7 +45,7 @@ let test_linker () =
let m1 = make_module "one"
and m2 = make_module "two" in
- link_modules m1 m2;
+ link_modules m1 m2 Mode.DestroySource;
dispose_module m1;
let m1 = make_module "one"