Skip to content

rustc: Leak the LLVM module and context. #3552 #7659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,12 @@ pub mod write {
}
// Clean up and return

llvm::LLVMDisposeModule(llmod);
llvm::LLVMContextDispose(llcx);
// Save some time by not destroying the LLVM module
if !sess.opts.leak_llvm {
llvm::LLVMDisposeModule(llmod);
llvm::LLVMContextDispose(llcx);
}

if sess.time_llvm_passes() {
llvm::LLVMRustPrintPassTimings();
}
Expand All @@ -413,8 +417,12 @@ pub mod write {
}
}

llvm::LLVMDisposeModule(llmod);
llvm::LLVMContextDispose(llcx);
// Save some time by not destroying the LLVM module
if !sess.opts.leak_llvm {
llvm::LLVMDisposeModule(llmod);
llvm::LLVMContextDispose(llcx);
}

if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); }
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,8 @@ pub fn build_session_options(binary: @str,
parse_only: parse_only,
no_trans: no_trans,
debugging_opts: debugging_opts,
android_cross_path: android_cross_path
android_cross_path: android_cross_path,
leak_llvm: true
};
return sopts;
}
Expand Down
4 changes: 4 additions & 0 deletions src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ pub struct options {
no_trans: bool,
debugging_opts: uint,
android_cross_path: Option<~str>,
// Destroying the LLVM module takes significant time. Standalone rustc
// will just leak it to save precious seconds.
leak_llvm: bool
}

pub struct crate_metadata {
Expand Down Expand Up @@ -350,6 +353,7 @@ pub fn basic_options() -> @options {
no_trans: false,
debugging_opts: 0u,
android_cross_path: None,
leak_llvm: false
}
}

Expand Down