Skip to content

Commit 232d8e5

Browse files
committed
auto merge of #11665 : alexcrichton/rust/zed-cleanup, r=brson
* Stop using hardcoded numbers that have to all get updated when something changes (inevitable errors and rebase conflicts) as well as removes some unneeded -Z options (obsoleted over time). * Remove `std::rt::borrowck`
2 parents 43cffe9 + d84c336 commit 232d8e5

File tree

9 files changed

+105
-390
lines changed

9 files changed

+105
-390
lines changed

Makefile.in

-5
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,6 @@ endif
124124
ifdef TRACE
125125
CFG_RUSTC_FLAGS += -Z trace
126126
endif
127-
ifndef DEBUG_BORROWS
128-
RUSTFLAGS_STAGE0 += -Z no-debug-borrows
129-
RUSTFLAGS_STAGE1 += -Z no-debug-borrows
130-
RUSTFLAGS_STAGE2 += -Z no-debug-borrows
131-
endif
132127

133128
# The executables crated during this compilation process have no need to include
134129
# static copies of libstd and libextra. We also generate dynamic versions of all

src/librustc/back/link.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub mod write {
126126
session::Default => lib::llvm::CodeGenLevelDefault,
127127
session::Aggressive => lib::llvm::CodeGenLevelAggressive,
128128
};
129-
let use_softfp = sess.opts.debugging_opts & session::use_softfp != 0;
129+
let use_softfp = sess.opts.debugging_opts & session::USE_SOFTFP != 0;
130130

