Skip to content

Commit 2fbba5b

Browse files
committed
Auto merge of #43051 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 8 pull requests - Successful merges: #42227, #42836, #42975, #42994, #43041, #43042, #43043, #43045 - Failed merges:
2 parents de7f061 + 9cca462 commit 2fbba5b

28 files changed

+561
-433
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
.hg/
5252
.hgignore
5353
.idea
54+
*.iml
5455
__pycache__/
5556
*.py[cod]
5657
*$py.class

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ Read ["Installation"] from [The Book].
4040

4141
> ***Note:*** Install locations can be adjusted by copying the config file
4242
> from `./src/bootstrap/config.toml.example` to `./config.toml`, and
43-
> adjusting the `prefix` option under `[install]`. Various other options are
44-
> also supported, and are documented in the config file.
43+
> adjusting the `prefix` option under `[install]`. Various other options, such
44+
> as enabling debug information, are also supported, and are documented in
45+
> the config file.
4546

4647
When complete, `sudo ./x.py install` will place several programs into
4748
`/usr/local/bin`: `rustc`, the Rust compiler, and `rustdoc`, the

src/bootstrap/bin/rustc.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,11 @@ fn main() {
7575
Err(_) => 0,
7676
};
7777

78-
// Build scripts always use the snapshot compiler which is guaranteed to be
79-
// able to produce an executable, whereas intermediate compilers may not
80-
// have the standard library built yet and may not be able to produce an
81-
// executable. Otherwise we just use the standard compiler we're
82-
// bootstrapping with.
83-
//
84-
// Also note that cargo will detect the version of the compiler to trigger
85-
// a rebuild when the compiler changes. If this happens, we want to make
86-
// sure to use the actual compiler instead of the snapshot compiler becase
87-
// that's the one that's actually changing.
78+
// Use a different compiler for build scripts, since there may not yet be a
79+
// libstd for the real compiler to use. However, if Cargo is attempting to
80+
// determine the version of the compiler, the real compiler needs to be
81+
// used. Currently, these two states are differentiated based on whether
82+
// --target and -vV is/isn't passed.
8883
let (rustc, libdir) = if target.is_none() && version.is_none() {
8984
("RUSTC_SNAPSHOT", "RUSTC_SNAPSHOT_LIBDIR")
9085
} else {

src/bootstrap/cc.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@ use config::Target;
4242
pub fn find(build: &mut Build) {
4343
// For all targets we're going to need a C compiler for building some shims
4444
// and such as well as for being a linker for Rust code.
45-
for target in build.config.target.iter() {
45+
//
46+
// This includes targets that aren't necessarily passed on the commandline
47+
// (FIXME: Perhaps it shouldn't?)
48+
for target in &build.config.target {
4649
let mut cfg = gcc::Config::new();
4750
cfg.cargo_metadata(false).opt_level(0).debug(false)
48-
.target(target).host(&build.config.build);
51+
.target(target).host(&build.build);
4952

5053
let config = build.config.target_config.get(target);
5154
if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
@@ -64,10 +67,13 @@ pub fn find(build: &mut Build) {
6467
}
6568

6669
// For all host triples we need to find a C++ compiler as well
67-
for host in build.config.host.iter() {
70+
//
71+
// This includes hosts that aren't necessarily passed on the commandline
72+
// (FIXME: Perhaps it shouldn't?)
73+
for host in &build.config.host {
6874
let mut cfg = gcc::Config::new();
6975
cfg.cargo_metadata(false).opt_level(0).debug(false).cpp(true)
70-
.target(host).host(&build.config.build);
76+
.target(host).host(&build.build);
7177
let config = build.config.target_config.get(host);
7278
if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
7379
cfg.compiler(cxx);

src/bootstrap/channel.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ use build_helper::output;
2323
use Build;
2424

2525
// The version number
26-
pub const CFG_RELEASE_NUM: &'static str = "1.20.0";
26+
pub const CFG_RELEASE_NUM: &str = "1.20.0";
2727

2828
// An optional number to put after the label, e.g. '.2' -> '-beta.2'
2929
// Be sure to make this starts with a dot to conform to semver pre-release
3030
// versions (section 9)
31-
pub const CFG_PRERELEASE_VERSION: &'static str = ".1";
31+
pub const CFG_PRERELEASE_VERSION: &str = ".1";
3232

3333
pub struct GitInfo {
3434
inner: Option<Info>,
@@ -99,6 +99,10 @@ impl GitInfo {
9999
version.push_str(&inner.commit_date);
100100
version.push_str(")");
101101
}
102-
return version
102+
version
103+
}
104+
105+
pub fn is_git(&self) -> bool {
106+
self.inner.is_some()
103107
}
104108
}

src/bootstrap/check.rs

+36-41
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,22 @@
1313
//! This file implements the various regression test suites that we execute on
1414
//! our CI.
1515
16-
extern crate build_helper;
17-
1816
use std::collections::HashSet;
1917
use std::env;
18+
use std::iter;
2019
use std::fmt;
2120
use std::fs::{self, File};
2221
use std::path::{PathBuf, Path};
2322
use std::process::Command;
2423
use std::io::Read;
2524

26-
use build_helper::output;
25+
use build_helper::{self, output};
2726

2827
use {Build, Compiler, Mode};
2928
use dist;
3029
use util::{self, dylib_path, dylib_path_var, exe};
3130

32-
const ADB_TEST_DIR: &'static str = "/data/tmp/work";
31+
const ADB_TEST_DIR: &str = "/data/tmp/work";
3332

3433
/// The two modes of the test runner; tests or benchmarks.
3534
#[derive(Copy, Clone)]
@@ -60,7 +59,7 @@ impl fmt::Display for TestKind {
6059
}
6160

6261
fn try_run(build: &Build, cmd: &mut Command) {
63-
if build.flags.cmd.no_fail_fast() {
62+
if !build.fail_fast {
6463
if !build.try_run(cmd) {
6564
let failures = build.delayed_failures.get();
6665
build.delayed_failures.set(failures + 1);
@@ -71,7 +70,7 @@ fn try_run(build: &Build, cmd: &mut Command) {
7170
}
7271

7372
fn try_run_quiet(build: &Build, cmd: &mut Command) {
74-
if build.flags.cmd.no_fail_fast() {
73+
if !build.fail_fast {
7574
if !build.try_run_quiet(cmd) {
7675
let failures = build.delayed_failures.get();
7776
build.delayed_failures.set(failures + 1);
@@ -99,7 +98,7 @@ pub fn linkcheck(build: &Build, host: &str) {
9998
/// This tool in `src/tools` will check out a few Rust projects and run `cargo
10099
/// test` to ensure that we don't regress the test suites there.
101100
pub fn cargotest(build: &Build, stage: u32, host: &str) {
102-
let ref compiler = Compiler::new(stage, host);
101+
let compiler = Compiler::new(stage, host);
103102

104103
// Note that this is a short, cryptic, and not scoped directory name. This
105104
// is currently to minimize the length of path on Windows where we otherwise
@@ -109,11 +108,11 @@ pub fn cargotest(build: &Build, stage: u32, host: &str) {
109108

110109
let _time = util::timeit();
111110
let mut cmd = Command::new(build.tool(&Compiler::new(0, host), "cargotest"));
112-
build.prepare_tool_cmd(compiler, &mut cmd);
113-
try_run(build, cmd.arg(&build.cargo)
111+
build.prepare_tool_cmd(&compiler, &mut cmd);
112+
try_run(build, cmd.arg(&build.initial_cargo)
114113
.arg(&out_dir)
115-
.env("RUSTC", build.compiler_path(compiler))
116-
.env("RUSTDOC", build.rustdoc(compiler)));
114+
.env("RUSTC", build.compiler_path(&compiler))
115+
.env("RUSTDOC", build.rustdoc(&compiler)));
117116
}
118117

119118
/// Runs `cargo test` for `cargo` packaged with Rust.
@@ -124,13 +123,12 @@ pub fn cargo(build: &Build, stage: u32, host: &str) {
124123
// and not RUSTC because the Cargo test suite has tests that will
125124
// fail if rustc is not spelled `rustc`.
126125
let path = build.sysroot(compiler).join("bin");
127-
let old_path = ::std::env::var("PATH").expect("");
128-
let sep = if cfg!(windows) { ";" } else {":" };
129-
let ref newpath = format!("{}{}{}", path.display(), sep, old_path);
126+
let old_path = env::var_os("PATH").unwrap_or_default();
127+
let newpath = env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("");
130128

131129
let mut cargo = build.cargo(compiler, Mode::Tool, host, "test");
132130
cargo.arg("--manifest-path").arg(build.src.join("src/tools/cargo/Cargo.toml"));
133-
if build.flags.cmd.no_fail_fast() {
131+
if !build.fail_fast {
134132
cargo.arg("--no-fail-fast");
135133
}
136134

@@ -198,9 +196,9 @@ pub fn compiletest(build: &Build,
198196
cmd.arg("--mode").arg(mode);
199197
cmd.arg("--target").arg(target);
200198
cmd.arg("--host").arg(compiler.host);
201-
cmd.arg("--llvm-filecheck").arg(build.llvm_filecheck(&build.config.build));
199+
cmd.arg("--llvm-filecheck").arg(build.llvm_filecheck(&build.build));
202200

203-
if let Some(nodejs) = build.config.nodejs.as_ref() {
201+
if let Some(ref nodejs) = build.config.nodejs {
204202
cmd.arg("--nodejs").arg(nodejs);
205203
}
206204

@@ -224,7 +222,7 @@ pub fn compiletest(build: &Build,
224222

225223
cmd.arg("--docck-python").arg(build.python());
226224

227-
if build.config.build.ends_with("apple-darwin") {
225+
if build.build.ends_with("apple-darwin") {
228226
// Force /usr/bin/python on macOS for LLDB tests because we're loading the
229227
// LLDB plugin's compiled module which only works with the system python
230228
// (namely not Homebrew-installed python)
@@ -251,7 +249,7 @@ pub fn compiletest(build: &Build,
251249

252250
cmd.args(&build.flags.cmd.test_args());
253251

254-
if build.config.verbose() || build.flags.verbose() {
252+
if build.is_verbose() {
255253
cmd.arg("--verbose");
256254
}
257255

@@ -279,7 +277,7 @@ pub fn compiletest(build: &Build,
279277

280278
if build.remote_tested(target) {
281279
cmd.arg("--remote-test-client")
282-
.arg(build.tool(&Compiler::new(0, &build.config.build),
280+
.arg(build.tool(&Compiler::new(0, &build.build),
283281
"remote-test-client"));
284282
}
285283

@@ -368,7 +366,7 @@ pub fn error_index(build: &Build, compiler: &Compiler) {
368366
"error_index_generator")
369367
.arg("markdown")
370368
.arg(&output)
371-
.env("CFG_BUILD", &build.config.build));
369+
.env("CFG_BUILD", &build.build));
372370

373371
markdown_test(build, compiler, &output);
374372
}
@@ -450,7 +448,7 @@ pub fn krate(build: &Build,
450448
cargo.arg("--manifest-path")
451449
.arg(build.src.join(path).join("Cargo.toml"))
452450
.arg("--features").arg(features);
453-
if test_kind.subcommand() == "test" && build.flags.cmd.no_fail_fast() {
451+
if test_kind.subcommand() == "test" && !build.fail_fast {
454452
cargo.arg("--no-fail-fast");
455453
}
456454

@@ -520,16 +518,14 @@ fn krate_emscripten(build: &Build,
520518
compiler: &Compiler,
521519
target: &str,
522520
mode: Mode) {
523-
let mut tests = Vec::new();
524521
let out_dir = build.cargo_out(compiler, mode, target);
525-
find_tests(&out_dir.join("deps"), target, &mut tests);
522+
let tests = find_tests(&out_dir.join("deps"), target);
526523

524+
let nodejs = build.config.nodejs.as_ref().expect("nodejs not configured");
527525
for test in tests {
528-
let test_file_name = test.to_string_lossy().into_owned();
529-
println!("running {}", test_file_name);
530-
let nodejs = build.config.nodejs.as_ref().expect("nodejs not configured");
526+
println!("running {}", test.display());
531527
let mut cmd = Command::new(nodejs);
532-
cmd.arg(&test_file_name);
528+
cmd.arg(&test);
533529
if build.config.quiet_tests {
534530
cmd.arg("--quiet");
535531
}
@@ -541,11 +537,10 @@ fn krate_remote(build: &Build,
541537
compiler: &Compiler,
542538
target: &str,
543539
mode: Mode) {
544-
let mut tests = Vec::new();
545540
let out_dir = build.cargo_out(compiler, mode, target);
546-
find_tests(&out_dir.join("deps"), target, &mut tests);
541+
let tests = find_tests(&out_dir.join("deps"), target);
547542

548-
let tool = build.tool(&Compiler::new(0, &build.config.build),
543+
let tool = build.tool(&Compiler::new(0, &build.build),
549544
"remote-test-client");
550545
for test in tests {
551546
let mut cmd = Command::new(&tool);
@@ -559,9 +554,8 @@ fn krate_remote(build: &Build,
559554
}
560555
}
561556

562-
fn find_tests(dir: &Path,
563-
target: &str,
564-
dst: &mut Vec<PathBuf>) {
557+
fn find_tests(dir: &Path, target: &str) -> Vec<PathBuf> {
558+
let mut dst = Vec::new();
565559
for e in t!(dir.read_dir()).map(|e| t!(e)) {
566560
let file_type = t!(e.file_type());
567561
if !file_type.is_file() {
@@ -576,6 +570,7 @@ fn find_tests(dir: &Path,
576570
dst.push(e.path());
577571
}
578572
}
573+
dst
579574
}
580575

581576
pub fn remote_copy_libs(build: &Build, compiler: &Compiler, target: &str) {
@@ -590,7 +585,7 @@ pub fn remote_copy_libs(build: &Build, compiler: &Compiler, target: &str) {
590585
.join(exe("remote-test-server", target));
591586

592587
// Spawn the emulator and wait for it to come online
593-
let tool = build.tool(&Compiler::new(0, &build.config.build),
588+
let tool = build.tool(&Compiler::new(0, &build.build),
594589
"remote-test-client");
595590
let mut cmd = Command::new(&tool);
596591
cmd.arg("spawn-emulator")
@@ -616,7 +611,7 @@ pub fn remote_copy_libs(build: &Build, compiler: &Compiler, target: &str) {
616611

617612
/// Run "distcheck", a 'make check' from a tarball
618613
pub fn distcheck(build: &Build) {
619-
if build.config.build != "x86_64-unknown-linux-gnu" {
614+
if build.build != "x86_64-unknown-linux-gnu" {
620615
return
621616
}
622617
if !build.config.host.iter().any(|s| s == "x86_64-unknown-linux-gnu") {
@@ -641,7 +636,7 @@ pub fn distcheck(build: &Build) {
641636
.args(&build.config.configure_args)
642637
.arg("--enable-vendor")
643638
.current_dir(&dir));
644-
build.run(Command::new(build_helper::make(&build.config.build))
639+
build.run(Command::new(build_helper::make(&build.build))
645640
.arg("check")
646641
.current_dir(&dir));
647642

@@ -659,7 +654,7 @@ pub fn distcheck(build: &Build) {
659654
build.run(&mut cmd);
660655

661656
let toml = dir.join("rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml");
662-
build.run(Command::new(&build.cargo)
657+
build.run(Command::new(&build.initial_cargo)
663658
.arg("generate-lockfile")
664659
.arg("--manifest-path")
665660
.arg(&toml)
@@ -668,13 +663,13 @@ pub fn distcheck(build: &Build) {
668663

669664
/// Test the build system itself
670665
pub fn bootstrap(build: &Build) {
671-
let mut cmd = Command::new(&build.cargo);
666+
let mut cmd = Command::new(&build.initial_cargo);
672667
cmd.arg("test")
673668
.current_dir(build.src.join("src/bootstrap"))
674669
.env("CARGO_TARGET_DIR", build.out.join("bootstrap"))
675670
.env("RUSTC_BOOTSTRAP", "1")
676-
.env("RUSTC", &build.rustc);
677-
if build.flags.cmd.no_fail_fast() {
671+
.env("RUSTC", &build.initial_rustc);
672+
if !build.fail_fast {
678673
cmd.arg("--no-fail-fast");
679674
}
680675
cmd.arg("--").args(&build.flags.cmd.test_args());

0 commit comments

Comments
 (0)