Skip to content

Commit

Permalink
librustc: Disable borrow check debugging even when rustc is compiled …
Browse files Browse the repository at this point in the history
…with -O0.

This improves -O0 compile times dramatically.
  • Loading branch information
pcwalton committed May 23, 2013
1 parent ca9bb2d commit 08e561a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ endif
ifdef TRACE
CFG_RUSTC_FLAGS += -Z trace
endif
ifndef DEBUG_BORROWS
RUSTFLAGS_STAGE1 += -Z no-debug-borrows
RUSTFLAGS_STAGE2 += -Z no-debug-borrows
endif

# platform-specific auto-configuration
include $(CFG_SRC_DIR)mk/platform.mk
Expand Down
13 changes: 10 additions & 3 deletions src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub static debug_info: uint = 1 << 20;
pub static extra_debug_info: uint = 1 << 21;
pub static statik: uint = 1 << 22;
pub static print_link_args: uint = 1 << 23;
pub static no_debug_borrows: uint = 1 << 24;

pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
~[(~"verbose", ~"in general, enable more debug printouts", verbose),
Expand Down Expand Up @@ -100,7 +101,10 @@ pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
extra_debug_info),
(~"debug-info", ~"Produce debug info (experimental)", debug_info),
(~"static", ~"Use or produce static libraries or binaries " +
"(experimental)", statik)
"(experimental)", statik),
(~"no-debug-borrows",
~"do not show where borrow checks fail",
no_debug_borrows),
]
}

Expand Down Expand Up @@ -141,7 +145,7 @@ pub struct options {
parse_only: bool,
no_trans: bool,
debugging_opts: uint,
android_cross_path: Option<~str>
android_cross_path: Option<~str>,
}

pub struct crate_metadata {
Expand Down Expand Up @@ -271,6 +275,9 @@ pub impl Session_ {
fn no_monomorphic_collapse(@self) -> bool {
self.debugging_opt(no_monomorphic_collapse)
}
fn debug_borrows(@self) -> bool {
self.opts.optimize == No && !self.debugging_opt(no_debug_borrows)
}

fn str_of(@self, id: ast::ident) -> @~str {
self.parse_sess.interner.get(id)
Expand Down Expand Up @@ -308,7 +315,7 @@ pub fn basic_options() -> @options {
parse_only: false,
no_trans: false,
debugging_opts: 0u,
android_cross_path: None
android_cross_path: None,
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/write_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn return_to_mut(mut bcx: block,
let bits_val =
Load(bcx, bits_val_ref);

if bcx.tcx().sess.opts.optimize == session::No {
if bcx.tcx().sess.debug_borrows() {
bcx = callee::trans_lang_call(
bcx,
bcx.tcx().lang_items.unrecord_borrow_fn(),
Expand Down Expand Up @@ -160,7 +160,7 @@ fn root(datum: &Datum,
],
expr::SaveIn(scratch_bits.val));

if bcx.tcx().sess.opts.optimize == session::No {
if bcx.tcx().sess.debug_borrows() {
bcx = callee::trans_lang_call(
bcx,
bcx.tcx().lang_items.record_borrow_fn(),
Expand Down

0 comments on commit 08e561a

Please sign in to comment.