jit: Remove old crate loading code and don't search through loaded crates (use llvm default instead)

This commit is contained in:
Zack Corr 2012-09-28 18:05:49 +10:00
parent ca4455666e
commit b3f418c10e
2 changed files with 4 additions and 34 deletions

View File

@ -223,30 +223,9 @@ mod write {
// JIT execution takes ownership of the module, // JIT execution takes ownership of the module,
// so don't dispose and return. // 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); jit::exec(sess, pm.llpm, llmod, CodeGenOptLevel, true);
if sess.time_llvm_passes() { if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); }
llvm::LLVMRustPrintPassTimings();
}
return; return;
} }

View File

@ -282,17 +282,7 @@ void *RustMCJITMemoryManager::getPointerToNamedFunction(const std::string &Name,
const char *NameStr = Name.c_str(); const char *NameStr = Name.c_str();
// Look through loaded crates for symbols. // Look through loaded crates and main 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).
void *Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr); void *Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr);
if (Ptr) return Ptr; if (Ptr) return Ptr;
@ -365,6 +355,7 @@ LLVMRustExecuteJIT(void* mem,
PM->run(*unwrap(M)); PM->run(*unwrap(M));
ExecutionEngine* EE = EngineBuilder(unwrap(M)) ExecutionEngine* EE = EngineBuilder(unwrap(M))
.setErrorStr(&Err)
.setTargetOptions(Options) .setTargetOptions(Options)
.setJITMemoryManager(MM) .setJITMemoryManager(MM)
.setOptLevel(OptLevel) .setOptLevel(OptLevel)