@@ -211,7 +211,7 @@ impl Step for StdLink {
211
211
target_compiler. host,
212
212
target) ) ;
213
213
let libdir = builder. sysroot_libdir ( target_compiler, target) ;
214
- add_to_sysroot ( builder, & libdir, & libstd_stamp ( builder, compiler, target) ) ;
214
+ add_to_sysroot ( builder, & libdir, & libstd_stamp ( builder, compiler, target) , None ) ;
215
215
216
216
if builder. config . sanitizers && compiler. stage != 0 && target == "x86_64-apple-darwin" {
217
217
// The sanitizers are only built in stage1 or above, so the dylibs will
@@ -414,7 +414,7 @@ impl Step for TestLink {
414
414
target_compiler. host,
415
415
target) ) ;
416
416
add_to_sysroot ( builder, & builder. sysroot_libdir ( target_compiler, target) ,
417
- & libtest_stamp ( builder, compiler, target) ) ;
417
+ & libtest_stamp ( builder, compiler, target) , None ) ;
418
418
419
419
builder. cargo ( target_compiler, Mode :: ToolTest , target, "clean" ) ;
420
420
}
@@ -574,8 +574,13 @@ impl Step for RustcLink {
574
574
& compiler. host,
575
575
target_compiler. host,
576
576
target) ) ;
577
- add_to_sysroot ( builder, & builder. sysroot_libdir ( target_compiler, target) ,
578
- & librustc_stamp ( builder, compiler, target) ) ;
577
+ let stage_out = builder. build . stage_out ( target_compiler, Mode :: Rustc ) ;
578
+ add_to_sysroot (
579
+ builder,
580
+ & builder. sysroot_libdir ( target_compiler, target) ,
581
+ & librustc_stamp ( builder, compiler, target) ,
582
+ if compiler. stage == 0 { Some ( & stage_out) } else { None } ,
583
+ ) ;
579
584
builder. cargo ( target_compiler, Mode :: ToolRustc , target, "clean" ) ;
580
585
}
581
586
}
@@ -982,10 +987,26 @@ impl Step for Assemble {
982
987
///
983
988
/// For a particular stage this will link the file listed in `stamp` into the
984
989
/// `sysroot_dst` provided.
985
- pub fn add_to_sysroot ( builder : & Builder , sysroot_dst : & Path , stamp : & Path ) {
990
+ pub fn add_to_sysroot (
991
+ builder : & Builder ,
992
+ sysroot_dst : & Path ,
993
+ stamp : & Path ,
994
+ stage_out : Option < & Path > ) {
986
995
t ! ( fs:: create_dir_all( & sysroot_dst) ) ;
987
996
for path in builder. read_stamp_file ( stamp) {
988
- builder. copy ( & path, & sysroot_dst. join ( path. file_name ( ) . unwrap ( ) ) ) ;
997
+ let file_dir = path. parent ( ) . unwrap ( ) // chop off base name
998
+ . parent ( ) . unwrap ( ) // chop off `release`
999
+ . parent ( ) . unwrap ( ) ; // chop off `release`
1000
+ if stage_out == Some ( file_dir) {
1001
+ // We are copying a build file. We need to add the build triple to it
1002
+ let rustlib_dir = sysroot_dst. parent ( ) . unwrap ( ) // chop off `lib`
1003
+ . parent ( ) . unwrap ( ) ; // chop off `$target`
1004
+ let build_dir = rustlib_dir. join ( builder. build . build ) . join ( "lib" ) ;
1005
+ t ! ( fs:: create_dir_all( & build_dir) ) ;
1006
+ builder. copy ( & path, & build_dir. join ( path. file_name ( ) . unwrap ( ) ) ) ;
1007
+ } else {
1008
+ builder. copy ( & path, & sysroot_dst. join ( path. file_name ( ) . unwrap ( ) ) ) ;
1009
+ }
989
1010
}
990
1011
}
991
1012
@@ -1014,8 +1035,12 @@ pub fn run_cargo(builder: &Builder,
1014
1035
let mut deps = Vec :: new ( ) ;
1015
1036
let mut toplevel = Vec :: new ( ) ;
1016
1037
let ok = stream_cargo ( builder, cargo, & mut |msg| {
1017
- let filenames = match msg {
1018
- CargoMessage :: CompilerArtifact { filenames, .. } => filenames,
1038
+ let ( filenames, package_id) = match msg {
1039
+ CargoMessage :: CompilerArtifact {
1040
+ filenames,
1041
+ package_id,
1042
+ ..
1043
+ } => ( filenames, package_id) ,
1019
1044
_ => return ,
1020
1045
} ;
1021
1046
for filename in filenames {
@@ -1030,8 +1055,12 @@ pub fn run_cargo(builder: &Builder,
1030
1055
let filename = Path :: new ( & * filename) ;
1031
1056
1032
1057
// If this was an output file in the "host dir" we don't actually
1033
- // worry about it, it's not relevant for us.
1058
+ // worry about it, it's not relevant for us
1034
1059
if filename. starts_with ( & host_root_dir) {
1060
+ // Unless it's a proc macro used in the compiler
1061
+ if package_id. starts_with ( "rustc_macros " ) {
1062
+ deps. push ( filename. to_path_buf ( ) ) ;
1063
+ }
1035
1064
continue ;
1036
1065
}
1037
1066
0 commit comments