1111
1212use back:: link;
1313use back:: { arm, x86, x86_64, mips} ;
14- use driver:: session:: { Aggressive , CrateTypeExecutable } ;
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,7 +868,18 @@ pub fn build_session_options(matches: &getopts::Matches)
865868 } else { No }
866869 } ;
867870 let gc = debugging_opts & session:: GC != 0 ;
868- let debuginfo = matches. opt_present ( "g" ) || matches. opt_present ( "debuginfo" ) ;
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
882+ } ;
869883
870884 let addl_lib_search_paths = matches. opt_strs ( "L" ) . map ( |s| {
871885 Path :: new ( s. as_slice ( ) )
@@ -1012,61 +1026,47 @@ pub fn optgroups() -> ~[getopts::OptGroup] {
10121026 optflag ( "h" , "help" , "Display this message" ) ,
10131027 optmulti ( "" , "cfg" , "Configure the compilation environment" , "SPEC" ) ,
10141028 optmulti ( "L" , "" , "Add a directory to the library search path" , "PATH" ) ,
1015- optmulti ( "" , "crate-type" , "Comma separated list of types of crates for the \
1016- compiler to emit",
1029+ optmulti ( "" , "crate-type" , "Comma separated list of types of crates for the compiler to emit" ,
10171030 "[bin|lib|rlib|dylib|staticlib]" ) ,
1018- optmulti ( "" , "emit" , "Comma separated list of types of output for the compiler
1019- to emit" ,
1031+ optmulti ( "" , "emit" , "Comma separated list of types of output for the compiler to emit" ,
10201032 "[asm|bc|ir|obj|link]" ) ,
10211033 optflag ( "" , "crate-id" , "Output the crate id and exit" ) ,
10221034 optflag ( "" , "crate-name" , "Output the crate name and exit" ) ,
10231035 optflag ( "" , "crate-file-name" , "Output the file(s) that would be written if compilation \
10241036 continued and exit") ,
10251037 optflag ( "" , "ls" , "List the symbols defined by a library crate" ) ,
1026- optflag ( "g" , "debuginfo" , "Emit DWARF debug info to the objects created" ) ,
1027- optflag ( "" , "no-trans" ,
1028- "Run all passes except translation; no output" ) ,
1029- optflag ( "" , "no-analysis" ,
1030- "Parse and expand the output, but run no analysis or produce \
1031- output") ,
1032- optflag ( "O" , "" , "Equivalent to --opt-level=2" ) ,
1033- optopt ( "o" , "" , "Write output to <filename>" , "FILENAME" ) ,
1034- optopt ( "" , "opt-level" ,
1035- "Optimize with possible levels 0-3" , "LEVEL" ) ,
1036- optopt ( "" , "out-dir" ,
1037- "Write output to compiler-chosen filename
1038- in <dir>" , "DIR" ) ,
1039- optflag ( "" , "parse-only" ,
1040- "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" ) ,
10411050 optflagopt ( "" , "pretty" ,
1042- "Pretty-print the input instead of compiling;
1043- valid types are: normal (un-annotated source),
1044- expanded (crates expanded),
1045- typed (crates expanded, with type annotations),
1046- or identified (fully parenthesized,
1047- AST nodes and blocks with IDs)" , "TYPE" ) ,
1048- optflagopt ( "" , "dep-info" ,
1049- "Output dependency info to <filename> after compiling" , "FILENAME" ) ,
1050- optopt ( "" , "sysroot" ,
1051- "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" ) ,
10521059 optflag ( "" , "test" , "Build a test harness" ) ,
1053- optopt ( "" , "target" ,
1054- "Target triple cpu-manufacturer-kernel[-os]
1055- to compile for (see chapter 3.4 of http://www.sourceware.org/autobook/
1056- for details)" , "TRIPLE" ) ,
1057- optmulti ( "W" , "warn" ,
1058- "Set lint warnings" , "OPT" ) ,
1059- optmulti ( "A" , "allow" ,
1060- "Set lint allowed" , "OPT" ) ,
1061- optmulti ( "D" , "deny" ,
1062- "Set lint denied" , "OPT" ) ,
1063- optmulti ( "F" , "forbid" ,
1064- "Set lint forbidden" , "OPT" ) ,
1065- optmulti ( "C" , "codegen" ,
1066- "Set a codegen option" , "OPT[=VALUE]" ) ,
1067- optmulti ( "Z" , "" , "Set internal debugging options" , "FLAG" ) ,
1068- optflag ( "v" , "version" ,
1069- "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" ) ,
10701070 ]
10711071}
10721072
0 commit comments