@@ -23,7 +23,7 @@ use crate::builder::Cargo;
2323use crate :: dist;
2424use crate :: native;
2525use crate :: util:: { exe, is_dylib, symlink_dir} ;
26- use crate :: { Compiler , GitRepo , Mode } ;
26+ use crate :: { Compiler , DependencyType , GitRepo , Mode } ;
2727
2828use crate :: builder:: { Builder , Kind , RunConfig , ShouldRun , Step } ;
2929use crate :: cache:: { Interned , INTERNER } ;
@@ -84,7 +84,7 @@ impl Step for Std {
8484 return ;
8585 }
8686
87- target_deps. extend ( copy_third_party_objects ( builder, & compiler, target) . into_iter ( ) ) ;
87+ target_deps. extend ( copy_third_party_objects ( builder, & compiler, target) ) ;
8888 target_deps. extend ( copy_self_contained_objects ( builder, & compiler, target) ) ;
8989
9090 let mut cargo = builder. cargo ( compiler, Mode :: Std , target, "build" ) ;
@@ -116,7 +116,8 @@ fn copy_and_stamp(
116116 libdir : & Path ,
117117 sourcedir : & Path ,
118118 name : & str ,
119- target_deps : & mut Vec < PathBuf > ,
119+ target_deps : & mut Vec < ( PathBuf , DependencyType ) > ,
120+ dependency_type : DependencyType ,
120121) {
121122 let target = libdir. join ( name) ;
122123 builder. copy ( & sourcedir. join ( name) , & target) ;
@@ -129,7 +130,7 @@ fn copy_third_party_objects(
129130 builder : & Builder < ' _ > ,
130131 compiler : & Compiler ,
131132 target : Interned < String > ,
132- ) -> Vec < PathBuf > {
133+ ) -> Vec < ( PathBuf , DependencyType ) > {
133134 let libdir = builder. sysroot_libdir ( * compiler, target) ;
134135 let mut target_deps = vec ! [ ] ;
135136
@@ -148,13 +149,18 @@ fn copy_third_party_objects(
148149 Path :: new ( & src) ,
149150 "libunwind.a" ,
150151 & mut target_deps,
152+ DependencyType :: Target ,
151153 ) ;
152154 }
153155
154156 if builder. config . sanitizers && compiler. stage != 0 {
155157 // The sanitizers are only copied in stage1 or above,
156158 // to avoid creating dependency on LLVM.
157- target_deps. extend ( copy_sanitizers ( builder, & compiler, target) ) ;
159+ target_deps. extend (
160+ copy_sanitizers ( builder, & compiler, target)
161+ . into_iter ( )
162+ . map ( |d| ( d, DependencyType :: Target ) ) ,
163+ ) ;
158164 }
159165
160166 target_deps
@@ -165,7 +171,7 @@ fn copy_self_contained_objects(
165171 builder : & Builder < ' _ > ,
166172 compiler : & Compiler ,
167173 target : Interned < String > ,
168- ) -> Vec < PathBuf > {
174+ ) -> Vec < ( PathBuf , DependencyType ) > {
169175 let libdir = builder. sysroot_libdir ( * compiler, target) ;
170176 let mut target_deps = vec ! [ ] ;
171177
@@ -185,6 +191,7 @@ fn copy_self_contained_objects(
185191 & srcdir,
186192 obj,
187193 & mut target_deps,
194+ DependencyType :: TargetSelfContained ,
188195 ) ;
189196 }
190197 } else if target. ends_with ( "-wasi" ) {
@@ -195,13 +202,14 @@ fn copy_self_contained_objects(
195202 & srcdir,
196203 "crt1.o" ,
197204 & mut target_deps,
205+ DependencyType :: TargetSelfContained ,
198206 ) ;
199207 } else if target. contains ( "windows-gnu" ) {
200208 for obj in [ "crt2.o" , "dllcrt2.o" ] . iter ( ) {
201209 let src = compiler_file ( builder, builder. cc ( target) , target, obj) ;
202210 let target = libdir. join ( obj) ;
203211 builder. copy ( & src, & target) ;
204- target_deps. push ( target) ;
212+ target_deps. push ( ( target, DependencyType :: TargetSelfContained ) ) ;
205213 }
206214 }
207215
@@ -370,7 +378,7 @@ pub struct StartupObjects {
370378}
371379
372380impl Step for StartupObjects {
373- type Output = Vec < PathBuf > ;
381+ type Output = Vec < ( PathBuf , DependencyType ) > ;
374382
375383 fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
376384 run. path ( "src/rtstartup" )
@@ -389,7 +397,7 @@ impl Step for StartupObjects {
389397 /// They don't require any library support as they're just plain old object
390398 /// files, so we just use the nightly snapshot compiler to always build them (as
391399 /// no other compilers are guaranteed to be available).
392- fn run ( self , builder : & Builder < ' _ > ) -> Vec < PathBuf > {
400+ fn run ( self , builder : & Builder < ' _ > ) -> Vec < ( PathBuf , DependencyType ) > {
393401 let for_compiler = self . compiler ;
394402 let target = self . target ;
395403 if !target. contains ( "windows-gnu" ) {
@@ -423,7 +431,7 @@ impl Step for StartupObjects {
423431
424432 let target = sysroot_dir. join ( ( * file) . to_string ( ) + ".o" ) ;
425433 builder. copy ( dst_file, & target) ;
426- target_deps. push ( target) ;
434+ target_deps. push ( ( target, DependencyType :: Target ) ) ;
427435 }
428436
429437 target_deps
@@ -838,8 +846,8 @@ pub fn add_to_sysroot(
838846) {
839847 t ! ( fs:: create_dir_all( & sysroot_dst) ) ;
840848 t ! ( fs:: create_dir_all( & sysroot_host_dst) ) ;
841- for ( path, host ) in builder. read_stamp_file ( stamp) {
842- if host {
849+ for ( path, dependency_type ) in builder. read_stamp_file ( stamp) {
850+ if dependency_type == DependencyType :: Host {
843851 builder. copy ( & path, & sysroot_host_dst. join ( path. file_name ( ) . unwrap ( ) ) ) ;
844852 } else {
845853 builder. copy ( & path, & sysroot_dst. join ( path. file_name ( ) . unwrap ( ) ) ) ;
@@ -852,7 +860,7 @@ pub fn run_cargo(
852860 cargo : Cargo ,
853861 tail_args : Vec < String > ,
854862 stamp : & Path ,
855- additional_target_deps : Vec < PathBuf > ,
863+ additional_target_deps : Vec < ( PathBuf , DependencyType ) > ,
856864 is_check : bool ,
857865) -> Vec < PathBuf > {
858866 if builder. config . dry_run {
@@ -903,15 +911,15 @@ pub fn run_cargo(
903911 if filename. starts_with ( & host_root_dir) {
904912 // Unless it's a proc macro used in the compiler
905913 if crate_types. iter ( ) . any ( |t| t == "proc-macro" ) {
906- deps. push ( ( filename. to_path_buf ( ) , true ) ) ;
914+ deps. push ( ( filename. to_path_buf ( ) , DependencyType :: Host ) ) ;
907915 }
908916 continue ;
909917 }
910918
911919 // If this was output in the `deps` dir then this is a precise file
912920 // name (hash included) so we start tracking it.
913921 if filename. starts_with ( & target_deps_dir) {
914- deps. push ( ( filename. to_path_buf ( ) , false ) ) ;
922+ deps. push ( ( filename. to_path_buf ( ) , DependencyType :: Target ) ) ;
915923 continue ;
916924 }
917925
@@ -963,17 +971,21 @@ pub fn run_cargo(
963971 let candidate = format ! ( "{}.lib" , path_to_add) ;
964972 let candidate = PathBuf :: from ( candidate) ;
965973 if candidate. exists ( ) {
966- deps. push ( ( candidate, false ) ) ;
974+ deps. push ( ( candidate, DependencyType :: Target ) ) ;
967975 }
968976 }
969- deps. push ( ( path_to_add. into ( ) , false ) ) ;
977+ deps. push ( ( path_to_add. into ( ) , DependencyType :: Target ) ) ;
970978 }
971979
972- deps. extend ( additional_target_deps. into_iter ( ) . map ( |d| ( d , false ) ) ) ;
980+ deps. extend ( additional_target_deps) ;
973981 deps. sort ( ) ;
974982 let mut new_contents = Vec :: new ( ) ;
975- for ( dep, proc_macro) in deps. iter ( ) {
976- new_contents. extend ( if * proc_macro { b"h" } else { b"t" } ) ;
983+ for ( dep, dependency_type) in deps. iter ( ) {
984+ new_contents. extend ( match * dependency_type {
985+ DependencyType :: Host => b"h" ,
986+ DependencyType :: Target => b"t" ,
987+ DependencyType :: TargetSelfContained => b"s" ,
988+ } ) ;
977989 new_contents. extend ( dep. to_str ( ) . unwrap ( ) . as_bytes ( ) ) ;
978990 new_contents. extend ( b"\0 " ) ;
979991 }
0 commit comments