1 // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11
12 use back::target_strs;
13 use back;
14 use driver::driver::host_triple;
15 use front;
16 use metadata::filesearch;
17 use metadata;
18 use middle::lint;
19 use util::nodemap::NodeMap;
20
21 use syntax::attr::AttrMetaMethods;
22 use syntax::ast::NodeId;
23 use syntax::ast::{IntTy, UintTy};
24 use syntax::codemap::Span;
25 use syntax::diagnostic;
26 use syntax::parse::ParseSess;
27 use syntax::{abi, ast, codemap};
28
29 use std::cell::{Cell, RefCell};
30 use collections::HashSet;
31
32 pub struct Config {
33 pub os: abi::Os,
34 pub arch: abi::Architecture,
35 pub target_strs: target_strs::t,
36 pub int_type: IntTy,
37 pub uint_type: UintTy,
38 }
39
40 macro_rules! debugging_opts(
41 ([ $opt:ident ] $cnt:expr ) => (
42 pub static $opt: u64 = 1 << $cnt;
43 );
44 ([ $opt:ident, $($rest:ident),* ] $cnt:expr ) => (
45 pub static $opt: u64 = 1 << $cnt;
46 debugging_opts!([ $($rest),* ] $cnt + 1)
47 )
48 )
49
50 debugging_opts!(
51 [
52 VERBOSE,
53 TIME_PASSES,
54 COUNT_LLVM_INSNS,
55 TIME_LLVM_PASSES,
56 TRANS_STATS,
57 ASM_COMMENTS,
58 NO_VERIFY,
59 BORROWCK_STATS,
60 NO_LANDING_PADS,
61 DEBUG_LLVM,
62 SHOW_SPAN,
63 COUNT_TYPE_SIZES,
64 META_STATS,
65 NO_OPT,
66 GC,
67 PRINT_LINK_ARGS,
68 PRINT_LLVM_PASSES,
69 LTO,
70 AST_JSON,
71 AST_JSON_NOEXPAND,
72 LS
73 ]
74 0
75 )
76
77 pub fn debugging_opts_map() -> Vec<(&'static str, &'static str, u64)> {
78 vec!(("verbose", "in general, enable more debug printouts", VERBOSE),
79 ("time-passes", "measure time of each rustc pass", TIME_PASSES),
80 ("count-llvm-insns", "count where LLVM \
81 instrs originate", COUNT_LLVM_INSNS),
82 ("time-llvm-passes", "measure time of each LLVM pass",
83 TIME_LLVM_PASSES),
84 ("trans-stats", "gather trans statistics", TRANS_STATS),
85 ("asm-comments", "generate comments into the assembly (may change behavior)",
86 ASM_COMMENTS),
87 ("no-verify", "skip LLVM verification", NO_VERIFY),
88 ("borrowck-stats", "gather borrowck statistics", BORROWCK_STATS),
89 ("no-landing-pads", "omit landing pads for unwinding",
90 NO_LANDING_PADS),
91 ("debug-llvm", "enable debug output from LLVM", DEBUG_LLVM),
92 ("show-span", "show spans for compiler debugging", SHOW_SPAN),
93 ("count-type-sizes", "count the sizes of aggregate types",
94 COUNT_TYPE_SIZES),
95 ("meta-stats", "gather metadata statistics", META_STATS),
96 ("no-opt", "do not optimize, even if -O is passed", NO_OPT),
97 ("print-link-args", "Print the arguments passed to the linker",
98 PRINT_LINK_ARGS),
99 ("gc", "Garbage collect shared data (experimental)", GC),
100 ("print-llvm-passes",
101 "Prints the llvm optimization passes being run",
102 PRINT_LLVM_PASSES),
103 ("lto", "Perform LLVM link-time optimizations", LTO),
104 ("ast-json", "Print the AST as JSON and halt", AST_JSON),
105 ("ast-json-noexpand", "Print the pre-expansion AST as JSON and halt", AST_JSON_NOEXPAND),
106 ("ls", "List the symbols defined by a library crate", LS))
107 }
108
109 #[deriving(Clone, Eq)]
110 pub enum OptLevel {
111 No, // -O0
112 Less, // -O1
113 Default, // -O2
114 Aggressive // -O3
115 }
116
117 #[deriving(Clone, Eq)]
118 pub enum DebugInfoLevel {
119 NoDebugInfo,
120 LimitedDebugInfo,
121 FullDebugInfo,
122 }
123
124 #[deriving(Clone)]
125 pub struct Options {
126 // The crate config requested for the session, which may be combined
127 // with additional crate configurations during the compile process
128 pub crate_types: Vec<CrateType>,
129
130 pub gc: bool,
131 pub optimize: OptLevel,
132 pub debuginfo: DebugInfoLevel,
133 pub lint_opts: Vec<(lint::Lint, lint::level)> ,
134 pub output_types: Vec<back::link::OutputType> ,
135 // This was mutable for rustpkg, which updates search paths based on the
136 // parsed code. It remains mutable in case its replacements wants to use
137 // this.
138 pub addl_lib_search_paths: RefCell<HashSet<Path>>,
139 pub maybe_sysroot: Option<Path>,
140 pub target_triple: ~str,
141 // User-specified cfg meta items. The compiler itself will add additional
142 // items to the crate config, and during parsing the entire crate config
143 // will be added to the crate AST node. This should not be used for
144 // anything except building the full crate config prior to parsing.
145 pub cfg: ast::CrateConfig,
146 pub test: bool,
147 pub parse_only: bool,
148 pub no_trans: bool,
149 pub no_analysis: bool,
150 pub debugging_opts: u64,
151 /// Whether to write dependency files. It's (enabled, optional filename).
152 pub write_dependency_info: (bool, Option<Path>),
153 /// Crate id-related things to maybe print. It's (crate_id, crate_name, crate_file_name).
154 pub print_metas: (bool, bool, bool),
155 pub cg: CodegenOptions,
156 }
157
158 // The type of entry function, so
159 // users can have their own entry
160 // functions that don't start a
161 // scheduler
162 #[deriving(Eq)]
163 pub enum EntryFnType {
164 EntryMain,
165 EntryStart,
166 EntryNone,
167 }
168
169 #[deriving(Eq, Ord, Clone, TotalOrd, TotalEq, Hash)]
170 pub enum CrateType {
171 CrateTypeExecutable,
172 CrateTypeDylib,
173 CrateTypeRlib,
174 CrateTypeStaticlib,
175 }
176
177 pub struct Session {
178 pub targ_cfg: Config,
179 pub opts: Options,
180 pub cstore: metadata::cstore::CStore,
181 pub parse_sess: ParseSess,
182 // For a library crate, this is always none
183 pub entry_fn: RefCell<Option<(NodeId, codemap::Span)>>,
184 pub entry_type: Cell<Option<EntryFnType>>,
185 pub macro_registrar_fn: Cell<Option<ast::NodeId>>,
186 pub default_sysroot: Option<Path>,
187 // The name of the root source file of the crate, in the local file system. The path is always
188 // expected to be absolute. `None` means that there is no source file.
189 pub local_crate_source_file: Option<Path>,
190 pub working_dir: Path,
191 pub lints: RefCell<NodeMap<Vec<(lint::Lint, codemap::Span, ~str)>>>,
192 pub node_id: Cell<ast::NodeId>,
193 pub crate_types: RefCell<Vec<CrateType>>,
194 pub features: front::feature_gate::Features,
195
196 /// The maximum recursion limit for potentially infinitely recursive
197 /// operations such as auto-dereference and monomorphization.
198 pub recursion_limit: Cell<uint>,
199 }
200
201 impl Session {
202 pub fn span_fatal(&self, sp: Span, msg: &str) -> ! {
203 self.diagnostic().span_fatal(sp, msg)
204 }
205 pub fn fatal(&self, msg: &str) -> ! {
206 self.diagnostic().handler().fatal(msg)
207 }
208 pub fn span_err(&self, sp: Span, msg: &str) {
209 self.diagnostic().span_err(sp, msg)
210 }
211 pub fn err(&self, msg: &str) {
212 self.diagnostic().handler().err(msg)
213 }
214 pub fn err_count(&self) -> uint {
215 self.diagnostic().handler().err_count()
216 }
217 pub fn has_errors(&self) -> bool {
218 self.diagnostic().handler().has_errors()
219 }
220 pub fn abort_if_errors(&self) {
221 self.diagnostic().handler().abort_if_errors()
222 }
223 pub fn span_warn(&self, sp: Span, msg: &str) {
224 self.diagnostic().span_warn(sp, msg)
225 }
226 pub fn warn(&self, msg: &str) {
227 self.diagnostic().handler().warn(msg)
228 }
229 pub fn span_note(&self, sp: Span, msg: &str) {
230 self.diagnostic().span_note(sp, msg)
231 }
232 pub fn span_end_note(&self, sp: Span, msg: &str) {
233 self.diagnostic().span_end_note(sp, msg)
234 }
235 pub fn fileline_note(&self, sp: Span, msg: &str) {
236 self.diagnostic().fileline_note(sp, msg)
237 }
238 pub fn note(&self, msg: &str) {
239 self.diagnostic().handler().note(msg)
240 }
241 pub fn span_bug(&self, sp: Span, msg: &str) -> ! {
242 self.diagnostic().span_bug(sp, msg)
243 }
244 pub fn bug(&self, msg: &str) -> ! {
245 self.diagnostic().handler().bug(msg)
246 }
247 pub fn span_unimpl(&self, sp: Span, msg: &str) -> ! {
248 self.diagnostic().span_unimpl(sp, msg)
249 }
250 pub fn unimpl(&self, msg: &str) -> ! {
251 self.diagnostic().handler().unimpl(msg)
252 }
253 pub fn add_lint(&self,
254 lint: lint::Lint,
255 id: ast::NodeId,
256 sp: Span,
257 msg: ~str) {
258 let mut lints = self.lints.borrow_mut();
259 match lints.find_mut(&id) {
260 Some(arr) => { arr.push((lint, sp, msg)); return; }
261 None => {}
262 }
263 lints.insert(id, vec!((lint, sp, msg)));
264 }
265 pub fn next_node_id(&self) -> ast::NodeId {
266 self.reserve_node_ids(1)
267 }
268 pub fn reserve_node_ids(&self, count: ast::NodeId) -> ast::NodeId {
269 let v = self.node_id.get();
270
271 match v.checked_add(&count) {
272 Some(next) => { self.node_id.set(next); }
273 None => self.bug("Input too large, ran out of node ids!")
274 }
275
276 v
277 }
278 pub fn diagnostic<'a>(&'a self) -> &'a diagnostic::SpanHandler {
279 &self.parse_sess.span_diagnostic
280 }
281 pub fn debugging_opt(&self, opt: u64) -> bool {
282 (self.opts.debugging_opts & opt) != 0
283 }
284 pub fn codemap<'a>(&'a self) -> &'a codemap::CodeMap {
285 &self.parse_sess.span_diagnostic.cm
286 }
287 // This exists to help with refactoring to eliminate impossible
288 // cases later on
289 pub fn impossible_case(&self, sp: Span, msg: &str) -> ! {
290 self.span_bug(sp, format!("impossible case reached: {}", msg));
291 }
292 pub fn verbose(&self) -> bool { self.debugging_opt(VERBOSE) }
293 pub fn time_passes(&self) -> bool { self.debugging_opt(TIME_PASSES) }
294 pub fn count_llvm_insns(&self) -> bool {
295 self.debugging_opt(COUNT_LLVM_INSNS)
296 }
297 pub fn count_type_sizes(&self) -> bool {
298 self.debugging_opt(COUNT_TYPE_SIZES)
299 }
300 pub fn time_llvm_passes(&self) -> bool {
301 self.debugging_opt(TIME_LLVM_PASSES)
302 }
303 pub fn trans_stats(&self) -> bool { self.debugging_opt(TRANS_STATS) }
304 pub fn meta_stats(&self) -> bool { self.debugging_opt(META_STATS) }
305 pub fn asm_comments(&self) -> bool { self.debugging_opt(ASM_COMMENTS) }
306 pub fn no_verify(&self) -> bool { self.debugging_opt(NO_VERIFY) }
307 pub fn borrowck_stats(&self) -> bool { self.debugging_opt(BORROWCK_STATS) }
308 pub fn print_llvm_passes(&self) -> bool {
309 self.debugging_opt(PRINT_LLVM_PASSES)
310 }
311 pub fn lto(&self) -> bool {
312 self.debugging_opt(LTO)
313 }
314 pub fn no_landing_pads(&self) -> bool {
315 self.debugging_opt(NO_LANDING_PADS)
316 }
317 pub fn show_span(&self) -> bool {
318 self.debugging_opt(SHOW_SPAN)
319 }
320 pub fn sysroot<'a>(&'a self) -> &'a Path {
321 match self.opts.maybe_sysroot {
322 Some (ref sysroot) => sysroot,
323 None => self.default_sysroot.as_ref()
324 .expect("missing sysroot and default_sysroot in Session")
325 }
326 }
327 pub fn target_filesearch<'a>(&'a self) -> filesearch::FileSearch<'a> {
328 filesearch::FileSearch::new(
329 self.sysroot(),
330 self.opts.target_triple,
331 &self.opts.addl_lib_search_paths)
332 }
333 pub fn host_filesearch<'a>(&'a self) -> filesearch::FileSearch<'a> {
334 filesearch::FileSearch::new(
335 self.sysroot(),
336 host_triple(),
337 &self.opts.addl_lib_search_paths)
338 }
339 }
340
341 /// Some reasonable defaults
342 pub fn basic_options() -> Options {
343 Options {
344 crate_types: Vec::new(),
345 gc: false,
346 optimize: No,
347 debuginfo: NoDebugInfo,
348 lint_opts: Vec::new(),
349 output_types: Vec::new(),
350 addl_lib_search_paths: RefCell::new(HashSet::new()),
351 maybe_sysroot: None,
352 target_triple: host_triple().to_owned(),
353 cfg: Vec::new(),
354 test: false,
355 parse_only: false,
356 no_trans: false,
357 no_analysis: false,
358 debugging_opts: 0,
359 write_dependency_info: (false, None),
360 print_metas: (false, false, false),
361 cg: basic_codegen_options(),
362 }
363 }
364
365 /// Declare a macro that will define all CodegenOptions fields and parsers all
366 /// at once. The goal of this macro is to define an interface that can be
367 /// programmatically used by the option parser in order to initialize the struct
368 /// without hardcoding field names all over the place.
369 ///
370 /// The goal is to invoke this macro once with the correct fields, and then this
371 /// macro generates all necessary code. The main gotcha of this macro is the
372 /// cgsetters module which is a bunch of generated code to parse an option into
373 /// its respective field in the struct. There are a few hand-written parsers for
374 /// parsing specific types of values in this module.
375 macro_rules! cgoptions(
376 ($($opt:ident : $t:ty = ($init:expr, $parse:ident, $desc:expr)),* ,) =>
377 (
378 #[deriving(Clone)]
379 pub struct CodegenOptions { $(pub $opt: $t),* }
380
381 pub fn basic_codegen_options() -> CodegenOptions {
382 CodegenOptions { $($opt: $init),* }
383 }
384
385 pub type CodegenSetter = fn(&mut CodegenOptions, v: Option<&str>) -> bool;
386 pub static CG_OPTIONS: &'static [(&'static str, CodegenSetter,
387 &'static str)] =
388 &[ $( (stringify!($opt), cgsetters::$opt, $desc) ),* ];
389
390 mod cgsetters {
391 use super::CodegenOptions;
392
393 $(
394 pub fn $opt(cg: &mut CodegenOptions, v: Option<&str>) -> bool {
395 $parse(&mut cg.$opt, v)
396 }
397 )*
398
399 fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
400 match v {
401 Some(..) => false,
402 None => { *slot = true; true }
403 }
404 }
405
406 fn parse_opt_string(slot: &mut Option<~str>, v: Option<&str>) -> bool {
407 match v {
408 Some(s) => { *slot = Some(s.to_owned()); true },
409 None => false,
410 }
411 }
412
413 fn parse_string(slot: &mut ~str, v: Option<&str>) -> bool {
414 match v {
415 Some(s) => { *slot = s.to_owned(); true },
416 None => false,
417 }
418 }
419
420 fn parse_list(slot: &mut Vec<~str>, v: Option<&str>)
421 -> bool {
422 match v {
423 Some(s) => {
424 for s in s.words() {
425 slot.push(s.to_owned());
426 }
427 true
428 },
429 None => false,
430 }
431 }
432
433 }
434 ) )
435
436 cgoptions!(
437 ar: Option<~str> = (None, parse_opt_string,
438 "tool to assemble archives with"),
439 linker: Option<~str> = (None, parse_opt_string,
440 "system linker to link outputs with"),
441 link_args: Vec<~str> = (Vec::new(), parse_list,
442 "extra arguments to pass to the linker (space separated)"),
443 target_cpu: ~str = ("generic".to_owned(), parse_string,
444 "select target processor (llc -mcpu=help for details)"),
445 target_feature: ~str = ("".to_owned(), parse_string,
446 "target specific attributes (llc -mattr=help for details)"),
447 passes: Vec<~str> = (Vec::new(), parse_list,
448 "a list of extra LLVM passes to run (space separated)"),
449 llvm_args: Vec<~str> = (Vec::new(), parse_list,
450 "a list of arguments to pass to llvm (space separated)"),
451 save_temps: bool = (false, parse_bool,
452 "save all temporary output files during compilation"),
453 android_cross_path: Option<~str> = (None, parse_opt_string,
454 "the path to the Android NDK"),
455 no_rpath: bool = (false, parse_bool,
456 "disables setting the rpath in libs/exes"),
457 no_prepopulate_passes: bool = (false, parse_bool,
458 "don't pre-populate the pass manager with a list of passes"),
459 no_vectorize_loops: bool = (false, parse_bool,
460 "don't run the loop vectorization optimization passes"),
461 no_vectorize_slp: bool = (false, parse_bool,
462 "don't run LLVM's SLP vectorization pass"),
463 soft_float: bool = (false, parse_bool,
464 "generate software floating point library calls"),
465 prefer_dynamic: bool = (false, parse_bool,
466 "prefer dynamic linking to static linking"),
467 no_integrated_as: bool = (false, parse_bool,
468 "use an external assembler rather than LLVM's integrated one"),
469 relocation_model: ~str = ("pic".to_owned(), parse_string,
470 "choose the relocation model to use (llc -relocation-model for details)"),
471 )
472
473 // Seems out of place, but it uses session, so I'm putting it here
474 pub fn expect<T:Clone>(sess: &Session, opt: Option<T>, msg: || -> StrBuf)
475 -> T {
476 diagnostic::expect(sess.diagnostic(), opt, msg)
477 }
478
479 pub fn default_lib_output() -> CrateType {
480 CrateTypeRlib
481 }
482
483 pub fn collect_crate_types(session: &Session,
484 attrs: &[ast::Attribute]) -> Vec<CrateType> {
485 // If we're generating a test executable, then ignore all other output
486 // styles at all other locations
487 if session.opts.test {
488 return vec!(CrateTypeExecutable)
489 }
490
491 // Only check command line flags if present. If no types are specified by
492 // command line, then reuse the empty `base` Vec to hold the types that
493 // will be found in crate attributes.
494 let mut base = session.opts.crate_types.clone();
495 if base.len() > 0 {
496 return base
497 } else {
498 let iter = attrs.iter().filter_map(|a| {
499 if a.name().equiv(&("crate_type")) {
500 match a.value_str() {
501 Some(ref n) if n.equiv(&("rlib")) => Some(CrateTypeRlib),
502 Some(ref n) if n.equiv(&("dylib")) => Some(CrateTypeDylib),
503 Some(ref n) if n.equiv(&("lib")) => {
504 Some(default_lib_output())
505 }
506 Some(ref n) if n.equiv(&("staticlib")) => {
507 Some(CrateTypeStaticlib)
508 }
509 Some(ref n) if n.equiv(&("bin")) => Some(CrateTypeExecutable),
510 Some(_) => {
511 session.add_lint(lint::UnknownCrateType,
512 ast::CRATE_NODE_ID,
513 a.span,
514 "invalid `crate_type` value".to_owned());
515 None
516 }
517 _ => {
518 session.add_lint(lint::UnknownCrateType, ast::CRATE_NODE_ID,
519 a.span, "`crate_type` requires a value".to_owned());
520 None
521 }
522 }
523 } else {
524 None
525 }
526 });
527 base.extend(iter);
528 if base.len() == 0 {
529 base.push(CrateTypeExecutable);
530 }
531 base.as_mut_slice().sort();
532 base.dedup();
533 return base;
534 }
535 }
536
537 pub fn sess_os_to_meta_os(os: abi::Os) -> metadata::loader::Os {
538 use metadata::loader;
539
540 match os {
541 abi::OsWin32 => loader::OsWin32,
542 abi::OsLinux => loader::OsLinux,
543 abi::OsAndroid => loader::OsAndroid,
544 abi::OsMacos => loader::OsMacos,
545 abi::OsFreebsd => loader::OsFreebsd
546 }
547 }
librustc/driver/session.rs:124:19-124:19 -struct- definition:
pub struct Options {
// The crate config requested for the session, which may be combined
// with additional crate configurations during the compile process
references:- 12342: pub fn basic_options() -> Options {
343: Options {
344: crate_types: Vec::new(),
librustc/driver/driver.rs:
958: session::Options {
959: crate_types: crate_types,
--
1023: pub fn build_session_(sopts: session::Options,
1024: local_crate_source_file: Option<Path>,
librustc/driver/session.rs:31:1-31:1 -struct- definition:
pub struct Config {
pub os: abi::Os,
pub arch: abi::Architecture,
references:- 4177: pub struct Session {
178: pub targ_cfg: Config,
179: pub opts: Options,
librustc/driver/driver.rs:
786: };
787: session::Config {
788: os: os,
librustc/back/link.rs:
1405: // Converts a library file-stem into a cc -l argument
1406: fn unlib(config: &session::Config, stem: &str) -> ~str {
1407: if stem.starts_with("lib") && config.os != abi::OsWin32 {
librustc/driver/session.rs:381:4-381:4 -fn- definition:
pub fn basic_codegen_options() -> CodegenOptions {
CodegenOptions { $($opt: $init),* }
}
references:- 3360: print_metas: (false, false, false),
361: cg: basic_codegen_options(),
362: }
librustc/driver/driver.rs:
982: {
983: let mut cg = session::basic_codegen_options();
984: for option in matches.opt_strs("C").move_iter() {
librustc/lib.rs:
211: println!("\nAvailable codegen options:\n");
212: let mut cg = session::basic_codegen_options();
213: for &(name, parser, desc) in session::CG_OPTIONS.iter() {
librustc/driver/session.rs:399:8-399:8 -fn- definition:
fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
match v {
Some(..) => false,
references:- 8394: pub fn $opt(cg: &mut CodegenOptions, v: Option<&str>) -> bool {
395: $parse(&mut cg.$opt, v)
396: }
librustc/driver/session.rs:76:1-76:1 -fn- definition:
pub fn debugging_opts_map() -> Vec<(&'static str, &'static str, u64)> {
vec!(("verbose", "in general, enable more debug printouts", VERBOSE),
("time-passes", "measure time of each rustc pass", TIME_PASSES),
references:- 2librustc/driver/driver.rs:
856: let debug_flags = matches.opt_strs("Z");
857: let debug_map = session::debugging_opts_map();
858: for debug_flag in debug_flags.iter() {
librustc/lib.rs:
199: println!("\nAvailable debug options:\n");
200: let r = session::debugging_opts_map();
201: for tuple in r.iter() {
librustc/driver/session.rs:420:8-420:8 -fn- definition:
fn parse_list(slot: &mut Vec<~str>, v: Option<&str>)
-> bool {
match v {
references:- 3394: pub fn $opt(cg: &mut CodegenOptions, v: Option<&str>) -> bool {
395: $parse(&mut cg.$opt, v)
396: }
librustc/driver/session.rs:109:23-109:23 -enum- definition:
pub enum OptLevel {
No, // -O0
Less, // -O1
references:- 6110: pub enum OptLevel {
--
130: pub gc: bool,
131: pub optimize: OptLevel,
132: pub debuginfo: DebugInfoLevel,
librustc/driver/session.rs:162:16-162:16 -enum- definition:
pub enum EntryFnType {
EntryMain,
EntryStart,
references:- 4161: // scheduler
163: pub enum EntryFnType {
--
183: pub entry_fn: RefCell<Option<(NodeId, codemap::Span)>>,
184: pub entry_type: Cell<Option<EntryFnType>>,
185: pub macro_registrar_fn: Cell<Option<ast::NodeId>>,
librustc/driver/session.rs:117:23-117:23 -enum- definition:
pub enum DebugInfoLevel {
NoDebugInfo,
LimitedDebugInfo,
references:- 6118: pub enum DebugInfoLevel {
--
131: pub optimize: OptLevel,
132: pub debuginfo: DebugInfoLevel,
133: pub lint_opts: Vec<(lint::Lint, lint::level)> ,
librustc/driver/session.rs:478:1-478:1 -fn- definition:
pub fn default_lib_output() -> CrateType {
CrateTypeRlib
}
references:- 2librustc/driver/driver.rs:
814: let new_part = match part {
815: "lib" => session::default_lib_output(),
816: "rlib" => session::CrateTypeRlib,
librustc/driver/session.rs:
503: Some(ref n) if n.equiv(&("lib")) => {
504: Some(default_lib_output())
505: }
librustc/driver/session.rs:473:67-473:67 -fn- definition:
// Seems out of place, but it uses session, so I'm putting it here
pub fn expect<T:Clone>(sess: &Session, opt: Option<T>, msg: || -> StrBuf)
-> T {
references:- 2librustc/middle/trans/monomorphize.rs:
109: let map_node = session::expect(
110: ccx.sess(),
librustc/middle/trans/callee.rs:
363: } else if def_id.krate == ast::LOCAL_CRATE {
364: let map_node = session::expect(
365: ccx.sess(),
librustc/driver/session.rs:169:53-169:53 -enum- definition:
pub enum CrateType {
CrateTypeExecutable,
CrateTypeDylib,
references:- 23127: // with additional crate configurations during the compile process
128: pub crate_types: Vec<CrateType>,
--
170: pub enum CrateType {
--
479: pub fn default_lib_output() -> CrateType {
480: CrateTypeRlib
--
483: pub fn collect_crate_types(session: &Session,
484: attrs: &[ast::Attribute]) -> Vec<CrateType> {
485: // If we're generating a test executable, then ignore all other output
librustc/middle/dependency_format.rs:
93: fn calculate_type(sess: &session::Session,
94: ty: session::CrateType) -> DependencyList {
95: match ty {
librustc/back/link.rs:
826: pub fn filename_for_input(sess: &Session, crate_type: session::CrateType,
827: id: &CrateId, out_filename: &Path) -> Path {
--
851: trans: &CrateTranslation,
852: crate_type: session::CrateType,
853: outputs: &OutputFilenames,
librustc/driver/driver.rs:
809: pub fn build_session_options(matches: &getopts::Matches) -> session::Options {
810: let mut crate_types: Vec<CrateType> = Vec::new();
811: let unparsed_crate_types = matches.opt_strs("crate-type");
librustc/driver/session.rs:
170: pub enum CrateType {
librustc/driver/session.rs:379:4-379:4 -struct- definition:
pub struct CodegenOptions { $(pub $opt: $t),* }
pub fn basic_codegen_options() -> CodegenOptions {
CodegenOptions { $($opt: $init),* }
references:- 26377: (
378: #[deriving(Clone)]
379: pub struct CodegenOptions { $(pub $opt: $t),* }
--
381: pub fn basic_codegen_options() -> CodegenOptions {
382: CodegenOptions { $($opt: $init),* }
383: }
--
393: $(
394: pub fn $opt(cg: &mut CodegenOptions, v: Option<&str>) -> bool {
395: $parse(&mut cg.$opt, v)
librustc/driver/driver.rs:
980: pub fn build_codegen_options(matches: &getopts::Matches)
981: -> session::CodegenOptions
982: {
librustc/driver/session.rs:
393: $(
394: pub fn $opt(cg: &mut CodegenOptions, v: Option<&str>) -> bool {
395: $parse(&mut cg.$opt, v)
librustc/driver/session.rs:176:1-176:1 -struct- definition:
pub struct Session {
pub targ_cfg: Config,
pub opts: Options,
references:- 98librustc/driver/driver.rs:
librustc/lib.rs:
librustc/middle/trans/common.rs:
librustc/middle/trans/context.rs:
librustc/middle/trans/base.rs:
librustc/middle/ty.rs:
librustc/middle/resolve.rs:
librustc/middle/resolve_lifetime.rs:
librustc/middle/check_loop.rs:
librustc/middle/check_const.rs:
librustc/middle/lint.rs:
librustc/middle/region.rs:
librustc/middle/astencode.rs:
librustc/middle/lang_items.rs:
librustc/middle/entry.rs:
librustc/middle/dependency_format.rs:
librustc/front/test.rs:
librustc/front/std_inject.rs:
librustc/front/assign_node_ids_and_map.rs:
librustc/front/feature_gate.rs:
librustc/front/show_span.rs:
librustc/back/archive.rs:
librustc/back/link.rs:
librustc/back/lto.rs:
librustc/back/rpath.rs:
librustc/metadata/creader.rs:
librustc/metadata/loader.rs:
librustc/driver/driver.rs:
librustc/back/link.rs:
librustc/driver/session.rs:406:8-406:8 -fn- definition:
fn parse_opt_string(slot: &mut Option<~str>, v: Option<&str>) -> bool {
match v {
Some(s) => { *slot = Some(s.to_owned()); true },
references:- 3394: pub fn $opt(cg: &mut CodegenOptions, v: Option<&str>) -> bool {
395: $parse(&mut cg.$opt, v)
396: }
librustc/driver/session.rs:482:1-482:1 -fn- definition:
pub fn collect_crate_types(session: &Session,
attrs: &[ast::Attribute]) -> Vec<CrateType> {
// If we're generating a test executable, then ignore all other output
references:- 2librustc/lib.rs:
330: if crate_file_name {
331: let crate_types = session::collect_crate_types(&sess,
332: attrs.as_slice());
librustc/driver/driver.rs:
214: *sess.crate_types.borrow_mut() = session::collect_crate_types(sess, krate.attrs.as_slice());
librustc/driver/session.rs:413:8-413:8 -fn- definition:
fn parse_string(slot: &mut ~str, v: Option<&str>) -> bool {
match v {
Some(s) => { *slot = s.to_owned(); true },
references:- 3394: pub fn $opt(cg: &mut CodegenOptions, v: Option<&str>) -> bool {
395: $parse(&mut cg.$opt, v)
396: }
librustc/driver/session.rs:536:1-536:1 -fn- definition:
pub fn sess_os_to_meta_os(os: abi::Os) -> metadata::loader::Os {
use metadata::loader;
match os {
references:- 8librustc/back/arm.rs:
25: meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)).to_owned(),
librustc/back/mips.rs:
20: meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)).to_owned(),
librustc/back/x86.rs:
21: meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)).to_owned(),
librustc/metadata/creader.rs:
333: filesearch: e.sess.target_filesearch(),
334: os: session::sess_os_to_meta_os(e.sess.targ_cfg.os),
335: triple: e.sess.targ_cfg.target_strs.target_triple.as_slice(),
--
399: triple: driver::host_triple(),
400: os: session::sess_os_to_meta_os(os),
401: root: &None,
--
410: load_ctxt.triple = target_triple;
411: load_ctxt.os = session::sess_os_to_meta_os(self.env.sess.targ_cfg.os);
412: load_ctxt.filesearch = self.env.sess.target_filesearch();
librustc/driver/driver.rs:
1220: metadata::loader::list_file_metadata(
1221: session::sess_os_to_meta_os(sess.targ_cfg.os), path, out)
1222: }
librustc/back/x86_64.rs:
21: meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)).to_owned(),