Skip to content

Commit 34b95a3

Browse files
committed
Auto merge of #32206 - alexcrichton:fix-windows-rustbuild, r=brson
Fix Windows rustbuild These commits fix the rustbuild Windows bots, namely: * The 32-bit build of LLVM was failing because libraries weren't being linked. This was in turn caused by the build script for `rustc_llvm` erroneously detecting that it was cross compiling when it actually wasn't. * Tools of the build were compiled against the wrong libraries, so running them would fail on Windows as rpath didn't exist and `PATH` was wrong. * Some linkchecker fixes for Windows paths had to be applied as well.
2 parents 9ca7561 + 158b854 commit 34b95a3

File tree

9 files changed

+143
-167
lines changed

9 files changed

+143
-167
lines changed

src/bootstrap/build/check.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::process::Command;
12-
1311
use build::{Build, Compiler};
1412

1513
pub fn linkcheck(build: &Build, stage: u32, host: &str) {
1614
println!("Linkcheck stage{} ({})", stage, host);
1715
let compiler = Compiler::new(stage, host);
18-
let linkchecker = build.tool(&compiler, "linkchecker");
19-
build.run(Command::new(&linkchecker)
20-
.arg(build.out.join(host).join("doc")));
16+
build.run(build.tool_cmd(&compiler, "linkchecker")
17+
.arg(build.out.join(host).join("doc")));
2118
}

src/bootstrap/build/compile.rs

+33-34
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,23 @@ use build::{Build, Compiler, Mode};
2323
/// This will build the standard library for a particular stage of the build
2424
/// using the `compiler` targeting the `target` architecture. The artifacts
2525
/// created will also be linked into the sysroot directory.
26-
pub fn std<'a>(build: &'a Build, stage: u32, target: &str,
27-
compiler: &Compiler<'a>) {
28-
let host = compiler.host;
29-
println!("Building stage{} std artifacts ({} -> {})", stage,
30-
host, target);
26+
pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
27+
println!("Building stage{} std artifacts ({} -> {})", compiler.stage,
28+
compiler.host, target);
3129

3230
// Move compiler-rt into place as it'll be required by the compiler when
3331
// building the standard library to link the dylib of libstd
34-
let libdir = build.sysroot_libdir(stage, &host, target);
32+
let libdir = build.sysroot_libdir(compiler, target);
3533
let _ = fs::remove_dir_all(&libdir);
3634
t!(fs::create_dir_all(&libdir));
3735
t!(fs::hard_link(&build.compiler_rt_built.borrow()[target],
3836
libdir.join(staticlib("compiler-rt", target))));
3937

4038
build_startup_objects(build, target, &libdir);
4139

42-
let out_dir = build.cargo_out(stage, &host, Mode::Libstd, target);
40+
let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
4341
build.clear_if_dirty(&out_dir, &build.compiler_path(compiler));
44-
let mut cargo = build.cargo(stage, compiler, Mode::Libstd, Some(target),
45-
"build");
42+
let mut cargo = build.cargo(compiler, Mode::Libstd, target, "build");
4643
cargo.arg("--features").arg(build.std_features())
4744
.arg("--manifest-path")
4845
.arg(build.src.join("src/rustc/std_shim/Cargo.toml"));
@@ -59,20 +56,20 @@ pub fn std<'a>(build: &'a Build, stage: u32, target: &str,
5956
}
6057

6158
build.run(&mut cargo);
62-
std_link(build, stage, target, compiler, host);
59+
std_link(build, target, compiler, compiler.host);
6360
}
6461

