diff options
| author | Zack Corr <zack@z0w0.me> | 2012-08-26 22:40:21 +1000 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-08-31 16:20:35 -0700 |
| commit | 7993f4820995c9b26d73e8a58bb8f3c0e2e79d47 (patch) | |
| tree | 449106cbe7bdd17cf03b3c93c0559957b114e099 /src/rustc | |
| parent | d7aa9918ef1673edcef261da41075203de5b15b3 (diff) | |
| download | rust-7993f4820995c9b26d73e8a58bb8f3c0e2e79d47.tar.gz rust-7993f4820995c9b26d73e8a58bb8f3c0e2e79d47.zip | |
jit: Add custom memory manager (still segfaulting)
Diffstat (limited to 'src/rustc')
| -rw-r--r-- | src/rustc/back/link.rs | 33 | ||||
| -rw-r--r-- | src/rustc/lib/llvm.rs | 10 |
2 files changed, 36 insertions, 7 deletions
diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs index 04c38c11d62..06d90e982c1 100644 --- a/src/rustc/back/link.rs +++ b/src/rustc/back/link.rs @@ -160,14 +160,37 @@ mod write { llvm::LLVMAddCFGSimplificationPass(pm.llpm);*/ // JIT execution takes ownership of the module, - // so don't dispose and return. + // so don't dispose and return. Due to a weird bug + // with dynamic libraries, we need to separate jitting + // into two functions and load crates inbetween. + + if !llvm::LLVMRustPrepareJIT(pm.llpm, + llmod, + CodeGenOptLevel, + true) { + llvm_err(sess, ~"Could not JIT"); + } + + // We need to tell LLVM where to resolve all linked + // symbols from. The equivalent of -lstd, -lcore, etc. + /*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}; + }); + }*/ - if !llvm::LLVMRustJIT(pm.llpm, - llmod, - CodeGenOptLevel, - true) { + if !llvm::LLVMRustExecuteJIT() { llvm_err(sess, ~"Could not JIT"); } + if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); } return; } diff --git a/src/rustc/lib/llvm.rs b/src/rustc/lib/llvm.rs index 5c8bab166ec..ec9c669501b 100644 --- a/src/rustc/lib/llvm.rs +++ b/src/rustc/lib/llvm.rs @@ -986,12 +986,18 @@ extern mod llvm { call. */ fn LLVMRustGetLastError() -> *c_char; - /** JIT the module. **/ - fn LLVMRustJIT(PM: PassManagerRef, + /** Load a shared library to resolve symbols against. */ + fn LLVMRustLoadLibrary(Filename: *c_char) -> bool; + + /** Create the JIT engine. */ + fn LLVMRustPrepareJIT(PM: PassManagerRef, M: ModuleRef, OptLevel: c_int, EnableSegmentedStacks: bool) -> bool; + /** Execute the JIT engine. */ + fn LLVMRustExecuteJIT() -> bool; + /** Parses the bitcode in the given memory buffer. */ fn LLVMRustParseBitcode(MemBuf: MemoryBufferRef) -> ModuleRef; |
