@@ -219,7 +219,7 @@ impl Step for StdLink {
219219 target_compiler. host,
220220 target) ) ;
221221 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 ) ;
223223
224224 if builder. config . sanitizers && compiler. stage != 0 && target == "x86_64-apple-darwin" {
225225 // The sanitizers are only built in stage1 or above, so the dylibs will
@@ -423,7 +423,7 @@ impl Step for TestLink {
423423 target_compiler. host,
424424 target) ) ;
425425 add_to_sysroot ( builder, & builder. sysroot_libdir ( target_compiler, target) ,
426- & libtest_stamp ( builder, compiler, target) ) ;
426+ & libtest_stamp ( builder, compiler, target) , None ) ;
427427
428428 builder. cargo ( target_compiler, Mode :: ToolTest , target, "clean" ) ;
429429 }
@@ -584,8 +584,13 @@ impl Step for RustcLink {
584584 & compiler. host,
585585 target_compiler. host,
586586 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+ ) ;
589594 builder. cargo ( target_compiler, Mode :: ToolRustc , target, "clean" ) ;
590595 }
591596}
@@ -1014,10 +1019,26 @@ impl Step for Assemble {
10141019///
10151020/// For a particular stage this will link the file listed in `stamp` into the
10161021/// `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 > ) {
10181027 t ! ( fs:: create_dir_all( & sysroot_dst) ) ;
10191028 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+ }
10211042 }
10221043}
10231044
@@ -1047,8 +1068,12 @@ pub fn run_cargo(builder: &Builder,
10471068 let mut deps = Vec :: new ( ) ;
10481069 let mut toplevel = Vec :: new ( ) ;
10491070 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) ,
10521077 _ => return ,
10531078 } ;
10541079 for filename in filenames {
@@ -1062,9 +1087,19 @@ pub fn run_cargo(builder: &Builder,
10621087
10631088 let filename = Path :: new ( & * filename) ;
10641089
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+
10651100 // If this was output in the `deps` dir then this is a precise file
10661101 // 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) {
10681103 deps. push ( filename. to_path_buf ( ) ) ;
10691104 continue ;
10701105 }
0 commit comments