6562
/// Link all libstd rlibs/dylibs into the sysroot location.
6663
///
6764
/// Links those artifacts generated in the given `stage` for `target` produced
6865
/// by `compiler` into `host`'s sysroot.
6966
pub fn std_link(build: &Build,
70-
stage: u32,
7167
target: &str,
7268
compiler: &Compiler,
7369
host: &str) {
74-
let libdir = build.sysroot_libdir(stage, host, target);
75-
let out_dir = build.cargo_out(stage, compiler.host, Mode::Libstd, target);
70+
let target_compiler = Compiler::new(compiler.stage, host);
71+
let libdir = build.sysroot_libdir(&target_compiler, target);
72+
let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
7673

7774
// If we're linking one compiler host's output into another, then we weren't
7875
// called from the `std` method above. In that case we clean out what's
@@ -85,7 +82,8 @@ pub fn std_link(build: &Build,
8582
}
8683
add_to_sysroot(&out_dir, &libdir);
8784

88-
if target.contains("musl") && (target.contains("x86_64") || target.contains("i686")) {
85+
if target.contains("musl") &&
86+
(target.contains("x86_64") || target.contains("i686")) {
8987
copy_third_party_objects(build, target, &libdir);
9088
}
9189
}
@@ -130,17 +128,14 @@ fn build_startup_objects(build: &Build, target: &str, into: &Path) {
130128
/// This will build the compiler for a particular stage of the build using
131129
/// the `compiler` targeting the `target` architecture. The artifacts
132130
/// created will also be linked into the sysroot directory.
133-
pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str,
134-
compiler: &Compiler<'a>) {
135-
let host = compiler.host;
136-
println!("Building stage{} compiler artifacts ({} -> {})", stage,
137-
host, target);
131+
pub fn rustc<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
132+
println!("Building stage{} compiler artifacts ({} -> {})",
133+
compiler.stage, compiler.host, target);
138134

139-
let out_dir = build.cargo_out(stage, &host, Mode::Librustc, target);
140-
build.clear_if_dirty(&out_dir, &libstd_shim(build, stage, &host, target));
135+
let out_dir = build.cargo_out(compiler, Mode::Librustc, target);
136+
build.clear_if_dirty(&out_dir, &libstd_shim(build, compiler, target));
141137

142-
let mut cargo = build.cargo(stage, compiler, Mode::Librustc, Some(target),
143-
"build");
138+
let mut cargo = build.cargo(compiler, Mode::Librustc, target, "build");
144139
cargo.arg("--features").arg(build.rustc_features())
145140
.arg("--manifest-path")
146141
.arg(build.src.join("src/rustc/Cargo.toml"));
@@ -184,27 +179,27 @@ pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str,
184179
}
185180
build.run(&mut cargo);
186181

187-
rustc_link(build, stage, target, compiler, compiler.host);
182+
rustc_link(build, target, compiler, compiler.host);
188183
}
189184

190185
/// Link all librustc rlibs/dylibs into the sysroot location.
191186
///
192187
/// Links those artifacts generated in the given `stage` for `target` produced
193188
/// by `compiler` into `host`'s sysroot.
194189
pub fn rustc_link(build: &Build,
195-
stage: u32,
196190
target: &str,
197191
compiler: &Compiler,
198192
host: &str) {
199-
let libdir = build.sysroot_libdir(stage, host, target);
200-
let out_dir = build.cargo_out(stage, compiler.host, Mode::Librustc, target);
193+
let target_compiler = Compiler::new(compiler.stage, host);
194+
let libdir = build.sysroot_libdir(&target_compiler, target);
195+
let out_dir = build.cargo_out(compiler, Mode::Librustc, target);
201196
add_to_sysroot(&out_dir, &libdir);
202197
}
203198

