Skip to content

Commit 40f012a

Browse files
committedFeb 19, 2023
Improve building compiler artifacts output
1 parent eebdfb5 commit 40f012a

File tree

2 files changed

+132
-39
lines changed

2 files changed

+132
-39
lines changed
 

‎src/bootstrap/compile.rs

+78-33
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,18 @@ impl Step for Std {
111111
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
112112
if compiler_to_use != compiler {
113113
builder.ensure(Std::new(compiler_to_use, target));
114-
builder.info(&format!(
115-
"Uplifting stage1 library ({} -> {})",
116-
compiler_to_use.host, target
117-
));
114+
let msg = if compiler_to_use.host == target {
115+
format!(
116+
"Uplifting library (stage{} -> stage{})",
117+
compiler_to_use.stage, compiler.stage
118+
)
119+
} else {
120+
format!(
121+
"Uplifting library (stage{}:{} -> stage{}:{})",
122+
compiler_to_use.stage, compiler_to_use.host, compiler.stage, target
123+
)
124+
};
125+
builder.info(&msg);
118126

119127
// Even if we're not building std this stage, the new sysroot must
120128
// still contain the third party objects needed by various targets.
@@ -134,13 +142,23 @@ impl Step for Std {
134142
cargo.arg("-p").arg(krate);
135143
}
136144

137-
builder.info(&format!(
138-
"Building{} stage{} library artifacts ({} -> {})",
139-
crate_description(&self.crates),
140-
compiler.stage,
141-
&compiler.host,
142-
target,
143-
));
145+
let msg = if compiler.host == target {
146+
format!(
147+
"Building{} stage{} library artifacts ({}) ",
148+
crate_description(&self.crates),
149+
compiler.stage,
150+
compiler.host
151+
)
152+
} else {
153+
format!(
154+
"Building{} stage{} library artifacts ({} -> {})",
155+
crate_description(&self.crates),
156+
compiler.stage,
157+
compiler.host,
158+
target,
159+
)
160+
};
161+
builder.info(&msg);
144162
run_cargo(
145163
builder,
146164
cargo,
@@ -438,10 +456,6 @@ impl Step for StdLink {
438456
let compiler = self.compiler;
439457
let target_compiler = self.target_compiler;
440458
let target = self.target;
441-
builder.info(&format!(
442-
"Copying stage{} library from stage{} ({} -> {} / {})",
443-
target_compiler.stage, compiler.stage, &compiler.host, target_compiler.host, target
444-
));
445459
let libdir = builder.sysroot_libdir(target_compiler, target);
446460
let hostdir = builder.sysroot_libdir(target_compiler, compiler.host);
447461
add_to_sysroot(builder, &libdir, &hostdir, &libstd_stamp(builder, compiler, target));
@@ -715,8 +729,22 @@ impl Step for Rustc {
715729
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
716730
if compiler_to_use != compiler {
717731
builder.ensure(Rustc::new(compiler_to_use, target));
718-
builder
719-
.info(&format!("Uplifting stage1 rustc ({} -> {})", builder.config.build, target));
732+
let msg = if compiler_to_use.host == target {
733+
format!(
734+
"Uplifting rustc (stage{} -> stage{})",
735+
compiler_to_use.stage,
736+
compiler.stage + 1
737+
)
738+
} else {
739+
format!(
740+
"Uplifting rustc (stage{}:{} -> stage{}:{})",
741+
compiler_to_use.stage,
742+
compiler_to_use.host,
743+
compiler.stage + 1,
744+
target
745+
)
746+
};
747+
builder.info(&msg);
720748
builder.ensure(RustcLink::from_rustc(self, compiler_to_use));
721749
return;
722750
}
@@ -810,13 +838,24 @@ impl Step for Rustc {
810838
cargo.arg("-p").arg(krate);
811839
}
812840

813-
builder.info(&format!(
814-
"Building{} stage{} compiler artifacts ({} -> {})",
815-
crate_description(&self.crates),
816-
compiler.stage,
817-
&compiler.host,
818-
target,
819-
));
841+
let msg = if compiler.host == target {
842+
format!(
843+
"Building{} compiler artifacts (stage{} -> stage{})",
844+
crate_description(&self.crates),
845+
compiler.stage,
846+
compiler.stage + 1
847+
)
848+
} else {
849+
format!(
850+
"Building{} compiler artifacts (stage{}:{} -> stage{}:{})",
851+
crate_description(&self.crates),
852+
compiler.stage,
853+
compiler.host,
854+
compiler.stage + 1,
855+
target,
856+
)
857+
};
858+
builder.info(&msg);
820859
run_cargo(
821860
builder,
822861
cargo,
@@ -1000,10 +1039,6 @@ impl Step for RustcLink {
10001039
let compiler = self.compiler;
10011040
let target_compiler = self.target_compiler;
10021041
let target = self.target;
1003-
builder.info(&format!(
1004-
"Copying stage{} rustc from stage{} ({} -> {} / {})",
1005-
target_compiler.stage, compiler.stage, &compiler.host, target_compiler.host, target
1006-
));
10071042
add_to_sysroot(
10081043
builder,
10091044
&builder.sysroot_libdir(target_compiler, target),
@@ -1077,10 +1112,15 @@ impl Step for CodegenBackend {
10771112

10781113
let tmp_stamp = out_dir.join(".tmp.stamp");
10791114

1080-
builder.info(&format!(
1081-
"Building stage{} codegen backend {} ({} -> {})",
1082-
compiler.stage, backend, &compiler.host, target
1083-
));
1115+
let msg = if compiler.host == target {
1116+
format!("Building stage{} codegen backend {}", compiler.stage, backend)
1117+
} else {
1118+
format!(
1119+
"Building stage{} codegen backend {} ({} -> {})",
1120+
compiler.stage, backend, compiler.host, target
1121+
)
1122+
};
1123+
builder.info(&msg);
10841124
let files = run_cargo(builder, cargo, vec![], &tmp_stamp, vec![], false, false);
10851125
if builder.config.dry_run() {
10861126
return;
@@ -1386,7 +1426,12 @@ impl Step for Assemble {
13861426

13871427
let stage = target_compiler.stage;
13881428
let host = target_compiler.host;
1389-
builder.info(&format!("Assembling stage{} compiler ({})", stage, host));
1429+
let msg = if build_compiler.host == host {
1430+
format!("Assembling stage{} compiler", stage)
1431+
} else {
1432+
format!("Assembling stage{} compiler ({})", stage, host)
1433+
};
1434+
builder.info(&msg);
13901435

13911436
// Link in all dylibs to the libdir
13921437
let stamp = librustc_stamp(builder, build_compiler, target_compiler.host);

‎src/bootstrap/tool.rs

+54-6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,44 @@ struct ToolBuild {
3333
allow_features: &'static str,
3434
}
3535

36+
fn tooling_output(
37+
mode: Mode,
38+
tool: &str,
39+
build_stage: u32,
40+
host: &TargetSelection,
41+
target: &TargetSelection,
42+
) -> String {
43+
match mode {
44+
// depends on compiler stage, different to host compiler
45+
Mode::ToolRustc => {
46+
if host == target {
47+
format!("Building tool {} (stage{} -> stage{})", tool, build_stage, build_stage + 1)
48+
} else {
49+
format!(
50+
"Building tool {} (stage{}:{} -> stage{}:{})",
51+
tool,
52+
build_stage,
53+
host,
54+
build_stage + 1,
55+
target
56+
)
57+
}
58+
}
59+
// doesn't depend on compiler, same as host compiler
60+
Mode::ToolStd => {
61+
if host == target {
62+
format!("Building tool {} (stage{})", tool, build_stage)
63+
} else {
64+
format!(
65+
"Building tool {} (stage{}:{} -> stage{}:{})",
66+
tool, build_stage, host, build_stage, target
67+
)
68+
}
69+
}
70+
_ => format!("Building tool {} (stage{})", tool, build_stage),
71+
}
72+
}
73+
3674
impl Step for ToolBuild {
3775
type Output = Option<PathBuf>;
3876

@@ -74,8 +112,14 @@ impl Step for ToolBuild {
74112
if !self.allow_features.is_empty() {
75113
cargo.allow_features(self.allow_features);
76114
}
77-
78-
builder.info(&format!("Building stage{} tool {} ({})", compiler.stage, tool, target));
115+
let msg = tooling_output(
116+
self.mode,
117+
self.tool,
118+
self.compiler.stage,
119+
&self.compiler.host,
120+
&self.target,
121+
);
122+
builder.info(&msg);
79123
let mut duplicates = Vec::new();
80124
let is_expected = compile::stream_cargo(builder, cargo, vec![], &mut |msg| {
81125
// Only care about big things like the RLS/Cargo for now
@@ -562,10 +606,14 @@ impl Step for Rustdoc {
562606
features.as_slice(),
563607
);
564608

565-
builder.info(&format!(
566-
"Building rustdoc for stage{} ({})",
567-
target_compiler.stage, target_compiler.host
568-
));
609+
let msg = tooling_output(
610+
Mode::ToolRustc,
611+
"rustdoc",
612+
build_compiler.stage,
613+
&self.compiler.host,
614+
&target,
615+
);
616+
builder.info(&msg);
569617
builder.run(&mut cargo.into());
570618

571619
// Cargo adds a number of paths to the dylib search path on windows, which results in

0 commit comments

Comments
 (0)
Please sign in to comment.