1111
1212use back:: link;
1313use back:: { arm, x86, x86_64, mips} ;
14- use driver:: session:: { Aggressive , CrateTypeExecutable , FullDebugInfo , NoDebugInfo } ;
14+ use driver:: session:: { Aggressive , CrateTypeExecutable , FullDebugInfo , LimitedDebugInfo ,
15+ NoDebugInfo } ;
1516use driver:: session:: { Session , Session_ , No , Less , Default } ;
1617use driver:: session;
1718use front;
@@ -38,7 +39,9 @@ use std::vec;
3839use std:: vec_ng:: Vec ;
3940use std:: vec_ng;
4041use collections:: { HashMap , HashSet } ;
41- use getopts:: { optopt, optmulti, optflag, optflagopt} ;
42+ use getopts:: { optopt, optmulti, optflag, optflagopt, opt} ;
43+ use MaybeHasArg = getopts:: Maybe ;
44+ use OccurOptional = getopts:: Optional ;
4245use getopts;
4346use syntax:: ast;
4447use syntax:: abi;
@@ -865,10 +868,17 @@ pub fn build_session_options(matches: &getopts::Matches)
865868 } else { No }
866869 } ;
867870 let gc = debugging_opts & session:: GC != 0 ;
868- let debuginfo = if matches. opt_present ( "g" ) || matches. opt_present ( "debuginfo" ) {
869- FullDebugInfo
870- } else {
871- NoDebugInfo
871+
872+ let debuginfo = match matches. opt_default ( "debuginfo" , "2" ) {
873+ Some ( level) => {
874+ match level {
875+ ~"0 " => NoDebugInfo ,
876+ ~"1 " => LimitedDebugInfo ,
877+ ~"2 " => FullDebugInfo ,
878+ _ => early_error ( "debug info level needs to be between 0-2" )
879+ }
880+ }
881+ None => NoDebugInfo
872882 } ;
873883
874884 let addl_lib_search_paths = matches. opt_strs ( "L" ) . map ( |s| {
@@ -1016,61 +1026,47 @@ pub fn optgroups() -> ~[getopts::OptGroup] {
10161026 optflag ( "h" , "help" , "Display this message" ) ,
10171027 optmulti ( "" , "cfg" , "Configure the compilation environment" , "SPEC" ) ,
10181028 optmulti ( "L" , "" , "Add a directory to the library search path" , "PATH" ) ,
1019- optmulti ( "" , "crate-type" , "Comma separated list of types of crates for the \
1020- compiler to emit",
1029+ optmulti ( "" , "crate-type" , "Comma separated list of types of crates for the compiler to emit" ,
10211030 "[bin|lib|rlib|dylib|staticlib]" ) ,
1022- optmulti ( "" , "emit" , "Comma separated list of types of output for the compiler
1023- to emit" ,
1031+ optmulti ( "" , "emit" , "Comma separated list of types of output for the compiler to emit" ,
10241032 "[asm|bc|ir|obj|link]" ) ,
10251033 optflag ( "" , "crate-id" , "Output the crate id and exit" ) ,
10261034 optflag ( "" , "crate-name" , "Output the crate name and exit" ) ,
10271035 optflag ( "" , "crate-file-name" , "Output the file(s) that would be written if compilation \
10281036 continued and exit") ,
10291037 optflag ( "" , "ls" , "List the symbols defined by a library crate" ) ,
1030- optflag ( "g" , "debuginfo" , "Emit DWARF debug info to the objects created" ) ,
1031- optflag ( "" , "no-trans" ,
1032- "Run all passes except translation; no output" ) ,
1033- optflag ( "" , "no-analysis" ,
1034- "Parse and expand the output, but run no analysis or produce \
1035- output") ,
1036- optflag ( "O" , "" , "Equivalent to --opt-level=2" ) ,
1037- optopt ( "o" , "" , "Write output to <filename>" , "FILENAME" ) ,
1038- optopt ( "" , "opt-level" ,
1039- "Optimize with possible levels 0-3" , "LEVEL" ) ,
1040- optopt ( "" , "out-dir" ,
1041- "Write output to compiler-chosen filename
1042- in <dir>" , "DIR" ) ,
1043- optflag ( "" , "parse-only" ,
1044- "Parse only; do not compile, assemble, or link" ) ,
1038+ opt ( "g" , "debuginfo" , "Emit DWARF debug info to the objects created:
1039+ 0 = no debug info,
1040+ 1 = line-tables only (for stacktraces),
1041+ 2 = full debug info with variable, argument and type information" ,
1042+ "LEVEL" , MaybeHasArg , OccurOptional ) ,
1043+ optflag ( "" , "no-trans" , "Run all passes except translation; no output" ) ,
1044+ optflag ( "" , "no-analysis" , "Parse and expand the output, but run no analysis or produce output" ) ,
1045+ optflag ( "O" , "" , "Equivalent to --opt-level=2" ) ,
1046+ optopt ( "o" , "" , "Write output to <filename>" , "FILENAME" ) ,
1047+ optopt ( "" , "opt-level" , "Optimize with possible levels 0-3" , "LEVEL" ) ,
1048+ optopt ( "" , "out-dir" , "Write output to compiler-chosen filename in <dir>" , "DIR" ) ,
1049+ optflag ( "" , "parse-only" , "Parse only; do not compile, assemble, or link" ) ,
10451050 optflagopt ( "" , "pretty" ,
1046- "Pretty-print the input instead of compiling;
1047- valid types are: normal (un-annotated source),
1048- expanded (crates expanded),
1049- typed (crates expanded, with type annotations),
1050- or identified (fully parenthesized,
1051- AST nodes and blocks with IDs)" , "TYPE" ) ,
1052- optflagopt ( "" , "dep-info" ,
1053- "Output dependency info to <filename> after compiling" , "FILENAME" ) ,
1054- optopt ( "" , "sysroot" ,
1055- "Override the system root" , "PATH" ) ,
1051+ "Pretty-print the input instead of compiling;
1052+ valid types are: normal (un-annotated source),
1053+ expanded (crates expanded),
1054+ typed (crates expanded, with type annotations),
1055+ or identified (fully parenthesized,
1056+ AST nodes and blocks with IDs)" , "TYPE" ) ,
1057+ optflagopt ( "" , "dep-info" , "Output dependency info to <filename> after compiling" , "FILENAME" ) ,
1058+ optopt ( "" , "sysroot" , "Override the system root" , "PATH" ) ,
10561059 optflag ( "" , "test" , "Build a test harness" ) ,
1057- optopt ( "" , "target" ,
1058- "Target triple cpu-manufacturer-kernel[-os]
1059- to compile for (see chapter 3.4 of http://www.sourceware.org/autobook/
1060- for details)" , "TRIPLE" ) ,
1061- optmulti ( "W" , "warn" ,
1062- "Set lint warnings" , "OPT" ) ,
1063- optmulti ( "A" , "allow" ,
1064- "Set lint allowed" , "OPT" ) ,
1065- optmulti ( "D" , "deny" ,
1066- "Set lint denied" , "OPT" ) ,
1067- optmulti ( "F" , "forbid" ,
1068- "Set lint forbidden" , "OPT" ) ,
1069- optmulti ( "C" , "codegen" ,
1070- "Set a codegen option" , "OPT[=VALUE]" ) ,
1071- optmulti ( "Z" , "" , "Set internal debugging options" , "FLAG" ) ,
1072- optflag ( "v" , "version" ,
1073- "Print version info and exit" ) ,
1060+ optopt ( "" , "target" , "Target triple cpu-manufacturer-kernel[-os]
1061+ to compile for (see chapter 3.4 of http://www.sourceware.org/autobook/
1062+ for details)" , "TRIPLE" ) ,
1063+ optmulti ( "W" , "warn" , "Set lint warnings" , "OPT" ) ,
1064+ optmulti ( "A" , "allow" , "Set lint allowed" , "OPT" ) ,
1065+ optmulti ( "D" , "deny" , "Set lint denied" , "OPT" ) ,
1066+ optmulti ( "F" , "forbid" , "Set lint forbidden" , "OPT" ) ,
1067+ optmulti ( "C" , "codegen" , "Set a codegen option" , "OPT[=VALUE]" ) ,
1068+ optmulti ( "Z" , "" , "Set internal debugging options" , "FLAG" ) ,
1069+ optflag ( "v" , "version" , "Print version info and exit" ) ,
10741070 ]
10751071}
10761072
0 commit comments