OSDN Git Service

Fix the Ocaml bindings for the ExecutionEngine: with the change to build
authorBob Wilson <bob.wilson@apple.com>
Wed, 24 Jun 2009 21:09:18 +0000 (21:09 +0000)
committerBob Wilson <bob.wilson@apple.com>
Wed, 24 Jun 2009 21:09:18 +0000 (21:09 +0000)
libraries instead of relinked objects, the interpreter, JIT, and native
target libraries were not being linked in to an ocaml program using the
ExecutionEngine.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74117 91177308-0d34-0410-b5e6-96231b3b80d8

bindings/ocaml/executionengine/executionengine_ocaml.c
include/llvm-c/ExecutionEngine.h
include/llvm/ExecutionEngine/Interpreter.h
include/llvm/ExecutionEngine/JIT.h
lib/ExecutionEngine/Interpreter/Interpreter.cpp
lib/ExecutionEngine/JIT/JIT.cpp

index ec40338..647759f 100644 (file)
@@ -16,6 +16,7 @@
 \*===----------------------------------------------------------------------===*/
 
 #include "llvm-c/ExecutionEngine.h"
+#include "llvm-c/Target.h"
 #include "caml/alloc.h"
 #include "caml/custom.h"
 #include "caml/fail.h"
 #include <string.h>
 #include <assert.h>
 
+/* Force the LLVM interpreter, JIT, and native target to be linked in. */
+void llvm_initialize(void) {
+  LLVMLinkInInterpreter();
+  LLVMLinkInJIT();
+  LLVMInitializeNativeTarget();
+}
 
 /* Can't use the recommended caml_named_value mechanism for backwards
    compatibility reasons. This is largely equivalent. */
index a31dc82..9877b8d 100644 (file)
@@ -26,6 +26,9 @@
 extern "C" {
 #endif
 
+void LLVMLinkInJIT(void);
+void LLVMLinkInInterpreter(void);
+
 typedef struct LLVMOpaqueGenericValue *LLVMGenericValueRef;
 typedef struct LLVMOpaqueExecutionEngine *LLVMExecutionEngineRef;
 
index b2b0464..7425cdb 100644 (file)
@@ -18,9 +18,7 @@
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include <cstdlib>
 
-namespace llvm {
-  extern void LinkInInterpreter();
-}
+extern "C" void LLVMLinkInInterpreter();
 
 namespace {
   struct ForceInterpreterLinking {
@@ -32,7 +30,7 @@ namespace {
       if (std::getenv("bar") != (char*) -1)
         return;
 
-      llvm::LinkInInterpreter();
+      LLVMLinkInInterpreter();
     }
   } ForceInterpreterLinking;
 }
index d4d1e73..6013db4 100644 (file)
@@ -18,9 +18,7 @@
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include <cstdlib>
 
-namespace llvm {
-  extern void LinkInJIT();
-}
+extern "C" void LLVMLinkInJIT();
 
 namespace {
   struct ForceJITLinking {
@@ -32,7 +30,7 @@ namespace {
       if (std::getenv("bar") != (char*) -1)
         return;
 
-      llvm::LinkInJIT();
+      LLVMLinkInJIT();
     }
   } ForceJITLinking;
 }
index ded65d5..d7f38ef 100644 (file)
@@ -29,10 +29,7 @@ static struct RegisterInterp {
 
 }
 
-namespace llvm {
-  void LinkInInterpreter() {
-  }
-}
+extern "C" void LLVMLinkInInterpreter() { }
 
 /// create - Create a new interpreter object.  This can never fail.
 ///
index 43995cb..14d8d5b 100644 (file)
@@ -60,9 +60,7 @@ static struct RegisterJIT {
 
 }
 
-namespace llvm {
-  void LinkInJIT() {
-  }
+extern "C" void LLVMLinkInJIT() {
 }