Skip to content

Commit 08e561a

Browse files
committed
librustc: Disable borrow check debugging even when rustc is compiled with -O0.
This improves -O0 compile times dramatically.
1 parent ca9bb2d commit 08e561a

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

Makefile.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ endif
122122
ifdef TRACE
123123
CFG_RUSTC_FLAGS += -Z trace
124124
endif
125+
ifndef DEBUG_BORROWS
126+
RUSTFLAGS_STAGE1 += -Z no-debug-borrows
127+
RUSTFLAGS_STAGE2 += -Z no-debug-borrows
128+
endif
125129

126130
# platform-specific auto-configuration
127131
include $(CFG_SRC_DIR)mk/platform.mk

src/librustc/driver/session.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pub static debug_info: uint = 1 << 20;
6666
pub static extra_debug_info: uint = 1 << 21;
6767
pub static statik: uint = 1 << 22;
6868
pub static print_link_args: uint = 1 << 23;
69+
pub static no_debug_borrows: uint = 1 << 24;
6970

7071
pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
7172
~[(~"verbose", ~"in general, enable more debug printouts", verbose),
@@ -100,7 +101,10 @@ pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
100101
extra_debug_info),
101102
(~"debug-info", ~"Produce debug info (experimental)", debug_info),
102103
(~"static", ~"Use or produce static libraries or binaries " +
103-
"(experimental)", statik)
104+
"(experimental)", statik),
105+
(~"no-debug-borrows",
106+
~"do not show where borrow checks fail",
107+
no_debug_borrows),
104108
]
105109
}
106110

@@ -141,7 +145,7 @@ pub struct options {
141145
parse_only: bool,
142146
no_trans: bool,
143147
debugging_opts: uint,
144-
android_cross_path: Option<~str>
148+
android_cross_path: Option<~str>,
145149
}
146150

147151
pub struct crate_metadata {
@@ -271,6 +275,9 @@ pub impl Session_ {
271275
fn no_monomorphic_collapse(@self) -> bool {
272276
self.debugging_opt(no_monomorphic_collapse)
273277
}
278+
fn debug_borrows(@self) -> bool {
279+
self.opts.optimize == No && !self.debugging_opt(no_debug_borrows)
280+
}
274281

275282
fn str_of(@self, id: ast::ident) -> @~str {
276283
self.parse_sess.interner.get(id)
@@ -308,7 +315,7 @@ pub fn basic_options() -> @options {
308315
parse_only: false,
309316
no_trans: false,
310317
debugging_opts: 0u,
311-
android_cross_path: None
318+
android_cross_path: None,
312319
}
313320
}
314321

src/librustc/middle/trans/write_guard.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub fn return_to_mut(mut bcx: block,
7474
let bits_val =
7575
Load(bcx, bits_val_ref);
7676

77-
if bcx.tcx().sess.opts.optimize == session::No {
77+
if bcx.tcx().sess.debug_borrows() {
7878
bcx = callee::trans_lang_call(
7979
bcx,
8080
bcx.tcx().lang_items.unrecord_borrow_fn(),
@@ -160,7 +160,7 @@ fn root(datum: &Datum,
160160
],
161161
expr::SaveIn(scratch_bits.val));
162162

163-
if bcx.tcx().sess.opts.optimize == session::No {
163+
if bcx.tcx().sess.debug_borrows() {
164164
bcx = callee::trans_lang_call(
165165
bcx,
166166
bcx.tcx().lang_items.record_borrow_fn(),

0 commit comments

Comments
 (0)