@@ -296,9 +296,17 @@ macro_rules! options {
296296 use std:: path:: PathBuf ;
297297 use std:: str :: FromStr ;
298298
299+ // Sometimes different options need to build a common structure.
300+ // That structure can kept in one of the options' fields, the others become dummy.
301+ macro_rules! redirect_field {
302+ ( $cg: ident. link_arg) => { $cg. link_args } ;
303+ ( $cg: ident. pre_link_arg) => { $cg. pre_link_args } ;
304+ ( $cg: ident. $field: ident) => { $cg. $field } ;
305+ }
306+
299307 $(
300308 pub fn $opt( cg: & mut $struct_name, v: Option <& str >) -> bool {
301- $parse( & mut cg. $opt, v)
309+ $parse( & mut redirect_field! ( cg. $opt) , v)
302310 }
303311 ) *
304312
@@ -643,9 +651,9 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
643651 "this option is deprecated and does nothing" ) ,
644652 linker: Option <PathBuf > = ( None , parse_opt_pathbuf, [ UNTRACKED ] ,
645653 "system linker to link outputs with" ) ,
646- link_arg: Vec < String > = ( vec! [ ] , parse_string_push, [ UNTRACKED ] ,
654+ link_arg: ( /* redirected to link_args */ ) = ( ( ) , parse_string_push, [ UNTRACKED ] ,
647655 "a single extra argument to append to the linker invocation (can be used several times)" ) ,
648- link_args: Option < Vec <String >> = ( None , parse_opt_list , [ UNTRACKED ] ,
656+ link_args: Vec <String > = ( Vec :: new ( ) , parse_list , [ UNTRACKED ] ,
649657 "extra arguments to append to the linker invocation (space separated)" ) ,
650658 link_dead_code: bool = ( false , parse_bool, [ UNTRACKED ] ,
651659 "don't let linker strip dead code (turning it on can be used for code coverage)" ) ,
@@ -876,9 +884,9 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
876884 "make rustc print the total optimization fuel used by a crate" ) ,
877885 force_unstable_if_unmarked: bool = ( false , parse_bool, [ TRACKED ] ,
878886 "force all crates to be `rustc_private` unstable" ) ,
879- pre_link_arg: Vec < String > = ( vec! [ ] , parse_string_push, [ UNTRACKED ] ,
887+ pre_link_arg: ( /* redirected to pre_link_args */ ) = ( ( ) , parse_string_push, [ UNTRACKED ] ,
880888 "a single extra argument to prepend the linker invocation (can be used several times)" ) ,
881- pre_link_args: Option < Vec <String >> = ( None , parse_opt_list , [ UNTRACKED ] ,
889+ pre_link_args: Vec <String > = ( Vec :: new ( ) , parse_list , [ UNTRACKED ] ,
882890 "extra arguments to prepend to the linker invocation (space separated)" ) ,
883891 profile: bool = ( false , parse_bool, [ TRACKED ] ,
884892 "insert profiling code" ) ,
0 commit comments