Skip to content

Commit 2566fa2

Browse files
committed
Revert "Add a file to trivially disable tool building or testing"
This reverts commit ab018c7. This also adds the `ToolBuild::is_ext_tool` field to replace the previous `ToolBuild::expectation` field, to indicate whether a build-failure of certain tool is essential.
1 parent 519f92f commit 2566fa2

File tree

10 files changed

+56
-232
lines changed

10 files changed

+56
-232
lines changed

src/bootstrap/check.rs

+8-28
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::path::{PathBuf, Path};
2323
use std::process::Command;
2424
use std::io::Read;
2525

26-
use build_helper::{self, output, BuildExpectation};
26+
use build_helper::{self, output};
2727

2828
use builder::{Kind, RunConfig, ShouldRun, Builder, Compiler, Step};
2929
use cache::{INTERNER, Interned};
@@ -65,23 +65,19 @@ impl fmt::Display for TestKind {
6565
}
6666
}
6767

68-
fn try_run_expecting(build: &Build, cmd: &mut Command, expect: BuildExpectation) -> bool {
68+
fn try_run(build: &Build, cmd: &mut Command) -> bool {
6969
if !build.fail_fast {
70-
if !build.try_run(cmd, expect) {
70+
if !build.try_run(cmd) {
7171
let mut failures = build.delayed_failures.borrow_mut();
7272
failures.push(format!("{:?}", cmd));
7373
return false;
7474
}
7575
} else {
76-
build.run_expecting(cmd, expect);
76+
build.run(cmd);
7777
}
7878
true
7979
}
8080

81-
fn try_run(build: &Build, cmd: &mut Command) {
82-
try_run_expecting(build, cmd, BuildExpectation::None);
83-
}
84-
8581
fn try_run_quiet(build: &Build, cmd: &mut Command) {
8682
if !build.fail_fast {
8783
if !build.try_run_quiet(cmd) {
@@ -259,11 +255,7 @@ impl Step for Rls {
259255

260256
builder.add_rustc_lib_path(compiler, &mut cargo);
261257

262-
if try_run_expecting(
263-
build,
264-
&mut cargo,
265-
builder.build.config.toolstate.rls.passes(ToolState::Testing),
266-
) {
258+
if try_run(build, &mut cargo) {
267259
build.save_toolstate("rls", ToolState::Testing);
268260
}
269261
}
@@ -309,11 +301,7 @@ impl Step for Rustfmt {
309301

310302
builder.add_rustc_lib_path(compiler, &mut cargo);
311303

312-
if try_run_expecting(
313-
build,
314-
&mut cargo,
315-
builder.build.config.toolstate.rustfmt.passes(ToolState::Testing),
316-
) {
304+
if try_run(build, &mut cargo) {
317305
build.save_toolstate("rustfmt", ToolState::Testing);
318306
}
319307
}
@@ -363,11 +351,7 @@ impl Step for Miri {
363351

364352
builder.add_rustc_lib_path(compiler, &mut cargo);
365353

366-
if try_run_expecting(
367-
build,
368-
&mut cargo,
369-
builder.build.config.toolstate.miri.passes(ToolState::Testing),
370-
) {
354+
if try_run(build, &mut cargo) {
371355
build.save_toolstate("miri", ToolState::Testing);
372356
}
373357
} else {
@@ -422,11 +406,7 @@ impl Step for Clippy {
422406

423407
builder.add_rustc_lib_path(compiler, &mut cargo);
424408

425-
if try_run_expecting(
426-
build,
427-
&mut cargo,
428-
builder.build.config.toolstate.clippy.passes(ToolState::Testing),
429-
) {
409+
if try_run(build, &mut cargo) {
430410
build.save_toolstate("clippy-driver", ToolState::Testing);
431411
}
432412
} else {

src/bootstrap/config.rs

-15
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use util::exe;
2727
use cache::{INTERNER, Interned};
2828
use flags::Flags;
2929
pub use flags::Subcommand;
30-
use toolstate::ToolStates;
3130

3231
/// Global configuration for the entire build and/or bootstrap.
3332
///
@@ -134,8 +133,6 @@ pub struct Config {
134133
// These are either the stage0 downloaded binaries or the locally installed ones.
135134
pub initial_cargo: PathBuf,
136135
pub initial_rustc: PathBuf,
137-
138-
pub toolstate: ToolStates,
139136
}
140137

141138
/// Per-target configuration stored in the global configuration structure.
@@ -348,18 +345,6 @@ impl Config {
348345
}
349346
}).unwrap_or_else(|| TomlConfig::default());
350347

351-
let toolstate_toml_path = config.src.join("src/tools/toolstate.toml");
352-
let parse_toolstate = || -> Result<_, Box<::std::error::Error>> {
353-
let mut f = File::open(toolstate_toml_path)?;
354-
let mut contents = String::new();
355-
f.read_to_string(&mut contents)?;
356-
Ok(toml::from_str(&contents)?)
357-
};
358-
config.toolstate = parse_toolstate().unwrap_or_else(|err| {
359-
println!("failed to parse TOML configuration 'toolstate.toml': {}", err);
360-
process::exit(2);
361-
});
362-
363348
let build = toml.build.clone().unwrap_or(Build::default());
364349
set(&mut config.build, build.build.clone().map(|x| INTERNER.intern_string(x)));
365350
set(&mut config.build, flags.build);

src/bootstrap/dist.rs

-10
Original file line numberDiff line numberDiff line change
@@ -1077,11 +1077,6 @@ impl Step for Rls {
10771077
let target = self.target;
10781078
assert!(build.config.extended);
10791079

1080-
if !builder.config.toolstate.rls.testing() {
1081-
println!("skipping Dist RLS stage{} ({})", stage, target);
1082-
return None
1083-
}
1084-
10851080
println!("Dist RLS stage{} ({})", stage, target);
10861081
let src = build.src.join("src/tools/rls");
10871082
let release_num = build.release_num("rls");
@@ -1164,11 +1159,6 @@ impl Step for Rustfmt {
11641159
let target = self.target;
11651160
assert!(build.config.extended);
11661161

1167-
if !builder.config.toolstate.rustfmt.testing() {
1168-
println!("skipping Dist Rustfmt stage{} ({})", stage, target);
1169-
return None
1170-
}
1171-
11721162
println!("Dist Rustfmt stage{} ({})", stage, target);
11731163
let src = build.src.join("src/tools/rustfmt");
11741164
let release_num = build.release_num("rustfmt");

src/bootstrap/lib.rs

+10-18
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ use std::path::{PathBuf, Path};
143143
use std::process::{self, Command};
144144
use std::slice;
145145

146-
use build_helper::{run_silent, run_suppressed, try_run_silent, try_run_suppressed, output, mtime,
147-
BuildExpectation};
146+
use build_helper::{run_silent, run_suppressed, try_run_silent, try_run_suppressed, output, mtime};
148147

149148
use util::{exe, libdir, OutputFolder, CiEnv};
150149

@@ -569,39 +568,32 @@ impl Build {
569568
.join(libdir(&self.config.build))
570569
}
571570

572-
/// Runs a command, printing out nice contextual information if its build
573-
/// status is not the expected one
574-
fn run_expecting(&self, cmd: &mut Command, expect: BuildExpectation) {
575-
self.verbose(&format!("running: {:?}", cmd));
576-
run_silent(cmd, expect)
577-
}
578-
579571
/// Runs a command, printing out nice contextual information if it fails.
580572
fn run(&self, cmd: &mut Command) {
581-
self.run_expecting(cmd, BuildExpectation::None)
573+
self.verbose(&format!("running: {:?}", cmd));
574+
run_silent(cmd)
582575
}
583576

584577
/// Runs a command, printing out nice contextual information if it fails.
585578
fn run_quiet(&self, cmd: &mut Command) {
586579
self.verbose(&format!("running: {:?}", cmd));
587-
run_suppressed(cmd, BuildExpectation::None)
580+
run_suppressed(cmd)
588581
}
589582

590-
/// Runs a command, printing out nice contextual information if its build
591-
/// status is not the expected one.
592-
/// Exits if the command failed to execute at all, otherwise returns whether
593-
/// the expectation was met
594-
fn try_run(&self, cmd: &mut Command, expect: BuildExpectation) -> bool {
583+
/// Runs a command, printing out nice contextual information if it fails.
584+
/// Exits if the command failed to execute at all, otherwise returns its
585+
/// `status.success()`.
586+
fn try_run(&self, cmd: &mut Command) -> bool {
595587
self.verbose(&format!("running: {:?}", cmd));
596-
try_run_silent(cmd, expect)
588+
try_run_silent(cmd)
597589
}
598590

599591
/// Runs a command, printing out nice contextual information if it fails.
600592
/// Exits if the command failed to execute at all, otherwise returns its
601593
/// `status.success()`.
602594
fn try_run_quiet(&self, cmd: &mut Command) -> bool {
603595
self.verbose(&format!("running: {:?}", cmd));
604-
try_run_suppressed(cmd, BuildExpectation::None)
596+
try_run_suppressed(cmd)
605597
}
606598

607599
pub fn is_verbose(&self) -> bool {

src/bootstrap/tool.rs

+13-24
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use native;
2222
use channel::GitInfo;
2323
use cache::Interned;
2424
use toolstate::ToolState;
25-
use build_helper::BuildExpectation;
2625

2726
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
2827
pub struct CleanTools {
@@ -82,7 +81,7 @@ struct ToolBuild {
8281
tool: &'static str,
8382
path: &'static str,
8483
mode: Mode,
85-
expectation: BuildExpectation,
84+
is_ext_tool: bool,
8685
}
8786

8887
impl Step for ToolBuild {
@@ -102,7 +101,7 @@ impl Step for ToolBuild {
102101
let target = self.target;
103102
let tool = self.tool;
104103
let path = self.path;
105-
let expectation = self.expectation;
104+
let is_ext_tool = self.is_ext_tool;
106105

107106
match self.mode {
108107
Mode::Libstd => builder.ensure(compile::Std { compiler, target }),
@@ -115,34 +114,25 @@ impl Step for ToolBuild {
115114
println!("Building stage{} tool {} ({})", compiler.stage, tool, target);
116115

117116
let mut cargo = prepare_tool_cargo(builder, compiler, target, "build", path);
118-
let is_expected = build.try_run(&mut cargo, expectation);
119-
// If the expectation is "Failing", `try_run` returning true actually
120-
// means a build-failure is successfully observed, i.e. the tool is
121-
// broken. Thus the XOR here.
122-
// Sorry for the complicated logic, but we can remove this expectation
123-
// logic after #45861 is fully fixed.
124-
build.save_toolstate(tool, if is_expected ^ (expectation == BuildExpectation::Failing) {
117+
let is_expected = build.try_run(&mut cargo);
118+
build.save_toolstate(tool, if is_expected {
125119
ToolState::Compiling
126120
} else {
127121
ToolState::Broken
128122
});
129123

130124
if !is_expected {
131-
if expectation == BuildExpectation::None {
125+
if !is_ext_tool {
132126
exit(1);
133127
} else {
134128
return None;
135129
}
136-
}
137-
138-
if expectation == BuildExpectation::Succeeding || expectation == BuildExpectation::None {
130+
} else {
139131
let cargo_out = build.cargo_out(compiler, Mode::Tool, target)
140132
.join(exe(tool, &compiler.host));
141133
let bin = build.tools_dir(compiler).join(exe(tool, &compiler.host));
142134
copy(&cargo_out, &bin);
143135
Some(bin)
144-
} else {
145-
None
146136
}
147137
}
148138
}
@@ -251,8 +241,8 @@ macro_rules! tool {
251241
tool: $tool_name,
252242
mode: $mode,
253243
path: $path,
254-
expectation: BuildExpectation::None,
255-
}).expect("expected to build -- BuildExpectation::None")
244+
is_ext_tool: false,
245+
}).expect("expected to build -- essential tool")
256246
}
257247
}
258248
)+
@@ -299,8 +289,8 @@ impl Step for RemoteTestServer {
299289
tool: "remote-test-server",
300290
mode: Mode::Libstd,
301291
path: "src/tools/remote-test-server",
302-
expectation: BuildExpectation::None,
303-
}).expect("expected to build -- BuildExpectation::None")
292+
is_ext_tool: false,
293+
}).expect("expected to build -- essential tool")
304294
}
305295
}
306296

@@ -417,8 +407,8 @@ impl Step for Cargo {
417407
tool: "cargo",
418408
mode: Mode::Librustc,
419409
path: "src/tools/cargo",
420-
expectation: BuildExpectation::None,
421-
}).expect("BuildExpectation::None - expected to build")
410+
is_ext_tool: false,
411+
}).expect("expected to build -- essential tool")
422412
}
423413
}
424414

@@ -455,14 +445,13 @@ macro_rules! tool_extended {
455445

456446
fn run($sel, $builder: &Builder) -> Option<PathBuf> {
457447
$extra_deps
458-
let toolstate = $builder.build.config.toolstate.$toolstate;
459448
$builder.ensure(ToolBuild {
460449
compiler: $sel.compiler,
461450
target: $sel.target,
462451
tool: $tool_name,
463452
mode: Mode::Librustc,
464453
path: $path,
465-
expectation: toolstate.passes(ToolState::Compiling),
454+
is_ext_tool: true,
466455
})
467456
}
468457
}

src/bootstrap/toolstate.rs

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

11-
use build_helper::BuildExpectation;
12-
1311
#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
1412
/// Whether a tool can be compiled, tested or neither
1513
pub enum ToolState {
@@ -21,38 +19,9 @@ pub enum ToolState {
2119
Broken = 0,
2220
}
2321

24-
impl ToolState {
25-
/// If a tool with the current toolstate should be working on
26-
/// the given toolstate
27-
pub fn passes(self, other: ToolState) -> BuildExpectation {
28-
if self as usize >= other as usize {
29-
BuildExpectation::Succeeding
30-
} else {
31-
BuildExpectation::Failing
32-
}
33-
}
34-
35-
pub fn testing(&self) -> bool {
36-
match *self {
37-
ToolState::Testing => true,
38-
_ => false,
39-
}
40-
}
41-
}
42-
4322
impl Default for ToolState {
4423
fn default() -> Self {
4524
// err on the safe side
4625
ToolState::Broken
4726
}
4827
}
49-
50-
#[derive(Copy, Clone, Debug, Deserialize, Default)]
51-
/// Used to express which tools should (not) be compiled or tested.
52-
/// This is created from `toolstate.toml`.
53-
pub struct ToolStates {
54-
pub miri: ToolState,
55-
pub clippy: ToolState,
56-
pub rls: ToolState,
57-
pub rustfmt: ToolState,
58-
}

0 commit comments

Comments
 (0)