11
11
12
12
use back:: link;
13
13
use back:: { arm, x86, x86_64, mips} ;
14
- use driver:: session:: { Aggressive , CrateTypeExecutable , FullDebugInfo , NoDebugInfo } ;
14
+ use driver:: session:: { Aggressive , CrateTypeExecutable , FullDebugInfo , LimitedDebugInfo ,
15
+ NoDebugInfo } ;
15
16
use driver:: session:: { Session , Session_ , No , Less , Default } ;
16
17
use driver:: session;
17
18
use front;
@@ -38,7 +39,9 @@ use std::vec;
38
39
use std:: vec_ng:: Vec ;
39
40
use std:: vec_ng;
40
41
use 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 ;
42
45
use getopts;
43
46
use syntax:: ast;
44
47
use syntax:: abi;
@@ -865,10 +868,17 @@ pub fn build_session_options(matches: &getopts::Matches)
865
868
} else { No }
866
869
} ;
867
870
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
872
882
} ;
873
883
874
884
let addl_lib_search_paths = matches. opt_strs ( "L" ) . map ( |s| {
@@ -1016,61 +1026,47 @@ pub fn optgroups() -> ~[getopts::OptGroup] {
1016
1026
optflag ( "h" , "help" , "Display this message" ) ,
1017
1027
optmulti ( "" , "cfg" , "Configure the compilation environment" , "SPEC" ) ,
1018
1028
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" ,
1021
1030
"[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" ,
1024
1032
"[asm|bc|ir|obj|link]" ) ,
1025
1033
optflag ( "" , "crate-id" , "Output the crate id and exit" ) ,
1026
1034
optflag ( "" , "crate-name" , "Output the crate name and exit" ) ,
1027
1035
optflag ( "" , "crate-file-name" , "Output the file(s) that would be written if compilation \
1028
1036
continued and exit") ,
1029
1037
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" ) ,
1045
1050
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" ) ,
1056
1059
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" ) ,
1074
1070
]
1075
1071
}
1076
1072
0 commit comments