204199
/// Cargo's output path for the standard library in a given stage, compiled
205200
/// by a particular compiler for the specified target.
206-
fn libstd_shim(build: &Build, stage: u32, host: &str, target: &str) -> PathBuf {
207-
build.cargo_out(stage, host, Mode::Libstd, target).join("libstd_shim.rlib")
201+
fn libstd_shim(build: &Build, compiler: &Compiler, target: &str) -> PathBuf {
202+
build.cargo_out(compiler, Mode::Libstd, target).join("libstd_shim.rlib")
208203
}
209204

210205
fn compiler_file(compiler: &Path, file: &str) -> String {
@@ -219,25 +214,29 @@ fn compiler_file(compiler: &Path, file: &str) -> String {
219214
/// compiler.
220215
pub fn assemble_rustc(build: &Build, stage: u32, host: &str) {
221216
assert!(stage > 0, "the stage0 compiler isn't assembled, it's downloaded");
217+
// The compiler that we're assembling
218+
let target_compiler = Compiler::new(stage, host);
219+
220+
// The compiler that compiled the compiler we're assembling
221+
let build_compiler = Compiler::new(stage - 1, &build.config.build);
222222

223223
// Clear out old files
224-
let sysroot = build.sysroot(stage, host);
224+
let sysroot = build.sysroot(&target_compiler);
225225
let _ = fs::remove_dir_all(&sysroot);
226226
t!(fs::create_dir_all(&sysroot));
227227

228228
// Link in all dylibs to the libdir
229229
let sysroot_libdir = sysroot.join(libdir(host));
230230
t!(fs::create_dir_all(&sysroot_libdir));
231-
let src_libdir = build.sysroot_libdir(stage - 1, &build.config.build, host);
231+
let src_libdir = build.sysroot_libdir(&build_compiler, host);
232232
for f in t!(fs::read_dir(&src_libdir)).map(|f| t!(f)) {
233233
let filename = f.file_name().into_string().unwrap();
234234
if is_dylib(&filename) {
235235
t!(fs::hard_link(&f.path(), sysroot_libdir.join(&filename)));
236236
}
237237
}
238238

239-
let out_dir = build.cargo_out(stage - 1, &build.config.build,
240-
Mode::Librustc, host);
239+
let out_dir = build.cargo_out(&build_compiler, Mode::Librustc, host);
241240

242241
// Link the compiler binary itself into place
243242
let rustc = out_dir.join(exe("rustc", host));
@@ -315,7 +314,7 @@ pub fn tool(build: &Build, stage: u32, host: &str, tool: &str) {
315314
// let out_dir = build.cargo_out(stage, &host, Mode::Librustc, target);
316315
// build.clear_if_dirty(&out_dir, &libstd_shim(build, stage, &host, target));
317316

318-
let mut cargo = build.cargo(stage, &compiler, Mode::Tool, None, "build");
317+
let mut cargo = build.cargo(&compiler, Mode::Tool, host, "build");
319318
cargo.arg("--manifest-path")
320319
.arg(build.src.join(format!("src/tools/{}/Cargo.toml", tool)));
321320
build.run(&mut cargo);

src/bootstrap/build/doc.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ pub fn standalone(build: &Build, stage: u32, host: &str, out: &Path) {
8181
}
8282

8383
let mut cmd = Command::new(&rustdoc);
84+
build.add_rustc_lib_path(&compiler, &mut cmd);
8485
cmd.arg("--html-after-content").arg(&footer)
8586
.arg("--html-before-content").arg(&version_info)
8687
.arg("--html-in-header").arg(&favicon)
@@ -107,14 +108,13 @@ pub fn standalone(build: &Build, stage: u32, host: &str, out: &Path) {
107108
pub fn std(build: &Build, stage: u32, host: &str, out: &Path) {
108109
println!("Documenting stage{} std ({})", stage, host);
109110
let compiler = Compiler::new(stage, host);
110-
let out_dir = build.stage_out(stage, host, Mode::Libstd)
111+
let out_dir = build.stage_out(&compiler, Mode::Libstd)
111112
.join(host).join("doc");
112113
let rustdoc = build.rustdoc(&compiler);
113114

114115
build.clear_if_dirty(&out_dir, &rustdoc);
115116

116-
let mut cargo = build.cargo(stage, &compiler, Mode::Libstd, Some(host),
117-
"doc");
117+
let mut cargo = build.cargo(&compiler, Mode::Libstd, host, "doc");
118118
cargo.arg("--manifest-path")
119119
.arg(build.src.join("src/rustc/std_shim/Cargo.toml"))
120120
.arg("--features").arg(build.std_features());
@@ -125,14 +125,13 @@ pub fn std(build: &Build, stage: u32, host: &str, out: &Path) {
125125
pub fn rustc(build: &Build, stage: u32, host: &str, out: &Path) {
126126
println!("Documenting stage{} compiler ({})", stage, host);
127127
let compiler = Compiler::new(stage, host);
128-
let out_dir = build.stage_out(stage, host, Mode::Librustc)
128+
let out_dir = build.stage_out(&compiler, Mode::Librustc)
129129
.join(host).join("doc");
130130
let rustdoc = build.rustdoc(&compiler);
131131
if !up_to_date(&rustdoc, &out_dir.join("rustc/index.html")) {
132132
t!(fs::remove_dir_all(&out_dir));
133133
}
134-
let mut cargo = build.cargo(stage, &compiler, Mode::Librustc, Some(host),
135-
"doc");
134+
let mut cargo = build.cargo(&compiler, Mode::Librustc, host, "doc");
136135
cargo.arg("--manifest-path")
137136
.arg(build.src.join("src/rustc/Cargo.toml"))
138137
.arg("--features").arg(build.rustc_features());
@@ -143,7 +142,7 @@ pub fn rustc(build: &Build, stage: u32, host: &str, out: &Path) {
143142
pub fn error_index(build: &Build, stage: u32, host: &str, out: &Path) {
144143
println!("Documenting stage{} error index ({})", stage, host);
145144
let compiler = Compiler::new(stage, host);
146-
let mut index = Command::new(build.tool(&compiler, "error_index_generator"));
145+
let mut index = build.tool_cmd(&compiler, "error_index_generator");
147146
index.arg("html");
148147
index.arg(out.join("error-index.html"));
149148

0 commit comments

Comments
 (0)