@@ -23,7 +23,7 @@ use crate::builder::Cargo;
23
23
use crate :: dist;
24
24
use crate :: native;
25
25
use crate :: util:: { exe, is_dylib, symlink_dir} ;
26
- use crate :: { Compiler , GitRepo , Mode } ;
26
+ use crate :: { Compiler , DependencyType , GitRepo , Mode } ;
27
27
28
28
use crate :: builder:: { Builder , Kind , RunConfig , ShouldRun , Step } ;
29
29
use crate :: cache:: { Interned , INTERNER } ;
@@ -84,7 +84,7 @@ impl Step for Std {
84
84
return ;
85
85
}
86
86
87
- target_deps. extend ( copy_third_party_objects ( builder, & compiler, target) . into_iter ( ) ) ;
87
+ target_deps. extend ( copy_third_party_objects ( builder, & compiler, target) ) ;
88
88
target_deps. extend ( copy_self_contained_objects ( builder, & compiler, target) ) ;
89
89
90
90
let mut cargo = builder. cargo ( compiler, Mode :: Std , target, "build" ) ;
@@ -116,7 +116,8 @@ fn copy_and_stamp(
116
116
libdir : & Path ,
117
117
sourcedir : & Path ,
118
118
name : & str ,
119
- target_deps : & mut Vec < PathBuf > ,
119
+ target_deps : & mut Vec < ( PathBuf , DependencyType ) > ,
120
+ dependency_type : DependencyType ,
120
121
) {
121
122
let target = libdir. join ( name) ;
122
123
builder. copy ( & sourcedir. join ( name) , & target) ;
@@ -129,7 +130,7 @@ fn copy_third_party_objects(
129
130
builder : & Builder < ' _ > ,
130
131
compiler : & Compiler ,
131
132
target : Interned < String > ,
132
- ) -> Vec < PathBuf > {
133
+ ) -> Vec < ( PathBuf , DependencyType ) > {
133
134
let libdir = builder. sysroot_libdir ( * compiler, target) ;
134
135
let mut target_deps = vec ! [ ] ;
135
136
@@ -148,13 +149,18 @@ fn copy_third_party_objects(
148
149
Path :: new ( & src) ,
149
150
"libunwind.a" ,
150
151
& mut target_deps,
152
+ DependencyType :: Target ,
151
153
) ;
152
154
}
153
155
154
156
if builder. config . sanitizers && compiler. stage != 0 {
155
157
// The sanitizers are only copied in stage1 or above,
156
158
// 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
+ ) ;
158
164
}
159
165
160
166
target_deps
@@ -165,7 +171,7 @@ fn copy_self_contained_objects(
165
171
builder : & Builder < ' _ > ,
166
172
compiler : & Compiler ,
167
173
target : Interned < String > ,
168
- ) -> Vec < PathBuf > {
174
+ ) -> Vec < ( PathBuf , DependencyType ) > {
169
175
let libdir = builder. sysroot_libdir ( * compiler, target) ;
170
176
let mut target_deps = vec ! [ ] ;
171
177
@@ -185,6 +191,7 @@ fn copy_self_contained_objects(
185
191
& srcdir,
186
192
obj,
187
193
& mut target_deps,
194
+ DependencyType :: TargetSelfContained ,
188
195
) ;
189
196
}
190
197
} else if target. ends_with ( "-wasi" ) {
@@ -195,13 +202,14 @@ fn copy_self_contained_objects(
195
202
& srcdir,
196
203
"crt1.o" ,
197
204
& mut target_deps,
205
+ DependencyType :: TargetSelfContained ,
198
206
) ;
199
207
} else if target. contains ( "windows-gnu" ) {
200
208
for obj in [ "crt2.o" , "dllcrt2.o" ] . iter ( ) {
201
209
let src = compiler_file ( builder, builder. cc ( target) , target, obj) ;
202
210
let target = libdir. join ( obj) ;
203
211
builder. copy ( & src, & target) ;
204
- target_deps. push ( target) ;
212
+ target_deps. push ( ( target, DependencyType :: TargetSelfContained ) ) ;
205
213
}
206
214
}
207
215
@@ -370,7 +378,7 @@ pub struct StartupObjects {
370
378
}
371
379
372
380
impl Step for StartupObjects {
373
- type Output = Vec < PathBuf > ;
381
+ type Output = Vec < ( PathBuf , DependencyType ) > ;
374
382
375
383
fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
376
384
run. path ( "src/rtstartup" )
@@ -389,7 +397,7 @@ impl Step for StartupObjects {
389
397
/// They don't require any library support as they're just plain old object
390
398
/// files, so we just use the nightly snapshot compiler to always build them (as
391
399
/// 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 ) > {
393
401
let for_compiler = self . compiler ;
394
402
let target = self . target ;
395
403
if !target. contains ( "windows-gnu" ) {
@@ -423,7 +431,7 @@ impl Step for StartupObjects {
423
431
424
432
let target = sysroot_dir. join ( ( * file) . to_string ( ) + ".o" ) ;
425
433
builder. copy ( dst_file, & target) ;
426
- target_deps. push ( target) ;
434
+ target_deps. push ( ( target, DependencyType :: Target ) ) ;
427
435
}
428
436
429
437
target_deps
@@ -838,8 +846,8 @@ pub fn add_to_sysroot(
838
846
) {
839
847
t ! ( fs:: create_dir_all( & sysroot_dst) ) ;
840
848
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 {
843
851
builder. copy ( & path, & sysroot_host_dst. join ( path. file_name ( ) . unwrap ( ) ) ) ;
844
852
} else {
845
853
builder. copy ( & path, & sysroot_dst. join ( path. file_name ( ) . unwrap ( ) ) ) ;
@@ -852,7 +860,7 @@ pub fn run_cargo(
852
860
cargo : Cargo ,
853
861
tail_args : Vec < String > ,
854
862
stamp : & Path ,
855
- additional_target_deps : Vec < PathBuf > ,
863
+ additional_target_deps : Vec < ( PathBuf , DependencyType ) > ,
856
864
is_check : bool ,
857
865
) -> Vec < PathBuf > {
858
866
if builder. config . dry_run {
@@ -903,15 +911,15 @@ pub fn run_cargo(
903
911
if filename. starts_with ( & host_root_dir) {
904
912
// Unless it's a proc macro used in the compiler
905
913
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 ) ) ;
907
915
}
908
916
continue ;
909
917
}
910
918
911
919
// If this was output in the `deps` dir then this is a precise file
912
920
// name (hash included) so we start tracking it.
913
921
if filename. starts_with ( & target_deps_dir) {
914
- deps. push ( ( filename. to_path_buf ( ) , false ) ) ;
922
+ deps. push ( ( filename. to_path_buf ( ) , DependencyType :: Target ) ) ;
915
923
continue ;
916
924
}
917
925
@@ -963,17 +971,21 @@ pub fn run_cargo(
963
971
let candidate = format ! ( "{}.lib" , path_to_add) ;
964
972
let candidate = PathBuf :: from ( candidate) ;
965
973
if candidate. exists ( ) {
966
- deps. push ( ( candidate, false ) ) ;
974
+ deps. push ( ( candidate, DependencyType :: Target ) ) ;
967
975
}
968
976
}
969
- deps. push ( ( path_to_add. into ( ) , false ) ) ;
977
+ deps. push ( ( path_to_add. into ( ) , DependencyType :: Target ) ) ;
970
978
}
971
979
972
- deps. extend ( additional_target_deps. into_iter ( ) . map ( |d| ( d , false ) ) ) ;
980
+ deps. extend ( additional_target_deps) ;
973
981
deps. sort ( ) ;
974
982
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
+ } ) ;
977
989
new_contents. extend ( dep. to_str ( ) . unwrap ( ) . as_bytes ( ) ) ;
978
990
new_contents. extend ( b"\0 " ) ;
979
991
}
0 commit comments