From 08e561ae70bc42b755b3831b3ce880745228892c Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 15 May 2013 14:01:54 -0700 Subject: [PATCH] librustc: Disable borrow check debugging even when rustc is compiled with -O0. This improves -O0 compile times dramatically. --- Makefile.in | 4 ++++ src/librustc/driver/session.rs | 13 ++++++++++--- src/librustc/middle/trans/write_guard.rs | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Makefile.in b/Makefile.in index 8ab704ebe17..9b59c46e5e8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index e2cc285fb7a..a340422d023 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -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), @@ -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), ] } @@ -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 { @@ -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) @@ -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, } } diff --git a/src/librustc/middle/trans/write_guard.rs b/src/librustc/middle/trans/write_guard.rs index 9fd62043112..0d13d27b653 100644 --- a/src/librustc/middle/trans/write_guard.rs +++ b/src/librustc/middle/trans/write_guard.rs @@ -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(), @@ -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(),