Skip to content

Commit 7993f48

Browse files
z0w0brson
authored andcommitted
jit: Add custom memory manager (still segfaulting)
1 parent d7aa991 commit 7993f48

File tree

5 files changed

+275
-184
lines changed

5 files changed

+275
-184
lines changed

mk/libuv/ia32/win/src/libuv/uv.target.mk.bak

Lines changed: 0 additions & 167 deletions
This file was deleted.

src/rustc/back/link.rs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,37 @@ mod write {
160160
llvm::LLVMAddCFGSimplificationPass(pm.llpm);*/
161161

162162
// JIT execution takes ownership of the module,
163-
// so don't dispose and return.
163+
// so don't dispose and return. Due to a weird bug
164+
// with dynamic libraries, we need to separate jitting
165+
// into two functions and load crates inbetween.
166+
167+
if !llvm::LLVMRustPrepareJIT(pm.llpm,
168+
llmod,
169+
CodeGenOptLevel,
170+
true) {
171+
llvm_err(sess, ~"Could not JIT");
172+
}
173+
174+
// We need to tell LLVM where to resolve all linked
175+
// symbols from. The equivalent of -lstd, -lcore, etc.
176+
/*let cstore = sess.cstore;
177+
for cstore::get_used_crate_files(cstore).each |cratepath| {
178+
debug!{"linking: %s", cratepath};
179+
180+
let _: () = str::as_c_str(
181+
cratepath,
182+
|buf_t| {
183+
if !llvm::LLVMRustLoadLibrary(buf_t) {
184+
llvm_err(sess, ~"Could not link");
185+
}
186+
debug!{"linked: %s", cratepath};
187+
});
188+
}*/
164189

165-
if !llvm::LLVMRustJIT(pm.llpm,
166-
llmod,
167-
CodeGenOptLevel,
168-
true) {
190+
if !llvm::LLVMRustExecuteJIT() {
169191
llvm_err(sess, ~"Could not JIT");
170192
}
193+
171194
if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); }
172195
return;
173196
}

src/rustc/lib/llvm.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,12 +986,18 @@ extern mod llvm {
986986
call. */
987987
fn LLVMRustGetLastError() -> *c_char;
988988

989-
/** JIT the module. **/
990-
fn LLVMRustJIT(PM: PassManagerRef,
989+
/** Load a shared library to resolve symbols against. */
990+
fn LLVMRustLoadLibrary(Filename: *c_char) -> bool;
991+
992+
/** Create the JIT engine. */
993+
fn LLVMRustPrepareJIT(PM: PassManagerRef,
991994
M: ModuleRef,
992995
OptLevel: c_int,
993996
EnableSegmentedStacks: bool) -> bool;
994997

998+
/** Execute the JIT engine. */
999+
fn LLVMRustExecuteJIT() -> bool;
1000+
9951001
/** Parses the bitcode in the given memory buffer. */
9961002
fn LLVMRustParseBitcode(MemBuf: MemoryBufferRef) -> ModuleRef;
9971003

0 commit comments

Comments
 (0)