131131
let tm = sess.targ_cfg.target_strs.target_triple.with_c_str(|T| {
132132
sess.opts.target_cpu.with_c_str(|CPU| {
@@ -156,7 +156,6 @@ pub mod write {
156156
pass.with_c_str(|s| llvm::LLVMRustAddPass(fpm, s))
157157
};
158158
if !sess.no_verify() { assert!(addpass("verify")); }
159-
if sess.lint_llvm() { assert!(addpass("lint")); }
160159

161160
if !sess.no_prepopulate_passes() {
162161
llvm::LLVMRustAddAnalysisPasses(tm, fpm, llmod);
@@ -988,7 +987,7 @@ fn link_natively(sess: Session, dylib: bool, obj_filename: &Path,
988987
let mut cc_args = sess.targ_cfg.target_strs.cc_args.clone();
989988
cc_args.push_all_move(link_args(sess, dylib, tmpdir.path(),
990989
obj_filename, out_filename));
991-
if (sess.opts.debugging_opts & session::print_link_args) != 0 {
990+
if (sess.opts.debugging_opts & session::PRINT_LINK_ARGS) != 0 {
992991
println!("{} link args: '{}'", cc_prog, cc_args.connect("' '"));
993992
}
994993

src/librustc/driver/driver.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -759,22 +759,22 @@ pub fn build_session_options(binary: ~str,
759759
}
760760
}
761761

762-
let mut debugging_opts = 0u;
762+
let mut debugging_opts = 0;
763763
let debug_flags = matches.opt_strs("Z");
764764
let debug_map = session::debugging_opts_map();
765765
for debug_flag in debug_flags.iter() {
766-
let mut this_bit = 0u;
766+
let mut this_bit = 0;
767767
for tuple in debug_map.iter() {
768768
let (name, bit) = match *tuple { (ref a, _, b) => (a, b) };
769769
if *name == *debug_flag { this_bit = bit; break; }
770770
}
771-
if this_bit == 0u {
771+
if this_bit == 0 {
772772
early_error(demitter, format!("unknown debug flag: {}", *debug_flag))
773773
}
774774
debugging_opts |= this_bit;
775775
}
776776

777-
if debugging_opts & session::debug_llvm != 0 {
777+
if debugging_opts & session::DEBUG_LLVM != 0 {
778778
unsafe { llvm::LLVMSetDebug(1); }
779779
}
780780

@@ -797,7 +797,7 @@ pub fn build_session_options(binary: ~str,
797797
let target_feature = matches.opt_str("target-feature").unwrap_or(~"");
798798
let save_temps = matches.opt_present("save-temps");
799799
let opt_level = {
800-
if (debugging_opts & session::no_opt) != 0 {
800+
if (debugging_opts & session::NO_OPT) != 0 {
801801
No
802802
} else if matches.opt_present("O") {
803803
if matches.opt_present("opt-level") {
@@ -816,9 +816,9 @@ pub fn build_session_options(binary: ~str,
816816
}
817817
} else { No }
818818
};
819-
let gc = debugging_opts & session::gc != 0;
820-
let extra_debuginfo = debugging_opts & session::extra_debug_info != 0;
821-
let debuginfo = debugging_opts & session::debug_info != 0 ||
819+
let gc = debugging_opts & session::GC != 0;
820+
let extra_debuginfo = debugging_opts & session::EXTRA_DEBUG_INFO != 0;
821+
let debuginfo = debugging_opts & session::DEBUG_INFO != 0 ||
822822
extra_debuginfo;
823823

824824
let addl_lib_search_paths = matches.opt_strs("L").map(|s| {

src/librustc/driver/session.rs

+94-102
Original file line numberDiff line numberDiff line change
@@ -39,89 +39,91 @@ pub struct Config {
3939
uint_type: UintTy,
4040
}
4141

42-
pub static verbose: uint = 1 << 0;
43-
pub static time_passes: uint = 1 << 1;
44-
pub static count_llvm_insns: uint = 1 << 2;
45-
pub static time_llvm_passes: uint = 1 << 3;
46-
pub static trans_stats: uint = 1 << 4;
47-
pub static asm_comments: uint = 1 << 5;
48-
pub static no_verify: uint = 1 << 6;
49-
pub static borrowck_stats: uint = 1 << 7;
50-
pub static borrowck_note_pure: uint = 1 << 8;
51-
pub static borrowck_note_loan: uint = 1 << 9;
52-
pub static no_landing_pads: uint = 1 << 10;
53-
pub static debug_llvm: uint = 1 << 11;
54-
pub static count_type_sizes: uint = 1 << 12;
55-
pub static meta_stats: uint = 1 << 13;
56-
pub static no_opt: uint = 1 << 14;
57-
pub static gc: uint = 1 << 15;
58-
pub static debug_info: uint = 1 << 16;
59-
pub static extra_debug_info: uint = 1 << 17;
60-
pub static print_link_args: uint = 1 << 18;
61-
pub static no_debug_borrows: uint = 1 << 19;
62-
pub static lint_llvm: uint = 1 << 20;
63-
pub static print_llvm_passes: uint = 1 << 21;
64-
pub static no_vectorize_loops: uint = 1 << 22;
65-
pub static no_vectorize_slp: uint = 1 << 23;
66-
pub static no_prepopulate_passes: uint = 1 << 24;
67-
pub static use_softfp: uint = 1 << 25;
68-
pub static gen_crate_map: uint = 1 << 26;
69-
pub static prefer_dynamic: uint = 1 << 27;
70-
pub static no_integrated_as: uint = 1 << 28;
71-
pub static lto: uint = 1 << 29;
42+
macro_rules! debugging_opts(
43+
([ $opt:ident ] $cnt:expr ) => (
44+
pub static $opt: u64 = 1 << $cnt;
45+
);
46+
([ $opt:ident, $($rest:ident),* ] $cnt:expr ) => (
47+
pub static $opt: u64 = 1 << $cnt;
48+
debugging_opts!([ $($rest),* ] $cnt + 1)
49+
)
50+
)
7251

73-
pub fn debugging_opts_map() -> ~[(&'static str, &'static str, uint)] {
74-
~[("verbose", "in general, enable more debug printouts", verbose),
75-
("time-passes", "measure time of each rustc pass", time_passes),
52+
debugging_opts!(
53+
[
54+
VERBOSE,
55+
TIME_PASSES,
56+
COUNT_LLVM_INSNS,
57+
TIME_LLVM_PASSES,
58+
TRANS_STATS,
59+
ASM_COMMENTS,
60+
NO_VERIFY,
61+
BORROWCK_STATS,
62+
NO_LANDING_PADS,
63+
DEBUG_LLVM,
64+
COUNT_TYPE_SIZES,
65+
META_STATS,
66+
NO_OPT,
67+
GC,
68+
DEBUG_INFO,
69+
EXTRA_DEBUG_INFO,
70+
PRINT_LINK_ARGS,
71+
PRINT_LLVM_PASSES,
72+
NO_VECTORIZE_LOOPS,
73+
NO_VECTORIZE_SLP,
74+
NO_PREPOPULATE_PASSES,
75+
USE_SOFTFP,
76+
GEN_CRATE_MAP,
77+
PREFER_DYNAMIC,
78+
NO_INTEGRATED_AS,
79+
LTO
80+
]
81+
0
82+
)
83+
84+
pub fn debugging_opts_map() -> ~[(&'static str, &'static str, u64)] {
85+
~[("verbose", "in general, enable more debug printouts", VERBOSE),
86+
("time-passes", "measure time of each rustc pass", TIME_PASSES),
7687
("count-llvm-insns", "count where LLVM \
77-
instrs originate", count_llvm_insns),
88+
instrs originate", COUNT_LLVM_INSNS),
7889
("time-llvm-passes", "measure time of each LLVM pass",
79-
time_llvm_passes),
80-
("trans-stats", "gather trans statistics", trans_stats),
81-
("asm-comments", "generate comments into the assembly (may change behavior)", asm_comments),
82-
("no-verify", "skip LLVM verification", no_verify),
83-
("borrowck-stats", "gather borrowck statistics", borrowck_stats),
84-
("borrowck-note-pure", "note where purity is req'd",
85-
borrowck_note_pure),
86-
("borrowck-note-loan", "note where loans are req'd",
87-
borrowck_note_loan),
90+
TIME_LLVM_PASSES),
91+
("trans-stats", "gather trans statistics", TRANS_STATS),
92+
("asm-comments", "generate comments into the assembly (may change behavior)",
93+
ASM_COMMENTS),
94+
("no-verify", "skip LLVM verification", NO_VERIFY),
95+
("borrowck-stats", "gather borrowck statistics", BORROWCK_STATS),
8896
("no-landing-pads", "omit landing pads for unwinding",
89-
no_landing_pads),
90-
("debug-llvm", "enable debug output from LLVM", debug_llvm),
97+
NO_LANDING_PADS),
98+
("debug-llvm", "enable debug output from LLVM", DEBUG_LLVM),
9199
("count-type-sizes", "count the sizes of aggregate types",
92-
count_type_sizes),
93-
("meta-stats", "gather metadata statistics", meta_stats),
94-
("no-opt", "do not optimize, even if -O is passed", no_opt),
95-
("print-link-args", "Print the arguments passed to the linker", print_link_args),
96-
("gc", "Garbage collect shared data (experimental)", gc),
100+
COUNT_TYPE_SIZES),
101+
("meta-stats", "gather metadata statistics", META_STATS),
102+
("no-opt", "do not optimize, even if -O is passed", NO_OPT),
103+
("print-link-args", "Print the arguments passed to the linker",
104+
PRINT_LINK_ARGS),
105+
("gc", "Garbage collect shared data (experimental)", GC),
97106
("extra-debug-info", "Extra debugging info (experimental)",
98-
extra_debug_info),
99-
("debug-info", "Produce debug info (experimental)", debug_info),
100-
("no-debug-borrows",
101-
"do not show where borrow checks fail",
102-
no_debug_borrows),
103-
("lint-llvm",
104-
"Run the LLVM lint pass on the pre-optimization IR",
105-
lint_llvm),
107+
EXTRA_DEBUG_INFO),
108+
("debug-info", "Produce debug info (experimental)", DEBUG_INFO),
106109
("print-llvm-passes",
107110
"Prints the llvm optimization passes being run",
108-
print_llvm_passes),
111+
PRINT_LLVM_PASSES),
109112
("no-prepopulate-passes",
110113
"Don't pre-populate the pass managers with a list of passes, only use \
111114
the passes from --passes",
112-
no_prepopulate_passes),
115+
NO_PREPOPULATE_PASSES),
113116
("no-vectorize-loops",
114117
"Don't run the loop vectorization optimization passes",
115-
no_vectorize_loops),
116-
("no-vectorize-slp",
117-
"Don't run LLVM's SLP vectorization passes",
118-
no_vectorize_slp),
119-
("soft-float", "Generate software floating point library calls", use_softfp),
120-
("gen-crate-map", "Force generation of a toplevel crate map", gen_crate_map),
121-
("prefer-dynamic", "Prefer dynamic linking to static linking", prefer_dynamic),
118+
NO_VECTORIZE_LOOPS),
119+
("no-vectorize-slp", "Don't run LLVM's SLP vectorization passes",
120+
NO_VECTORIZE_SLP),
121+
("soft-float", "Generate software floating point library calls", USE_SOFTFP),
122+
("gen-crate-map", "Force generation of a toplevel crate map", GEN_CRATE_MAP),
123+
("prefer-dynamic", "Prefer dynamic linking to static linking", PREFER_DYNAMIC),
122124
("no-integrated-as",
123-
"Use external assembler rather than LLVM's integrated one", no_integrated_as),
124-
("lto", "Perform LLVM link-time optimizations", lto),
125+
"Use external assembler rather than LLVM's integrated one", NO_INTEGRATED_AS),
126+
("lto", "Perform LLVM link-time optimizations", LTO),
125127
]
126128
}
127129

@@ -168,7 +170,7 @@ pub struct Options {
168170
parse_only: bool,
169171
no_trans: bool,
170172
no_analysis: bool,
171-
debugging_opts: uint,
173+
debugging_opts: u64,
172174
android_cross_path: Option<~str>,
173175
/// Whether to write dependency files. It's (enabled, optional filename).
174176
write_dependency_info: (bool, Option<Path>),
@@ -291,66 +293,56 @@ impl Session_ {
291293
pub fn diagnostic(&self) -> @diagnostic::SpanHandler {
292294
self.span_diagnostic
293295
}
294-
pub fn debugging_opt(&self, opt: uint) -> bool {
295-
(self.opts.debugging_opts & opt) != 0u
296+
pub fn debugging_opt(&self, opt: u64) -> bool {
297+
(self.opts.debugging_opts & opt) != 0
296298
}
297299
// This exists to help with refactoring to eliminate impossible
298300
// cases later on
299301
pub fn impossible_case(&self, sp: Span, msg: &str) -> ! {
300302
self.span_bug(sp, format!("Impossible case reached: {}", msg));
301303
}
302-
pub fn verbose(&self) -> bool { self.debugging_opt(verbose) }
303-
pub fn time_passes(&self) -> bool { self.debugging_opt(time_passes) }
304+
pub fn verbose(&self) -> bool { self.debugging_opt(VERBOSE) }
305+
pub fn time_passes(&self) -> bool { self.debugging_opt(TIME_PASSES) }
304306
pub fn count_llvm_insns(&self) -> bool {
305-
self.debugging_opt(count_llvm_insns)
307+
self.debugging_opt(COUNT_LLVM_INSNS)
306308
}
307309
pub fn count_type_sizes(&self) -> bool {
308-
self.debugging_opt(count_type_sizes)
310+
self.debugging_opt(COUNT_TYPE_SIZES)
309311
}
310312
pub fn time_llvm_passes(&self) -> bool {
311-
self.debugging_opt(time_llvm_passes)
312-
}
313-
pub fn trans_stats(&self) -> bool { self.debugging_opt(trans_stats) }
314-
pub fn meta_stats(&self) -> bool { self.debugging_opt(meta_stats) }
315-
pub fn asm_comments(&self) -> bool { self.debugging_opt(asm_comments) }
316-
pub fn no_verify(&self) -> bool { self.debugging_opt(no_verify) }
317-
pub fn lint_llvm(&self) -> bool { self.debugging_opt(lint_llvm) }
318-
pub fn borrowck_stats(&self) -> bool { self.debugging_opt(borrowck_stats) }
319-
pub fn borrowck_note_pure(&self) -> bool {
320-
self.debugging_opt(borrowck_note_pure)
321-
}
322-
pub fn borrowck_note_loan(&self) -> bool {
323-
self.debugging_opt(borrowck_note_loan)
324-
}
325-
pub fn debug_borrows(&self) -> bool {
326-
self.opts.optimize == No && !self.debugging_opt(no_debug_borrows)
313+
self.debugging_opt(TIME_LLVM_PASSES)
327314
}
315+
pub fn trans_stats(&self) -> bool { self.debugging_opt(TRANS_STATS) }
316+
pub fn meta_stats(&self) -> bool { self.debugging_opt(META_STATS) }
317+
pub fn asm_comments(&self) -> bool { self.debugging_opt(ASM_COMMENTS) }
318+
pub fn no_verify(&self) -> bool { self.debugging_opt(NO_VERIFY) }
319+
pub fn borrowck_stats(&self) -> bool { self.debugging_opt(BORROWCK_STATS) }
328320
pub fn print_llvm_passes(&self) -> bool {
329-
self.debugging_opt(print_llvm_passes)
321+
self.debugging_opt(PRINT_LLVM_PASSES)
330322
}
331323
pub fn no_prepopulate_passes(&self) -> bool {
332-
self.debugging_opt(no_prepopulate_passes)
324+
self.debugging_opt(NO_PREPOPULATE_PASSES)
333325
}
334326
pub fn no_vectorize_loops(&self) -> bool {
335-
self.debugging_opt(no_vectorize_loops)
327+
self.debugging_opt(NO_VECTORIZE_LOOPS)
336328
}
337329
pub fn no_vectorize_slp(&self) -> bool {
338-
self.debugging_opt(no_vectorize_slp)
330+
self.debugging_opt(NO_VECTORIZE_SLP)
339331
}
340332
pub fn gen_crate_map(&self) -> bool {
341-
self.debugging_opt(gen_crate_map)
333+
self.debugging_opt(GEN_CRATE_MAP)
342334
}
343335
pub fn prefer_dynamic(&self) -> bool {
344-
self.debugging_opt(prefer_dynamic)
336+
self.debugging_opt(PREFER_DYNAMIC)
345337
}
346338
pub fn no_integrated_as(&self) -> bool {
347-
self.debugging_opt(no_integrated_as)
339+
self.debugging_opt(NO_INTEGRATED_AS)
348340
}
349341
pub fn lto(&self) -> bool {
350-
self.debugging_opt(lto)
342+
self.debugging_opt(LTO)
351343
}
352344
pub fn no_landing_pads(&self) -> bool {
353-
self.debugging_opt(no_landing_pads)
345+
self.debugging_opt(NO_LANDING_PADS)
354346
}
355347

356348
// pointless function, now...
@@ -396,7 +388,7 @@ pub fn basic_options() -> @Options {
396388
parse_only: false,
397389
no_trans: false,
398390
no_analysis: false,
399-
debugging_opts: 0u,
391+
debugging_opts: 0,
400392
android_cross_path: None,
401393
write_dependency_info: (false, None),
402394
print_metas: (false, false, false),

src/librustdoc/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn runtest(test: &str, cratename: &str, libs: HashSet<Path>) {
104104
maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()),
105105
addl_lib_search_paths: @RefCell::new(libs),
106106
outputs: ~[session::OutputExecutable],
107-
debugging_opts: session::prefer_dynamic,
107+
debugging_opts: session::PREFER_DYNAMIC,
108108
.. (*session::basic_options()).clone()
109109
};
110110

0 commit comments

Comments
 (0)