@@ -63,7 +63,8 @@ use std::sync::mpsc::channel;
63
63
use syntax:: edition:: Edition ;
64
64
use externalfiles:: ExternalHtml ;
65
65
use rustc:: session:: search_paths:: SearchPaths ;
66
- use rustc:: session:: config:: { ErrorOutputType , RustcOptGroup , nightly_options, Externs } ;
66
+ use rustc:: session:: config:: { ErrorOutputType , RustcOptGroup , Externs , CodegenOptions } ;
67
+ use rustc:: session:: config:: { nightly_options, build_codegen_options} ;
67
68
use rustc_back:: target:: TargetTriple ;
68
69
69
70
#[ macro_use]
@@ -157,6 +158,9 @@ pub fn opts() -> Vec<RustcOptGroup> {
157
158
stable( "plugin-path" , |o| {
158
159
o. optmulti( "" , "plugin-path" , "directory to load plugins from" , "DIR" )
159
160
} ) ,
161
+ stable( "C" , |o| {
162
+ o. optmulti( "C" , "codegen" , "pass a codegen option to rustc" , "OPT[=VALUE]" )
163
+ } ) ,
160
164
stable( "passes" , |o| {
161
165
o. optmulti( "" , "passes" ,
162
166
"list of passes to also run, you might want \
@@ -443,14 +447,16 @@ pub fn main_args(args: &[String]) -> isize {
443
447
}
444
448
} ;
445
449
450
+ let cg = build_codegen_options ( & matches, ErrorOutputType :: default ( ) ) ;
451
+
446
452
match ( should_test, markdown_input) {
447
453
( true , true ) => {
448
454
return markdown:: test ( input, cfgs, libs, externs, test_args, maybe_sysroot,
449
- display_warnings, linker, edition)
455
+ display_warnings, linker, edition, cg )
450
456
}
451
457
( true , false ) => {
452
458
return test:: run ( Path :: new ( input) , cfgs, libs, externs, test_args, crate_name,
453
- maybe_sysroot, display_warnings, linker, edition)
459
+ maybe_sysroot, display_warnings, linker, edition, cg )
454
460
}
455
461
( false , true ) => return markdown:: render ( Path :: new ( input) ,
456
462
output. unwrap_or ( PathBuf :: from ( "doc" ) ) ,
@@ -460,7 +466,7 @@ pub fn main_args(args: &[String]) -> isize {
460
466
}
461
467
462
468
let output_format = matches. opt_str ( "w" ) ;
463
- let res = acquire_input ( PathBuf :: from ( input) , externs, edition, & matches, move |out| {
469
+ let res = acquire_input ( PathBuf :: from ( input) , externs, edition, cg , & matches, move |out| {
464
470
let Output { krate, passes, renderinfo } = out;
465
471
info ! ( "going to format" ) ;
466
472
match output_format. as_ref ( ) . map ( |s| & * * s) {
@@ -502,14 +508,15 @@ fn print_error<T>(error_message: T) where T: Display {
502
508
fn acquire_input < R , F > ( input : PathBuf ,
503
509
externs : Externs ,
504
510
edition : Edition ,
511
+ cg : CodegenOptions ,
505
512
matches : & getopts:: Matches ,
506
513
f : F )
507
514
-> Result < R , String >
508
515
where R : ' static + Send , F : ' static + Send + FnOnce ( Output ) -> R {
509
516
match matches. opt_str ( "r" ) . as_ref ( ) . map ( |s| & * * s) {
510
- Some ( "rust" ) => Ok ( rust_input ( input, externs, edition, matches, f) ) ,
517
+ Some ( "rust" ) => Ok ( rust_input ( input, externs, edition, cg , matches, f) ) ,
511
518
Some ( s) => Err ( format ! ( "unknown input format: {}" , s) ) ,
512
- None => Ok ( rust_input ( input, externs, edition, matches, f) )
519
+ None => Ok ( rust_input ( input, externs, edition, cg , matches, f) )
513
520
}
514
521
}
515
522
@@ -538,6 +545,7 @@ fn parse_externs(matches: &getopts::Matches) -> Result<Externs, String> {
538
545
fn rust_input < R , F > ( cratefile : PathBuf ,
539
546
externs : Externs ,
540
547
edition : Edition ,
548
+ cg : CodegenOptions ,
541
549
matches : & getopts:: Matches ,
542
550
f : F ) -> R
543
551
where R : ' static + Send ,
@@ -591,7 +599,7 @@ where R: 'static + Send,
591
599
let ( mut krate, renderinfo) =
592
600
core:: run_core ( paths, cfgs, externs, Input :: File ( cratefile) , triple, maybe_sysroot,
593
601
display_warnings, crate_name. clone ( ) ,
594
- force_unstable_if_unmarked, edition) ;
602
+ force_unstable_if_unmarked, edition, cg ) ;
595
603
596
604
info ! ( "finished with rustc" ) ;
597
605
0 commit comments