Skip to content

Commit b3f418c

Browse files
committed
jit: Remove old crate loading code and don't search through loaded crates (use llvm default instead)
1 parent ca44556 commit b3f418c

File tree

2 files changed

+4
-34
lines changed

2 files changed

+4
-34
lines changed

src/rustc/back/link.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ mod jit {
105105
// for us.
106106

107107
let entry = llvm::LLVMRustExecuteJIT(manager,
108-
pm, m, opt, stacks);
108+
pm, m, opt, stacks);
109109

110110
if ptr::is_null(entry) {
111111
llvm_err(sess, ~"Could not JIT");
@@ -223,30 +223,9 @@ mod write {
223223
// JIT execution takes ownership of the module,
224224
// so don't dispose and return.
225225

226-
// We need to tell LLVM where to resolve all linked
227-
// symbols from. The equivalent of -lstd, -lcore, etc.
228-
// By default the JIT will resolve symbols from the std and
229-
// core linked into rustc. We don't want that,
230-
// incase the user wants to use an older std library.
231-
/*let cstore = sess.cstore;
232-
for cstore::get_used_crate_files(cstore).each |cratepath| {
233-
debug!{"linking: %s", cratepath};
234-
235-
let _: () = str::as_c_str(
236-
cratepath,
237-
|buf_t| {
238-
if !llvm::LLVMRustLoadLibrary(buf_t) {
239-
llvm_err(sess, ~"Could not link");
240-
}
241-
debug!{"linked: %s", cratepath};
242-
});
243-
}*/
244-
245226
jit::exec(sess, pm.llpm, llmod, CodeGenOptLevel, true);
246227

247-
if sess.time_llvm_passes() {
248-
llvm::LLVMRustPrintPassTimings();
249-
}
228+
if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); }
250229
return;
251230
}
252231

src/rustllvm/RustWrapper.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -282,17 +282,7 @@ void *RustMCJITMemoryManager::getPointerToNamedFunction(const std::string &Name,
282282

283283
const char *NameStr = Name.c_str();
284284

285-
// Look through loaded crates for symbols.
286-
287-
for (DenseSet<DynamicLibrary*>::iterator I = crates.begin(),
288-
E = crates.end(); I != E; ++I) {
289-
void *Ptr = (*I)->getAddressOfSymbol(NameStr);
290-
291-
if (Ptr) return Ptr;
292-
}
293-
294-
// Fallback to using any symbols LLVM has loaded (generally
295-
// from the main program).
285+
// Look through loaded crates and main for symbols.
296286

297287
void *Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr);
298288
if (Ptr) return Ptr;
@@ -365,6 +355,7 @@ LLVMRustExecuteJIT(void* mem,
365355
PM->run(*unwrap(M));
366356

367357
ExecutionEngine* EE = EngineBuilder(unwrap(M))
358+
.setErrorStr(&Err)
368359
.setTargetOptions(Options)
369360
.setJITMemoryManager(MM)
370361
.setOptLevel(OptLevel)

0 commit comments

Comments
 (0)