about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZack Corr <zack@z0w0.me>2012-09-28 18:05:49 +1000
committerZack Corr <zack@z0w0.me>2012-09-28 18:05:49 +1000
commitb3f418c10ed88163f6d1c6774b51eb69def521f8 (patch)
tree21798177d03b851b3bfb69befba499b705a40d9c
parentca4455666eaf09debf6fe769ba75f90453832981 (diff)
downloadrust-b3f418c10ed88163f6d1c6774b51eb69def521f8.tar.gz
rust-b3f418c10ed88163f6d1c6774b51eb69def521f8.zip
jit: Remove old crate loading code and don't search through loaded crates (use llvm default instead)
-rw-r--r--src/rustc/back/link.rs25
-rw-r--r--src/rustllvm/RustWrapper.cpp13
2 files changed, 4 insertions, 34 deletions
diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs
index 751f0369141..27b566ac28a 100644
--- a/src/rustc/back/link.rs
+++ b/src/rustc/back/link.rs
@@ -105,7 +105,7 @@ mod jit {
         // for us.
 
         let entry = llvm::LLVMRustExecuteJIT(manager,
-                                      pm, m, opt, stacks);
+                                             pm, m, opt, stacks);
 
         if ptr::is_null(entry) {
             llvm_err(sess, ~"Could not JIT");
@@ -223,30 +223,9 @@ mod write {
                 // JIT execution takes ownership of the module,
                 // so don't dispose and return.
 
-                // We need to tell LLVM where to resolve all linked
-                // symbols from. The equivalent of -lstd, -lcore, etc.
-                // By default the JIT will resolve symbols from the std and
-                // core linked into rustc. We don't want that,
-                // incase the user wants to use an older std library.
-                /*let cstore = sess.cstore;
-                for cstore::get_used_crate_files(cstore).each |cratepath| {
-                    debug!{"linking: %s", cratepath};
-
-                    let _: () = str::as_c_str(
-                        cratepath,
-                        |buf_t| {
-                            if !llvm::LLVMRustLoadLibrary(buf_t) {
-                                llvm_err(sess, ~"Could not link");
-                            }
-                            debug!{"linked: %s", cratepath};
-                        });
-                }*/
-
                 jit::exec(sess, pm.llpm, llmod, CodeGenOptLevel, true);
 
-                if sess.time_llvm_passes() {
-                    llvm::LLVMRustPrintPassTimings();
-                }
+                if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); }
                 return;
             }
 
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp
index 72a97953a94..fc2049507ee 100644
--- a/src/rustllvm/RustWrapper.cpp
+++ b/src/rustllvm/RustWrapper.cpp
@@ -282,17 +282,7 @@ void *RustMCJITMemoryManager::getPointerToNamedFunction(const std::string &Name,
 
   const char *NameStr = Name.c_str();
 
-  // Look through loaded crates for symbols.
-
-  for (DenseSet<DynamicLibrary*>::iterator I = crates.begin(),
-       E = crates.end(); I != E; ++I) {
-    void *Ptr = (*I)->getAddressOfSymbol(NameStr);
-
-    if (Ptr) return Ptr;
-  }
-
-  // Fallback to using any symbols LLVM has loaded (generally
-  // from the main program).
+  // Look through loaded crates and main for symbols.
 
   void *Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr);
   if (Ptr) return Ptr;
@@ -365,6 +355,7 @@ LLVMRustExecuteJIT(void* mem,
   PM->run(*unwrap(M));
 
   ExecutionEngine* EE = EngineBuilder(unwrap(M))
+    .setErrorStr(&Err)
     .setTargetOptions(Options)
     .setJITMemoryManager(MM)
     .setOptLevel(OptLevel)