Skip to content

Commit 8c2ca6c

Browse files
committed
Revert "Auto merge of #48105 - Mark-Simulacrum:exclude-paths, r=alexcrichton"
This reverts commit c83fa5d, reversing changes made to 90759be.
1 parent 1670a53 commit 8c2ca6c

File tree

10 files changed

+327
-444
lines changed

10 files changed

+327
-444
lines changed

Diff for: src/bootstrap/builder.rs

+23-99
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub struct RunConfig<'a> {
9595
pub builder: &'a Builder<'a>,
9696
pub host: Interned<String>,
9797
pub target: Interned<String>,
98-
pub path: PathBuf,
98+
pub path: Option<&'a Path>,
9999
}
100100

101101
struct StepDescription {
@@ -105,32 +105,6 @@ struct StepDescription {
105105
only_build: bool,
106106
should_run: fn(ShouldRun) -> ShouldRun,
107107
make_run: fn(RunConfig),
108-
name: &'static str,
109-
}
110-
111-
#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq)]
112-
struct PathSet {
113-
set: BTreeSet<PathBuf>,
114-
}
115-
116-
impl PathSet {
117-
fn empty() -> PathSet {
118-
PathSet { set: BTreeSet::new() }
119-
}
120-
121-
fn one<P: Into<PathBuf>>(path: P) -> PathSet {
122-
let mut set = BTreeSet::new();
123-
set.insert(path.into());
124-
PathSet { set }
125-
}
126-
127-
fn has(&self, needle: &Path) -> bool {
128-
self.set.iter().any(|p| p.ends_with(needle))
129-
}
130-
131-
fn path(&self, builder: &Builder) -> PathBuf {
132-
self.set.iter().next().unwrap_or(&builder.build.src).to_path_buf()
133-
}
134108
}
135109

136110
impl StepDescription {
@@ -142,18 +116,10 @@ impl StepDescription {
142116
only_build: S::ONLY_BUILD,
143117
should_run: S::should_run,
144118
make_run: S::make_run,
145-
name: unsafe { ::std::intrinsics::type_name::<S>() },
146119
}
147120
}
148121

149-
fn maybe_run(&self, builder: &Builder, pathset: &PathSet) {
150-
if builder.config.exclude.iter().any(|e| pathset.has(e)) {
151-
eprintln!("Skipping {:?} because it is excluded", pathset);
152-
return;
153-
} else if !builder.config.exclude.is_empty() {
154-
eprintln!("{:?} not skipped for {:?} -- not in {:?}", pathset,
155-
self.name, builder.config.exclude);
156-
}
122+
fn maybe_run(&self, builder: &Builder, path: Option<&Path>) {
157123
let build = builder.build;
158124
let hosts = if self.only_build_targets || self.only_build {
159125
build.build_triple()
@@ -178,7 +144,7 @@ impl StepDescription {
178144
for target in targets {
179145
let run = RunConfig {
180146
builder,
181-
path: pathset.path(builder),
147+
path,
182148
host: *host,
183149
target: *target,
184150
};
@@ -191,28 +157,19 @@ impl StepDescription {
191157
let should_runs = v.iter().map(|desc| {
192158
(desc.should_run)(ShouldRun::new(builder))
193159
}).collect::<Vec<_>>();
194-
195-
// sanity checks on rules
196-
for (desc, should_run) in v.iter().zip(&should_runs) {
197-
assert!(!should_run.paths.is_empty(),
198-
"{:?} should have at least one pathset", desc.name);
199-
}
200-
201160
if paths.is_empty() {
202161
for (desc, should_run) in v.iter().zip(should_runs) {
203162
if desc.default && should_run.is_really_default {
204-
for pathset in &should_run.paths {
205-
desc.maybe_run(builder, pathset);
206-
}
163+
desc.maybe_run(builder, None);
207164
}
208165
}
209166
} else {
210167
for path in paths {
211168
let mut attempted_run = false;
212169
for (desc, should_run) in v.iter().zip(&should_runs) {
213-
if let Some(pathset) = should_run.pathset_for_path(path) {
170+
if should_run.run(path) {
214171
attempted_run = true;
215-
desc.maybe_run(builder, pathset);
172+
desc.maybe_run(builder, Some(path));
216173
}
217174
}
218175

@@ -228,7 +185,7 @@ impl StepDescription {
228185
pub struct ShouldRun<'a> {
229186
pub builder: &'a Builder<'a>,
230187
// use a BTreeSet to maintain sort order
231-
paths: BTreeSet<PathSet>,
188+
paths: BTreeSet<PathBuf>,
232189

233190
// If this is a default rule, this is an additional constraint placed on
234191
// it's run. Generally something like compiler docs being enabled.
@@ -249,46 +206,25 @@ impl<'a> ShouldRun<'a> {
249206
self
250207
}
251208

252-
// Unlike `krate` this will create just one pathset. As such, it probably shouldn't actually
253-
// ever be used, but as we transition to having all rules properly handle passing krate(...) by
254-
// actually doing something different for every crate passed.
255-
pub fn all_krates(mut self, name: &str) -> Self {
256-
let mut set = BTreeSet::new();
257-
for krate in self.builder.in_tree_crates(name) {
258-
set.insert(PathBuf::from(&krate.path));
259-
}
260-
self.paths.insert(PathSet { set });
261-
self
262-
}
263-
264209
pub fn krate(mut self, name: &str) -> Self {
265-
for krate in self.builder.in_tree_crates(name) {
266-
self.paths.insert(PathSet::one(&krate.path));
210+
for (_, krate_path) in self.builder.crates(name) {
211+
self.paths.insert(PathBuf::from(krate_path));
267212
}
268213
self
269214
}
270215

271-
// single, non-aliased path
272-
pub fn path(self, path: &str) -> Self {
273-
self.paths(&[path])
274-
}
275-
276-
// multiple aliases for the same job
277-
pub fn paths(mut self, paths: &[&str]) -> Self {
278-
self.paths.insert(PathSet {
279-
set: paths.iter().map(PathBuf::from).collect(),
280-
});
216+
pub fn path(mut self, path: &str) -> Self {
217+
self.paths.insert(PathBuf::from(path));
281218
self
282219
}
283220

284221
// allows being more explicit about why should_run in Step returns the value passed to it
285-
pub fn never(mut self) -> ShouldRun<'a> {
286-
self.paths.insert(PathSet::empty());
222+
pub fn never(self) -> ShouldRun<'a> {
287223
self
288224
}
289225

290-
fn pathset_for_path(&self, path: &Path) -> Option<&PathSet> {
291-
self.paths.iter().find(|pathset| pathset.has(path))
226+
fn run(&self, path: &Path) -> bool {
227+
self.paths.iter().any(|p| path.ends_with(p))
292228
}
293229
}
294230

@@ -318,23 +254,19 @@ impl<'a> Builder<'a> {
318254
tool::RustInstaller, tool::Cargo, tool::Rls, tool::Rustdoc, tool::Clippy,
319255
native::Llvm, tool::Rustfmt, tool::Miri),
320256
Kind::Check => describe!(check::Std, check::Test, check::Rustc),
321-
Kind::Test => describe!(test::Tidy, test::Bootstrap, test::Ui, test::RunPass,
322-
test::CompileFail, test::ParseFail, test::RunFail, test::RunPassValgrind,
323-
test::MirOpt, test::Codegen, test::CodegenUnits, test::Incremental, test::Debuginfo,
324-
test::UiFullDeps, test::RunPassFullDeps, test::RunFailFullDeps,
325-
test::CompileFailFullDeps, test::IncrementalFullDeps, test::Rustdoc, test::Pretty,
326-
test::RunPassPretty, test::RunFailPretty, test::RunPassValgrindPretty,
327-
test::RunPassFullDepsPretty, test::RunFailFullDepsPretty, test::RunMake,
328-
test::Crate, test::CrateLibrustc, test::Rustdoc, test::Linkcheck, test::Cargotest,
329-
test::Cargo, test::Rls, test::Docs, test::ErrorIndex, test::Distcheck,
330-
test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme),
257+
Kind::Test => describe!(test::Tidy, test::Bootstrap, test::DefaultCompiletest,
258+
test::HostCompiletest, test::Crate, test::CrateLibrustc, test::Rustdoc,
259+
test::Linkcheck, test::Cargotest, test::Cargo, test::Rls, test::Docs,
260+
test::ErrorIndex, test::Distcheck, test::Rustfmt, test::Miri, test::Clippy,
261+
test::RustdocJS, test::RustdocTheme),
331262
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
332263
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
333264
doc::Standalone, doc::Std, doc::Test, doc::Rustc, doc::ErrorIndex, doc::Nomicon,
334265
doc::Reference, doc::Rustdoc, doc::RustByExample, doc::CargoBook),
335266
Kind::Dist => describe!(dist::Docs, dist::Mingw, dist::Rustc, dist::DebuggerScripts,
336267
dist::Std, dist::Analysis, dist::Src, dist::PlainSourceTarball, dist::Cargo,
337-
dist::Rls, dist::Rustfmt, dist::Extended, dist::HashSign),
268+
dist::Rls, dist::Rustfmt, dist::Extended, dist::HashSign,
269+
dist::DontDistWithMiriEnabled),
338270
Kind::Install => describe!(install::Docs, install::Std, install::Cargo, install::Rls,
339271
install::Rustfmt, install::Analysis, install::Src, install::Rustc),
340272
}
@@ -365,10 +297,8 @@ impl<'a> Builder<'a> {
365297
should_run = (desc.should_run)(should_run);
366298
}
367299
let mut help = String::from("Available paths:\n");
368-
for pathset in should_run.paths {
369-
for path in pathset.set {
370-
help.push_str(format!(" ./x.py {} {}\n", subcommand, path.display()).as_str());
371-
}
300+
for path in should_run.paths {
301+
help.push_str(format!(" ./x.py {} {}\n", subcommand, path.display()).as_str());
372302
}
373303
Some(help)
374304
}
@@ -393,12 +323,6 @@ impl<'a> Builder<'a> {
393323
stack: RefCell::new(Vec::new()),
394324
};
395325

396-
if kind == Kind::Dist {
397-
assert!(!build.config.test_miri, "Do not distribute with miri enabled.\n\
398-
The distributed libraries would include all MIR (increasing binary size).
399-
The distributed MIR would include validation statements.");
400-
}
401-
402326
StepDescription::run(&Builder::get_step_descriptions(builder.kind), &builder, paths);
403327
}
404328

Diff for: src/bootstrap/check.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl Step for Std {
2626
const DEFAULT: bool = true;
2727

2828
fn should_run(run: ShouldRun) -> ShouldRun {
29-
run.all_krates("std")
29+
run.path("src/libstd").krate("std")
3030
}
3131

3232
fn make_run(run: RunConfig) {
@@ -67,7 +67,7 @@ impl Step for Rustc {
6767
const DEFAULT: bool = true;
6868

6969
fn should_run(run: ShouldRun) -> ShouldRun {
70-
run.all_krates("rustc-main")
70+
run.path("src/librustc").krate("rustc-main")
7171
}
7272

7373
fn make_run(run: RunConfig) {
@@ -114,7 +114,7 @@ impl Step for Test {
114114
const DEFAULT: bool = true;
115115

116116
fn should_run(run: ShouldRun) -> ShouldRun {
117-
run.all_krates("test")
117+
run.path("src/libtest").krate("test")
118118
}
119119

120120
fn make_run(run: RunConfig) {

Diff for: src/bootstrap/compile.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl Step for Std {
4848
const DEFAULT: bool = true;
4949

5050
fn should_run(run: ShouldRun) -> ShouldRun {
51-
run.all_krates("std")
51+
run.path("src/libstd").krate("std")
5252
}
5353

5454
fn make_run(run: RunConfig) {
@@ -320,7 +320,7 @@ impl Step for Test {
320320
const DEFAULT: bool = true;
321321

322322
fn should_run(run: ShouldRun) -> ShouldRun {
323-
run.all_krates("test")
323+
run.path("src/libtest").krate("test")
324324
}
325325

326326
fn make_run(run: RunConfig) {
@@ -436,7 +436,7 @@ impl Step for Rustc {
436436
const DEFAULT: bool = true;
437437

438438
fn should_run(run: ShouldRun) -> ShouldRun {
439-
run.all_krates("rustc-main")
439+
run.path("src/librustc").krate("rustc-main")
440440
}
441441

442442
fn make_run(run: RunConfig) {
@@ -593,7 +593,7 @@ impl Step for CodegenBackend {
593593
const DEFAULT: bool = true;
594594

595595
fn should_run(run: ShouldRun) -> ShouldRun {
596-
run.all_krates("rustc_trans")
596+
run.path("src/librustc_trans")
597597
}
598598

599599
fn make_run(run: RunConfig) {
@@ -828,7 +828,7 @@ impl Step for Assemble {
828828
type Output = Compiler;
829829

830830
fn should_run(run: ShouldRun) -> ShouldRun {
831-
run.all_krates("rustc-main")
831+
run.path("src/rustc")
832832
}
833833

834834
/// Prepare a new compiler from the artifacts in `stage`

Diff for: src/bootstrap/config.rs

-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ pub struct Config {
5656
pub sanitizers: bool,
5757
pub profiler: bool,
5858
pub ignore_git: bool,
59-
pub exclude: Vec<PathBuf>,
6059

6160
pub run_host_only: bool,
6261

@@ -312,7 +311,6 @@ impl Config {
312311
let flags = Flags::parse(&args);
313312
let file = flags.config.clone();
314313
let mut config = Config::default();
315-
config.exclude = flags.exclude;
316314
config.llvm_enabled = true;
317315
config.llvm_optimize = true;
318316
config.llvm_version_check = true;

Diff for: src/bootstrap/dist.rs

+25
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,31 @@ impl Step for Rustfmt {
12331233
}
12341234
}
12351235

1236+
1237+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
1238+
pub struct DontDistWithMiriEnabled;
1239+
1240+
impl Step for DontDistWithMiriEnabled {
1241+
type Output = PathBuf;
1242+
const DEFAULT: bool = true;
1243+
1244+
fn should_run(run: ShouldRun) -> ShouldRun {
1245+
let build_miri = run.builder.build.config.test_miri;
1246+
run.default_condition(build_miri)
1247+
}
1248+
1249+
fn make_run(run: RunConfig) {
1250+
run.builder.ensure(DontDistWithMiriEnabled);
1251+
}
1252+
1253+
fn run(self, _: &Builder) -> PathBuf {
1254+
panic!("Do not distribute with miri enabled.\n\
1255+
The distributed libraries would include all MIR (increasing binary size).
1256+
The distributed MIR would include validation statements.");
1257+
}
1258+
}
1259+
1260+
12361261
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
12371262
pub struct Extended {
12381263
stage: u32,

Diff for: src/bootstrap/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ impl Step for Std {
429429

430430
fn should_run(run: ShouldRun) -> ShouldRun {
431431
let builder = run.builder;
432-
run.all_krates("std").default_condition(builder.build.config.docs)
432+
run.krate("std").default_condition(builder.build.config.docs)
433433
}
434434

435435
fn make_run(run: RunConfig) {

0 commit comments

Comments
 (0)