@@ -315,7 +315,6 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
315315 paths:: create_dir_all ( & script_dir) ?;
316316 paths:: create_dir_all ( & script_out_dir) ?;
317317
318- let extra_link_arg = cx. bcx . config . cli_unstable ( ) . extra_link_arg ;
319318 let nightly_features_allowed = cx. bcx . config . nightly_features_allowed ;
320319 let targets: Vec < Target > = unit. pkg . targets ( ) . to_vec ( ) ;
321320 // Need a separate copy for the fresh closure.
@@ -427,7 +426,6 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
427426 & pkg_descr,
428427 & script_out_dir,
429428 & script_out_dir,
430- extra_link_arg,
431429 nightly_features_allowed,
432430 & targets,
433431 ) ?;
@@ -455,7 +453,6 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
455453 & pkg_descr,
456454 & prev_script_out_dir,
457455 & script_out_dir,
458- extra_link_arg,
459456 nightly_features_allowed,
460457 & targets_fresh,
461458 ) ?,
@@ -508,7 +505,6 @@ impl BuildOutput {
508505 pkg_descr : & str ,
509506 script_out_dir_when_generated : & Path ,
510507 script_out_dir : & Path ,
511- extra_link_arg : bool ,
512508 nightly_features_allowed : bool ,
513509 targets : & [ Target ] ,
514510 ) -> CargoResult < BuildOutput > {
@@ -519,7 +515,6 @@ impl BuildOutput {
519515 pkg_descr,
520516 script_out_dir_when_generated,
521517 script_out_dir,
522- extra_link_arg,
523518 nightly_features_allowed,
524519 targets,
525520 )
@@ -535,7 +530,6 @@ impl BuildOutput {
535530 pkg_descr : & str ,
536531 script_out_dir_when_generated : & Path ,
537532 script_out_dir : & Path ,
538- extra_link_arg : bool ,
539533 nightly_features_allowed : bool ,
540534 targets : & [ Target ] ,
541535 ) -> CargoResult < BuildOutput > {
@@ -606,59 +600,47 @@ impl BuildOutput {
606600 linker_args. push ( ( LinkType :: Cdylib , value) )
607601 }
608602 "rustc-link-arg-bins" => {
609- if extra_link_arg {
610- if !targets. iter ( ) . any ( |target| target. is_bin ( ) ) {
611- bail ! (
612- "invalid instruction `cargo:{}` from {}\n \
613- The package {} does not have a bin target.",
614- key,
615- whence,
616- pkg_descr
617- ) ;
618- }
619- linker_args. push ( ( LinkType :: Bin , value) ) ;
620- } else {
621- warnings. push ( format ! ( "cargo:{} requires -Zextra-link-arg flag" , key) ) ;
603+ if !targets. iter ( ) . any ( |target| target. is_bin ( ) ) {
604+ bail ! (
605+ "invalid instruction `cargo:{}` from {}\n \
606+ The package {} does not have a bin target.",
607+ key,
608+ whence,
609+ pkg_descr
610+ ) ;
622611 }
612+ linker_args. push ( ( LinkType :: Bin , value) ) ;
623613 }
624614 "rustc-link-arg-bin" => {
625- if extra_link_arg {
626- let mut parts = value. splitn ( 2 , '=' ) ;
627- let bin_name = parts. next ( ) . unwrap ( ) . to_string ( ) ;
628- let arg = parts. next ( ) . ok_or_else ( || {
629- anyhow:: format_err!(
630- "invalid instruction `cargo:{}={}` from {}\n \
631- The instruction should have the form cargo:{}=BIN=ARG",
632- key,
633- value,
634- whence,
635- key
636- )
637- } ) ?;
638- if !targets
639- . iter ( )
640- . any ( |target| target. is_bin ( ) && target. name ( ) == bin_name)
641- {
642- bail ! (
643- "invalid instruction `cargo:{}` from {}\n \
644- The package {} does not have a bin target with the name `{}`.",
645- key,
646- whence,
647- pkg_descr,
648- bin_name
649- ) ;
650- }
651- linker_args. push ( ( LinkType :: SingleBin ( bin_name) , arg. to_string ( ) ) ) ;
652- } else {
653- warnings. push ( format ! ( "cargo:{} requires -Zextra-link-arg flag" , key) ) ;
615+ let mut parts = value. splitn ( 2 , '=' ) ;
616+ let bin_name = parts. next ( ) . unwrap ( ) . to_string ( ) ;
617+ let arg = parts. next ( ) . ok_or_else ( || {
618+ anyhow:: format_err!(
619+ "invalid instruction `cargo:{}={}` from {}\n \
620+ The instruction should have the form cargo:{}=BIN=ARG",
621+ key,
622+ value,
623+ whence,
624+ key
625+ )
626+ } ) ?;
627+ if !targets
628+ . iter ( )
629+ . any ( |target| target. is_bin ( ) && target. name ( ) == bin_name)
630+ {
631+ bail ! (
632+ "invalid instruction `cargo:{}` from {}\n \
633+ The package {} does not have a bin target with the name `{}`.",
634+ key,
635+ whence,
636+ pkg_descr,
637+ bin_name
638+ ) ;
654639 }
640+ linker_args. push ( ( LinkType :: SingleBin ( bin_name) , arg. to_string ( ) ) ) ;
655641 }
656642 "rustc-link-arg" => {
657- if extra_link_arg {
658- linker_args. push ( ( LinkType :: All , value) ) ;
659- } else {
660- warnings. push ( format ! ( "cargo:{} requires -Zextra-link-arg flag" , key) ) ;
661- }
643+ linker_args. push ( ( LinkType :: All , value) ) ;
662644 }
663645 "rustc-cfg" => cfgs. push ( value. to_string ( ) ) ,
664646 "rustc-env" => {
@@ -953,16 +935,13 @@ fn prev_build_output(cx: &mut Context<'_, '_>, unit: &Unit) -> (Option<BuildOutp
953935 . and_then ( |bytes| paths:: bytes2path ( & bytes) )
954936 . unwrap_or_else ( |_| script_out_dir. clone ( ) ) ;
955937
956- let extra_link_arg = cx. bcx . config . cli_unstable ( ) . extra_link_arg ;
957-
958938 (
959939 BuildOutput :: parse_file (
960940 & output_file,
961941 unit. pkg . library ( ) . map ( |t| t. crate_name ( ) ) ,
962942 & unit. pkg . to_string ( ) ,
963943 & prev_script_out_dir,
964944 & script_out_dir,
965- extra_link_arg,
966945 cx. bcx . config . nightly_features_allowed ,
967946 unit. pkg . targets ( ) ,
968947 )
0 commit comments