Index: bindings/ocaml/llvm/llvm.ml =================================================================== --- bindings/ocaml/llvm/llvm.ml +++ bindings/ocaml/llvm/llvm.ml @@ -683,6 +683,7 @@ external function_call_conv : llvalue -> int = "llvm_function_call_conv" external set_function_call_conv : int -> llvalue -> unit = "llvm_set_function_call_conv" +external link_gc_components : unit -> unit = "llvm_link_gc_components" external gc : llvalue -> string option = "llvm_gc" external set_gc : string option -> llvalue -> unit = "llvm_set_gc" external function_begin : llmodule -> (llmodule, llvalue) llpos Index: bindings/ocaml/llvm/llvm.mli =================================================================== --- bindings/ocaml/llvm/llvm.mli +++ bindings/ocaml/llvm/llvm.mli @@ -1498,6 +1498,12 @@ See the method [llvm::Function::setCallingConv]. *) val set_function_call_conv : int -> llvalue -> unit +(** [link_gc_components] links up up CodeGen and AsmWriter components + related to GC. After a call to this function, ErlangGC, OCamlGC, + and ShadowStackGC will be accessible. See the method + [LLVMLinkGCComponents]. *) +val link_gc_components : unit -> unit + (** [gc f] returns [Some name] if the function [f] has a garbage collection algorithm specified and [None] otherwise. See the method [llvm::Function::getGC]. *) Index: bindings/ocaml/llvm/llvm_ocaml.c =================================================================== --- bindings/ocaml/llvm/llvm_ocaml.c +++ bindings/ocaml/llvm/llvm_ocaml.c @@ -1235,6 +1235,12 @@ } } +/* unit -> unit */ +CAMLprim value llvm_link_gc_components(value Unit) { + LLVMLinkGCComponents(); + return Val_unit; +} + /* string option -> llvalue -> unit */ CAMLprim value llvm_set_gc(value GC, LLVMValueRef Fn) { LLVMSetGC(Fn, GC == Val_int(0)? 0 : String_val(Field(GC, 0))); Index: include/llvm-c/Core.h =================================================================== --- include/llvm-c/Core.h +++ include/llvm-c/Core.h @@ -1906,6 +1906,14 @@ void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC); /** + * Link the Codegen and AsmWriter components related to GC. After a + * call to this function, ErlangGC, OCamlGC and ShadowStackGC will be + * accessible. + * + */ +void LLVMLinkGCComponents(void); + +/** * Obtain the name of the garbage collector to use during code * generation. * Index: lib/CodeGen/CMakeLists.txt =================================================================== --- lib/CodeGen/CMakeLists.txt +++ lib/CodeGen/CMakeLists.txt @@ -32,6 +32,7 @@ LLVMTargetMachine.cpp LatencyPriorityQueue.cpp LexicalScopes.cpp + LinkComponents.cpp LiveDebugVariables.cpp LiveInterval.cpp LiveIntervalAnalysis.cpp Index: lib/CodeGen/LinkGCComponents.cpp =================================================================== --- /dev/null +++ lib/CodeGen/LinkGCComponents.cpp @@ -0,0 +1,4 @@ +#include "llvm/CodeGen/LinkAllCodegenComponents.h" +#include "llvm/CodeGen/LinkAllAsmWriterComponents.h" + +void LLVMLinkGCComponents(void) {}