Skip to content

Commit a4901b1

Browse files
z0w0brson
authored andcommitted
jit: Add custom memory manager (still segfaulting)
1 parent 7d8f00f commit a4901b1

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
@@ -154,14 +154,37 @@ mod write {
154154
llvm::LLVMAddCFGSimplificationPass(pm.llpm);*/
155155

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

159-
if !llvm::LLVMRustJIT(pm.llpm,
160-
llmod,
161-
CodeGenOptLevel,
162-
true) {
184+
if !llvm::LLVMRustExecuteJIT() {
163185
llvm_err(sess, ~"Could not JIT");
164186
}
187+
165188
if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); }
166189
return;
167190
}

src/rustc/lib/llvm.rs

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

950-
/** JIT the module. **/
951-
fn LLVMRustJIT(PM: PassManagerRef,
950+
/** Load a shared library to resolve symbols against. */
951+
fn LLVMRustLoadLibrary(Filename: *c_char) -> bool;
952+
953+
/** Create the JIT engine. */
954+
fn LLVMRustPrepareJIT(PM: PassManagerRef,
952955
M: ModuleRef,
953956
OptLevel: c_int,
954957
EnableSegmentedStacks: bool) -> bool;
955958

959+
/** Execute the JIT engine. */
960+
fn LLVMRustExecuteJIT() -> bool;
961+
956962
/** Parses the bitcode in the given memory buffer. */
957963
fn LLVMRustParseBitcode(MemBuf: MemoryBufferRef) -> ModuleRef;
958964

0 commit comments

Comments
 (0)