@@ -249,14 +249,12 @@ fn make_failed_scrape_diagnostic(
249
249
250
250
/// Creates a unit of work invoking `rustc` for building the `unit`.
251
251
fn rustc ( cx : & mut Context < ' _ , ' _ > , unit : & Unit , exec : & Arc < dyn Executor > ) -> CargoResult < Work > {
252
- let mut rustc = prepare_rustc ( cx, & unit . target . rustc_crate_types ( ) , unit) ?;
252
+ let mut rustc = prepare_rustc ( cx, unit) ?;
253
253
let build_plan = cx. bcx . build_config . build_plan ;
254
254
255
255
let name = unit. pkg . name ( ) . to_string ( ) ;
256
256
let buildkey = unit. buildkey ( ) ;
257
257
258
- add_cap_lints ( cx. bcx , unit, & mut rustc) ;
259
-
260
258
let outputs = cx. outputs ( unit) ?;
261
259
let root = cx. files ( ) . out_dir ( unit) ;
262
260
@@ -282,10 +280,6 @@ fn rustc(cx: &mut Context<'_, '_>, unit: &Unit, exec: &Arc<dyn Executor>) -> Car
282
280
let rustc_dep_info_loc = root. join ( dep_info_name) ;
283
281
let dep_info_loc = fingerprint:: dep_info_loc ( cx, unit) ;
284
282
285
- rustc. args ( cx. bcx . rustflags_args ( unit) ) ;
286
- if cx. bcx . config . cli_unstable ( ) . binary_dep_depinfo {
287
- rustc. arg ( "-Z" ) . arg ( "binary-dep-depinfo" ) ;
288
- }
289
283
let mut output_options = OutputOptions :: new ( cx, unit) ;
290
284
let package_id = unit. pkg . package_id ( ) ;
291
285
let target = Target :: clone ( & unit. target ) ;
@@ -669,13 +663,13 @@ where
669
663
search_path
670
664
}
671
665
672
- // TODO: do we really need this as a separate function?
673
- // Maybe we should reorganize `rustc` fn to make it more traceable and readable .
674
- fn prepare_rustc (
675
- cx : & Context < ' _ , ' _ > ,
676
- crate_types : & [ CrateType ] ,
677
- unit : & Unit ,
678
- ) -> CargoResult < ProcessBuilder > {
666
+ /// Prepares flags and environments we can compute for a `rustc` invocation
667
+ /// before the job queue starts compiling any unit .
668
+ ///
669
+ /// This builds a static view of the invocation. Flags depending on the
670
+ /// completion of other units will be added later in runtime, such as flags
671
+ /// from build scripts.
672
+ fn prepare_rustc ( cx : & Context < ' _ , ' _ > , unit : & Unit ) -> CargoResult < ProcessBuilder > {
679
673
let is_primary = cx. is_primary_package ( unit) ;
680
674
let is_workspace = cx. bcx . ws . is_member ( & unit. pkg ) ;
681
675
@@ -693,8 +687,13 @@ fn prepare_rustc(
693
687
}
694
688
695
689
base. inherit_jobserver ( & cx. jobserver ) ;
696
- build_base_args ( cx, & mut base, unit, crate_types ) ?;
690
+ build_base_args ( cx, & mut base, unit) ?;
697
691
build_deps_args ( & mut base, cx, unit) ?;
692
+ add_cap_lints ( cx. bcx , unit, & mut base) ;
693
+ base. args ( cx. bcx . rustflags_args ( unit) ) ;
694
+ if cx. bcx . config . cli_unstable ( ) . binary_dep_depinfo {
695
+ base. arg ( "-Z" ) . arg ( "binary-dep-depinfo" ) ;
696
+ }
698
697
Ok ( base)
699
698
}
700
699
@@ -941,12 +940,7 @@ fn add_error_format_and_color(cx: &Context<'_, '_>, cmd: &mut ProcessBuilder) {
941
940
}
942
941
943
942
/// Adds essential rustc flags and environment variables to the command to execute.
944
- fn build_base_args (
945
- cx : & Context < ' _ , ' _ > ,
946
- cmd : & mut ProcessBuilder ,
947
- unit : & Unit ,
948
- crate_types : & [ CrateType ] ,
949
- ) -> CargoResult < ( ) > {
943
+ fn build_base_args ( cx : & Context < ' _ , ' _ > , cmd : & mut ProcessBuilder , unit : & Unit ) -> CargoResult < ( ) > {
950
944
assert ! ( !unit. mode. is_run_custom_build( ) ) ;
951
945
952
946
let bcx = cx. bcx ;
@@ -978,7 +972,7 @@ fn build_base_args(
978
972
979
973
let mut contains_dy_lib = false ;
980
974
if !test {
981
- for crate_type in crate_types {
975
+ for crate_type in & unit . target . rustc_crate_types ( ) {
982
976
cmd. arg ( "--crate-type" ) . arg ( crate_type. as_str ( ) ) ;
983
977
contains_dy_lib |= crate_type == & CrateType :: Dylib ;
984
978
}
0 commit comments