Skip to content

Commit 6c70cd1

Browse files
committed
Auto merge of #48599 - Mark-Simulacrum:rustbuild-updates-step-1, r=alexcrichton
Remove ONLY_BUILD and ONLY_BUILD_TARGETS Primarily removes `ONLY_BUILD` and `ONLY_BUILD_TARGETS`. These aren't actually needed in the new system since we can simply not take the relevant `host` and `target` fields if we don't want to run with them in `Step::make_run`. This PR also includes a few other commits which generally clean up the state of rustbuild, but are not related to the `Step` changes.
2 parents 5f2efb0 + 29a8529 commit 6c70cd1

File tree

7 files changed

+46
-59
lines changed

7 files changed

+46
-59
lines changed

src/bootstrap/bin/rustc.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn main() {
9595
let rustc = env::var_os(rustc).unwrap_or_else(|| panic!("{:?} was not set", rustc));
9696
let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{:?} was not set", libdir));
9797
let mut dylib_path = bootstrap::util::dylib_path();
98-
dylib_path.insert(0, PathBuf::from(libdir));
98+
dylib_path.insert(0, PathBuf::from(&libdir));
9999

100100
let mut cmd = Command::new(rustc);
101101
cmd.args(&args)
@@ -107,7 +107,7 @@ fn main() {
107107
if let Some(target) = target {
108108
// The stage0 compiler has a special sysroot distinct from what we
109109
// actually downloaded, so we just always pass the `--sysroot` option.
110-
cmd.arg("--sysroot").arg(sysroot);
110+
cmd.arg("--sysroot").arg(&sysroot);
111111

112112
// When we build Rust dylibs they're all intended for intermediate
113113
// usage, so make sure we pass the -Cprefer-dynamic flag instead of
@@ -280,6 +280,8 @@ fn main() {
280280

281281
if verbose > 1 {
282282
eprintln!("rustc command: {:?}", cmd);
283+
eprintln!("sysroot: {:?}", sysroot);
284+
eprintln!("libdir: {:?}", libdir);
283285
}
284286

285287
// Actually run the compiler!

src/bootstrap/builder.rs

+3-19
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
6060
/// Run this rule for all hosts without cross compiling.
6161
const ONLY_HOSTS: bool = false;
6262

63-
/// Run this rule for all targets, but only with the native host.
64-
const ONLY_BUILD_TARGETS: bool = false;
65-
66-
/// Only run this step with the build triple as host and target.
67-
const ONLY_BUILD: bool = false;
68-
6963
/// Primary function to execute this rule. Can call `builder.ensure(...)`
7064
/// with other steps to run those.
7165
fn run(self, builder: &Builder) -> Self::Output;
@@ -101,8 +95,6 @@ pub struct RunConfig<'a> {
10195
struct StepDescription {
10296
default: bool,
10397
only_hosts: bool,
104-
only_build_targets: bool,
105-
only_build: bool,
10698
should_run: fn(ShouldRun) -> ShouldRun,
10799
make_run: fn(RunConfig),
108100
name: &'static str,
@@ -138,8 +130,6 @@ impl StepDescription {
138130
StepDescription {
139131
default: S::DEFAULT,
140132
only_hosts: S::ONLY_HOSTS,
141-
only_build_targets: S::ONLY_BUILD_TARGETS,
142-
only_build: S::ONLY_BUILD,
143133
should_run: S::should_run,
144134
make_run: S::make_run,
145135
name: unsafe { ::std::intrinsics::type_name::<S>() },
@@ -155,18 +145,12 @@ impl StepDescription {
155145
self.name, builder.config.exclude);
156146
}
157147
let build = builder.build;
158-
let hosts = if self.only_build_targets || self.only_build {
159-
build.build_triple()
160-
} else {
161-
&build.hosts
162-
};
148+
let hosts = &build.hosts;
163149

164150
// Determine the targets participating in this rule.
165151
let targets = if self.only_hosts {
166-
if build.config.run_host_only {
167-
&[]
168-
} else if self.only_build {
169-
build.build_triple()
152+
if !build.config.run_host_only {
153+
return; // don't run anything
170154
} else {
171155
&build.hosts
172156
}

src/bootstrap/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ impl Config {
347347
config.keep_stage = flags.keep_stage;
348348

349349
// If --target was specified but --host wasn't specified, don't run any host-only tests.
350-
config.run_host_only = flags.host.is_empty() && !flags.target.is_empty();
350+
config.run_host_only = !(flags.host.is_empty() && !flags.target.is_empty());
351351

352352
let toml = file.map(|file| {
353353
let mut f = t!(File::open(&file));

src/bootstrap/dist.rs

+3-18
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ pub struct Docs {
7070
impl Step for Docs {
7171
type Output = PathBuf;
7272
const DEFAULT: bool = true;
73-
const ONLY_BUILD_TARGETS: bool = true;
7473

7574
fn should_run(run: ShouldRun) -> ShouldRun {
7675
run.path("src/doc")
@@ -271,7 +270,6 @@ pub struct Mingw {
271270
impl Step for Mingw {
272271
type Output = Option<PathBuf>;
273272
const DEFAULT: bool = true;
274-
const ONLY_BUILD_TARGETS: bool = true;
275273

276274
fn should_run(run: ShouldRun) -> ShouldRun {
277275
run.never()
@@ -331,7 +329,6 @@ impl Step for Rustc {
331329
type Output = PathBuf;
332330
const DEFAULT: bool = true;
333331
const ONLY_HOSTS: bool = true;
334-
const ONLY_BUILD_TARGETS: bool = true;
335332

336333
fn should_run(run: ShouldRun) -> ShouldRun {
337334
run.path("src/librustc")
@@ -561,15 +558,14 @@ pub struct Std {
561558
impl Step for Std {
562559
type Output = PathBuf;
563560
const DEFAULT: bool = true;
564-
const ONLY_BUILD_TARGETS: bool = true;
565561

566562
fn should_run(run: ShouldRun) -> ShouldRun {
567563
run.path("src/libstd")
568564
}
569565

570566
fn make_run(run: RunConfig) {
571567
run.builder.ensure(Std {
572-
compiler: run.builder.compiler(run.builder.top_stage, run.host),
568+
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
573569
target: run.target,
574570
});
575571
}
@@ -638,7 +634,6 @@ pub struct Analysis {
638634
impl Step for Analysis {
639635
type Output = PathBuf;
640636
const DEFAULT: bool = true;
641-
const ONLY_BUILD_TARGETS: bool = true;
642637

643638
fn should_run(run: ShouldRun) -> ShouldRun {
644639
let builder = run.builder;
@@ -647,7 +642,7 @@ impl Step for Analysis {
647642

648643
fn make_run(run: RunConfig) {
649644
run.builder.ensure(Analysis {
650-
compiler: run.builder.compiler(run.builder.top_stage, run.host),
645+
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
651646
target: run.target,
652647
});
653648
}
@@ -755,8 +750,6 @@ impl Step for Src {
755750
type Output = PathBuf;
756751
const DEFAULT: bool = true;
757752
const ONLY_HOSTS: bool = true;
758-
const ONLY_BUILD_TARGETS: bool = true;
759-
const ONLY_BUILD: bool = true;
760753

761754
fn should_run(run: ShouldRun) -> ShouldRun {
762755
run.path("src")
@@ -851,8 +844,6 @@ impl Step for PlainSourceTarball {
851844
type Output = PathBuf;
852845
const DEFAULT: bool = true;
853846
const ONLY_HOSTS: bool = true;
854-
const ONLY_BUILD_TARGETS: bool = true;
855-
const ONLY_BUILD: bool = true;
856847

857848
fn should_run(run: ShouldRun) -> ShouldRun {
858849
let builder = run.builder;
@@ -1007,7 +998,6 @@ pub struct Cargo {
1007998

1008999
impl Step for Cargo {
10091000
type Output = PathBuf;
1010-
const ONLY_BUILD_TARGETS: bool = true;
10111001
const ONLY_HOSTS: bool = true;
10121002

10131003
fn should_run(run: ShouldRun) -> ShouldRun {
@@ -1095,7 +1085,6 @@ pub struct Rls {
10951085

10961086
impl Step for Rls {
10971087
type Output = Option<PathBuf>;
1098-
const ONLY_BUILD_TARGETS: bool = true;
10991088
const ONLY_HOSTS: bool = true;
11001089

11011090
fn should_run(run: ShouldRun) -> ShouldRun {
@@ -1177,7 +1166,6 @@ pub struct Rustfmt {
11771166

11781167
impl Step for Rustfmt {
11791168
type Output = Option<PathBuf>;
1180-
const ONLY_BUILD_TARGETS: bool = true;
11811169
const ONLY_HOSTS: bool = true;
11821170

11831171
fn should_run(run: ShouldRun) -> ShouldRun {
@@ -1263,7 +1251,6 @@ pub struct Extended {
12631251
impl Step for Extended {
12641252
type Output = ();
12651253
const DEFAULT: bool = true;
1266-
const ONLY_BUILD_TARGETS: bool = true;
12671254
const ONLY_HOSTS: bool = true;
12681255

12691256
fn should_run(run: ShouldRun) -> ShouldRun {
@@ -1274,7 +1261,7 @@ impl Step for Extended {
12741261
fn make_run(run: RunConfig) {
12751262
run.builder.ensure(Extended {
12761263
stage: run.builder.top_stage,
1277-
host: run.host,
1264+
host: run.builder.build.build,
12781265
target: run.target,
12791266
});
12801267
}
@@ -1692,9 +1679,7 @@ pub struct HashSign;
16921679

16931680
impl Step for HashSign {
16941681
type Output = ();
1695-
const ONLY_BUILD_TARGETS: bool = true;
16961682
const ONLY_HOSTS: bool = true;
1697-
const ONLY_BUILD: bool = true;
16981683

16991684
fn should_run(run: ShouldRun) -> ShouldRun {
17001685
run.path("hash-and-sign")

src/bootstrap/install.rs

+30-6
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ macro_rules! install {
161161
impl Step for $name {
162162
type Output = ();
163163
const DEFAULT: bool = true;
164-
const ONLY_BUILD_TARGETS: bool = true;
165164
const ONLY_HOSTS: bool = $only_hosts;
166165
$(const $c: bool = true;)*
167166

@@ -174,7 +173,7 @@ macro_rules! install {
174173
run.builder.ensure($name {
175174
stage: run.builder.top_stage,
176175
target: run.target,
177-
host: run.host,
176+
host: run.builder.build.build,
178177
});
179178
}
180179

@@ -226,14 +225,39 @@ install!((self, builder, _config),
226225
});
227226
install_analysis(builder, self.stage, self.target);
228227
};
229-
Src, "src", Self::should_build(_config) , only_hosts: true, {
230-
builder.ensure(dist::Src);
231-
install_src(builder, self.stage);
232-
}, ONLY_BUILD;
233228
Rustc, "src/librustc", true, only_hosts: true, {
234229
builder.ensure(dist::Rustc {
235230
compiler: builder.compiler(self.stage, self.target),
236231
});
237232
install_rustc(builder, self.stage, self.target);
238233
};
239234
);
235+
236+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
237+
pub struct Src {
238+
pub stage: u32,
239+
}
240+
241+
impl Step for Src {
242+
type Output = ();
243+
const DEFAULT: bool = true;
244+
const ONLY_HOSTS: bool = true;
245+
246+
fn should_run(run: ShouldRun) -> ShouldRun {
247+
let config = &run.builder.config;
248+
let cond = config.extended &&
249+
config.tools.as_ref().map_or(true, |t| t.contains("src"));
250+
run.path("src").default_condition(cond)
251+
}
252+
253+
fn make_run(run: RunConfig) {
254+
run.builder.ensure(Src {
255+
stage: run.builder.top_stage,
256+
});
257+
}
258+
259+
fn run(self, builder: &Builder) {
260+
builder.ensure(dist::Src);
261+
install_src(builder, self.stage);
262+
}
263+
}

src/bootstrap/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
//! More documentation can be found in each respective module below, and you can
114114
//! also check out the `src/bootstrap/README.md` file for more information.
115115
116-
//#![deny(warnings)]
116+
#![deny(warnings)]
117117
#![feature(core_intrinsics)]
118118

119119
#[macro_use]

src/bootstrap/test.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -505,27 +505,23 @@ impl Step for RustdocJS {
505505
}
506506

507507
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
508-
pub struct Tidy {
509-
host: Interned<String>,
510-
}
508+
pub struct Tidy;
511509

512510
impl Step for Tidy {
513511
type Output = ();
514512
const DEFAULT: bool = true;
515513
const ONLY_HOSTS: bool = true;
516-
const ONLY_BUILD: bool = true;
517514

518-
/// Runs the `tidy` tool as compiled in `stage` by the `host` compiler.
515+
/// Runs the `tidy` tool.
519516
///
520517
/// This tool in `src/tools` checks up on various bits and pieces of style and
521518
/// otherwise just implements a few lint-like checks that are specific to the
522519
/// compiler itself.
523520
fn run(self, builder: &Builder) {
524521
let build = builder.build;
525-
let host = self.host;
526522

527523
let _folder = build.fold_output(|| "tidy");
528-
println!("tidy check ({})", host);
524+
println!("tidy check");
529525
let mut cmd = builder.tool_cmd(Tool::Tidy);
530526
cmd.arg(build.src.join("src"));
531527
cmd.arg(&build.initial_cargo);
@@ -543,9 +539,7 @@ impl Step for Tidy {
543539
}
544540

545541
fn make_run(run: RunConfig) {
546-
run.builder.ensure(Tidy {
547-
host: run.builder.build.build,
548-
});
542+
run.builder.ensure(Tidy);
549543
}
550544
}
551545

@@ -1610,7 +1604,6 @@ pub struct Distcheck;
16101604

16111605
impl Step for Distcheck {
16121606
type Output = ();
1613-
const ONLY_BUILD: bool = true;
16141607

16151608
fn should_run(run: ShouldRun) -> ShouldRun {
16161609
run.path("distcheck")
@@ -1676,7 +1669,6 @@ impl Step for Bootstrap {
16761669
type Output = ();
16771670
const DEFAULT: bool = true;
16781671
const ONLY_HOSTS: bool = true;
1679-
const ONLY_BUILD: bool = true;
16801672

16811673
/// Test the build system itself
16821674
fn run(self, builder: &Builder) {

0 commit comments

Comments
 (0)