@@ -32,6 +32,19 @@ macro_rules! targets {
3232 ( libstd, Libstd { stage: u32 , compiler: Compiler <' a> } ) ,
3333 ( librustc, Librustc { stage: u32 , compiler: Compiler <' a> } ) ,
3434
35+ // Links the standard library/librustc produced by the compiler
36+ // provided into the host's directory also provided.
37+ ( libstd_link, LibstdLink {
38+ stage: u32 ,
39+ compiler: Compiler <' a>,
40+ host: & ' a str
41+ } ) ,
42+ ( librustc_link, LibrustcLink {
43+ stage: u32 ,
44+ compiler: Compiler <' a>,
45+ host: & ' a str
46+ } ) ,
47+
3548 // Steps for long-running native builds. Ideally these wouldn't
3649 // actually exist and would be part of build scripts, but for now
3750 // these are here.
@@ -107,13 +120,25 @@ fn top_level(build: &Build) -> Vec<Step> {
107120 continue
108121 }
109122 let host = t. target ( host) ;
110- targets. push ( host. librustc ( stage, t. compiler ( stage) ) ) ;
123+ if host. target == build. config . build {
124+ targets. push ( host. librustc ( stage, host. compiler ( stage) ) ) ;
125+ } else {
126+ targets. push ( host. librustc_link ( stage, t. compiler ( stage) ,
127+ host. target ) ) ;
128+ }
111129 for target in build. config . target . iter ( ) {
112130 if !build. flags . target . contains ( target) {
113131 continue
114132 }
115- targets. push ( host. target ( target)
116- . libstd ( stage, t. compiler ( stage) ) ) ;
133+
134+ if host. target == build. config . build {
135+ targets. push ( host. target ( target)
136+ . libstd ( stage, host. compiler ( stage) ) ) ;
137+ } else {
138+ targets. push ( host. target ( target)
139+ . libstd_link ( stage, t. compiler ( stage) ,
140+ host. target ) ) ;
141+ }
117142 }
118143 }
119144 }
@@ -128,10 +153,14 @@ fn add_steps<'a>(build: &'a Build,
128153 target : & Step < ' a > ,
129154 targets : & mut Vec < Step < ' a > > ) {
130155 for step in build. flags . step . iter ( ) {
131- let compiler = host. compiler ( stage) ;
156+ let compiler = host. target ( & build . config . build ) . compiler ( stage) ;
132157 match & step[ ..] {
133158 "libstd" => targets. push ( target. libstd ( stage, compiler) ) ,
134159 "librustc" => targets. push ( target. librustc ( stage, compiler) ) ,
160+ "libstd-link" => targets. push ( target. libstd_link ( stage, compiler,
161+ host. target ) ) ,
162+ "librustc-link" => targets. push ( target. librustc_link ( stage, compiler,
163+ host. target ) ) ,
135164 "rustc" => targets. push ( host. rustc ( stage) ) ,
136165 "llvm" => targets. push ( target. llvm ( ( ) ) ) ,
137166 "compiler-rt" => targets. push ( target. compiler_rt ( ( ) ) ) ,
@@ -179,6 +208,14 @@ impl<'a> Step<'a> {
179208 vec ! [ self . compiler_rt( ( ) ) ,
180209 self . rustc( compiler. stage) . target( compiler. host) ]
181210 }
211+ Source :: LibrustcLink { stage, compiler, host } => {
212+ vec ! [ self . librustc( stage, compiler) ,
213+ self . libstd_link( stage, compiler, host) ]
214+ }
215+ Source :: LibstdLink { stage, compiler, host } => {
216+ vec ! [ self . libstd( stage, compiler) ,
217+ self . target( host) . rustc( stage) ]
218+ }
182219 Source :: CompilerRt { _dummy } => {
183220 vec ! [ self . llvm( ( ) ) . target( & build. config. build) ]
184221 }
0 commit comments