@@ -219,7 +219,7 @@ impl Step for StdLink {
219
219
target_compiler. host,
220
220
target) ) ;
221
221
let libdir = builder. sysroot_libdir ( target_compiler, target) ;
222
- add_to_sysroot ( builder, & libdir, & libstd_stamp ( builder, compiler, target) ) ;
222
+ add_to_sysroot ( builder, & libdir, & libstd_stamp ( builder, compiler, target) , None ) ;
223
223
224
224
if builder. config . sanitizers && compiler. stage != 0 && target == "x86_64-apple-darwin" {
225
225
// The sanitizers are only built in stage1 or above, so the dylibs will
@@ -423,7 +423,7 @@ impl Step for TestLink {
423
423
target_compiler. host,
424
424
target) ) ;
425
425
add_to_sysroot ( builder, & builder. sysroot_libdir ( target_compiler, target) ,
426
- & libtest_stamp ( builder, compiler, target) ) ;
426
+ & libtest_stamp ( builder, compiler, target) , None ) ;
427
427
428
428
builder. cargo ( target_compiler, Mode :: ToolTest , target, "clean" ) ;
429
429
}
@@ -584,8 +584,13 @@ impl Step for RustcLink {
584
584
& compiler. host,
585
585
target_compiler. host,
586
586
target) ) ;
587
- add_to_sysroot ( builder, & builder. sysroot_libdir ( target_compiler, target) ,
588
- & librustc_stamp ( builder, compiler, target) ) ;
587
+ let stage_out = builder. build . stage_out ( target_compiler, Mode :: Rustc ) ;
588
+ add_to_sysroot (
589
+ builder,
590
+ & builder. sysroot_libdir ( target_compiler, target) ,
591
+ & librustc_stamp ( builder, compiler, target) ,
592
+ Some ( & stage_out) ,
593
+ ) ;
589
594
builder. cargo ( target_compiler, Mode :: ToolRustc , target, "clean" ) ;
590
595
}
591
596
}
@@ -1014,10 +1019,26 @@ impl Step for Assemble {
1014
1019
///
1015
1020
/// For a particular stage this will link the file listed in `stamp` into the
1016
1021
/// `sysroot_dst` provided.
1017
- pub fn add_to_sysroot ( builder : & Builder , sysroot_dst : & Path , stamp : & Path ) {
1022
+ pub fn add_to_sysroot (
1023
+ builder : & Builder ,
1024
+ sysroot_dst : & Path ,
1025
+ stamp : & Path ,
1026
+ stage_out : Option < & Path > ) {
1018
1027
t ! ( fs:: create_dir_all( & sysroot_dst) ) ;
1019
1028
for path in builder. read_stamp_file ( stamp) {
1020
- builder. copy ( & path, & sysroot_dst. join ( path. file_name ( ) . unwrap ( ) ) ) ;
1029
+ let file_dir = path. parent ( ) . unwrap ( ) // chop off base name
1030
+ . parent ( ) . unwrap ( ) // chop off `release`
1031
+ . parent ( ) . unwrap ( ) ; // chop off `release`
1032
+ if stage_out == Some ( file_dir) {
1033
+ // We are copying a build file. We need to add the build triple to it
1034
+ let rustlib_dir = sysroot_dst. parent ( ) . unwrap ( ) // chop off `lib`
1035
+ . parent ( ) . unwrap ( ) ; // chop off `$target`
1036
+ let build_dir = rustlib_dir. join ( builder. build . build ) . join ( "lib" ) ;
1037
+ t ! ( fs:: create_dir_all( & build_dir) ) ;
1038
+ builder. copy ( & path, & build_dir. join ( path. file_name ( ) . unwrap ( ) ) ) ;
1039
+ } else {
1040
+ builder. copy ( & path, & sysroot_dst. join ( path. file_name ( ) . unwrap ( ) ) ) ;
1041
+ }
1021
1042
}
1022
1043
}
1023
1044
@@ -1047,8 +1068,12 @@ pub fn run_cargo(builder: &Builder,
1047
1068
let mut deps = Vec :: new ( ) ;
1048
1069
let mut toplevel = Vec :: new ( ) ;
1049
1070
let ok = stream_cargo ( builder, cargo, tail_args, & mut |msg| {
1050
- let filenames = match msg {
1051
- CargoMessage :: CompilerArtifact { filenames, .. } => filenames,
1071
+ let ( filenames, package_id) = match msg {
1072
+ CargoMessage :: CompilerArtifact {
1073
+ filenames,
1074
+ package_id,
1075
+ ..
1076
+ } => ( filenames, package_id) ,
1052
1077
_ => return ,
1053
1078
} ;
1054
1079
for filename in filenames {
@@ -1062,9 +1087,19 @@ pub fn run_cargo(builder: &Builder,
1062
1087
1063
1088
let filename = Path :: new ( & * filename) ;
1064
1089
1090
+ // If this was an output file in the "host dir" we don't actually
1091
+ // worry about it, it's not relevant for us
1092
+ if filename. starts_with ( & host_root_dir) {
1093
+ // Unless it's a proc macro used in the compiler
1094
+ if package_id. starts_with ( "serde_derive " ) {
1095
+ deps. push ( filename. to_path_buf ( ) ) ;
1096
+ }
1097
+ continue ;
1098
+ }
1099
+
1065
1100
// If this was output in the `deps` dir then this is a precise file
1066
1101
// name (hash included) so we start tracking it.
1067
- if filename. starts_with ( & host_root_dir ) || filename . starts_with ( & target_deps_dir) {
1102
+ if filename. starts_with ( & target_deps_dir) {
1068
1103
deps. push ( filename. to_path_buf ( ) ) ;
1069
1104
continue ;
1070
1105
}
0 commit comments