Skip to content

Commit 72f2f19

Browse files
authored
Merge branch 'master' into stabilise/termination-test
2 parents bc74162 + 6232478 commit 72f2f19

File tree

118 files changed

+2164
-556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+2164
-556
lines changed

config.toml.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@
279279
# Whether or not `panic!`s generate backtraces (RUST_BACKTRACE)
280280
#backtrace = true
281281

282+
# Whether to always use incremental compilation when building rustc
283+
#incremental = false
284+
282285
# Build rustc with experimental parallelization
283286
#experimental-parallel-queries = false
284287

src/bootstrap/bin/rustc.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,15 @@ fn main() {
268268
if let Ok(host_linker) = env::var("RUSTC_HOST_LINKER") {
269269
cmd.arg(format!("-Clinker={}", host_linker));
270270
}
271+
272+
if let Ok(s) = env::var("RUSTC_HOST_CRT_STATIC") {
273+
if s == "true" {
274+
cmd.arg("-C").arg("target-feature=+crt-static");
275+
}
276+
if s == "false" {
277+
cmd.arg("-C").arg("target-feature=-crt-static");
278+
}
279+
}
271280
}
272281

273282
if env::var_os("RUSTC_PARALLEL_QUERIES").is_some() {

src/bootstrap/bootstrap.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ def bin_root(self):
489489
"""
490490
return os.path.join(self.build_dir, self.build, "stage0")
491491

492-
def get_toml(self, key):
492+
def get_toml(self, key, section=None):
493493
"""Returns the value of the given key in config.toml, otherwise returns None
494494
495495
>>> rb = RustBuild()
@@ -501,12 +501,29 @@ def get_toml(self, key):
501501
502502
>>> rb.get_toml("key3") is None
503503
True
504+
505+
Optionally also matches the section the key appears in
506+
507+
>>> rb.config_toml = '[a]\\nkey = "value1"\\n[b]\\nkey = "value2"'
508+
>>> rb.get_toml('key', 'a')
509+
'value1'
510+
>>> rb.get_toml('key', 'b')
511+
'value2'
512+
>>> rb.get_toml('key', 'c') is None
513+
True
504514
"""
515+
516+
cur_section = None
505517
for line in self.config_toml.splitlines():
518+
section_match = re.match(r'^\s*\[(.*)\]\s*$', line)
519+
if section_match is not None:
520+
cur_section = section_match.group(1)
521+
506522
match = re.match(r'^{}\s*=(.*)$'.format(key), line)
507523
if match is not None:
508524
value = match.group(1)
509-
return self.get_string(value) or value.strip()
525+
if section is None or section == cur_section:
526+
return self.get_string(value) or value.strip()
510527
return None
511528

512529
def cargo(self):
@@ -589,7 +606,17 @@ def build_bootstrap(self):
589606
env["LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib") + \
590607
(os.pathsep + env["LIBRARY_PATH"]) \
591608
if "LIBRARY_PATH" in env else ""
592-
env["RUSTFLAGS"] = "-Cdebuginfo=2"
609+
env["RUSTFLAGS"] = "-Cdebuginfo=2 "
610+
611+
build_section = "target.{}".format(self.build_triple())
612+
target_features = []
613+
if self.get_toml("crt-static", build_section) == "true":
614+
target_features += ["+crt-static"]
615+
elif self.get_toml("crt-static", build_section) == "false":
616+
target_features += ["-crt-static"]
617+
if target_features:
618+
env["RUSTFLAGS"] += "-C target-feature=" + (",".join(target_features)) + " "
619+
593620
env["PATH"] = os.path.join(self.bin_root(), "bin") + \
594621
os.pathsep + env["PATH"]
595622
if not os.path.isfile(self.cargo()):

src/bootstrap/builder.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -698,9 +698,14 @@ impl<'a> Builder<'a> {
698698
let out_dir = self.stage_out(compiler, mode);
699699
cargo
700700
.env("CARGO_TARGET_DIR", out_dir)
701-
.arg(cmd)
702-
.arg("--target")
703-
.arg(target);
701+
.arg(cmd);
702+
703+
if cmd != "install" {
704+
cargo.arg("--target")
705+
.arg(target);
706+
} else {
707+
assert_eq!(target, compiler.host);
708+
}
704709

705710
// Set a flag for `check` so that certain build scripts can do less work
706711
// (e.g. not building/requiring LLVM).
@@ -801,7 +806,7 @@ impl<'a> Builder<'a> {
801806
);
802807
}
803808

804-
if mode == Mode::Tool {
809+
if mode.is_tool() {
805810
// Tools like cargo and rls don't get debuginfo by default right now, but this can be
806811
// enabled in the config. Adding debuginfo makes them several times larger.
807812
if self.config.rust_debuginfo_tools {
@@ -842,6 +847,10 @@ impl<'a> Builder<'a> {
842847
cargo.env("RUSTC_CRT_STATIC", x.to_string());
843848
}
844849

850+
if let Some(x) = self.crt_static(compiler.host) {
851+
cargo.env("RUSTC_HOST_CRT_STATIC", x.to_string());
852+
}
853+
845854
// Enable usage of unstable features
846855
cargo.env("RUSTC_BOOTSTRAP", "1");
847856
self.add_rust_test_threads(&mut cargo);
@@ -862,7 +871,7 @@ impl<'a> Builder<'a> {
862871
//
863872
// If LLVM support is disabled we need to use the snapshot compiler to compile
864873
// build scripts, as the new compiler doesn't support executables.
865-
if mode == Mode::Libstd || !self.config.llvm_enabled {
874+
if mode == Mode::Std || !self.config.llvm_enabled {
866875
cargo
867876
.env("RUSTC_SNAPSHOT", &self.initial_rustc)
868877
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir());
@@ -894,7 +903,7 @@ impl<'a> Builder<'a> {
894903
cargo.env("RUSTC_VERBOSE", format!("{}", self.verbosity));
895904

896905
// in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful.
897-
if self.config.deny_warnings && !(mode == Mode::Libstd && stage == 0) {
906+
if self.config.deny_warnings && !(mode == Mode::Std && stage == 0) {
898907
cargo.env("RUSTC_DENY_WARNINGS", "1");
899908
}
900909

@@ -954,7 +963,7 @@ impl<'a> Builder<'a> {
954963
}
955964

956965
if cmd == "build"
957-
&& mode == Mode::Libstd
966+
&& mode == Mode::Std
958967
&& self.config.extended
959968
&& compiler.is_final_stage(self)
960969
{
@@ -1003,7 +1012,7 @@ impl<'a> Builder<'a> {
10031012
// be resolved because MinGW has the import library. The downside is we
10041013
// don't get newer functions from Windows, but we don't use any of them
10051014
// anyway.
1006-
if mode != Mode::Tool {
1015+
if !mode.is_tool() {
10071016
cargo.env("WINAPI_NO_BUNDLED_LIBRARIES", "1");
10081017
}
10091018

@@ -1018,8 +1027,8 @@ impl<'a> Builder<'a> {
10181027
}
10191028

10201029
if self.config.rust_optimize {
1021-
// FIXME: cargo bench does not accept `--release`
1022-
if cmd != "bench" {
1030+
// FIXME: cargo bench/install do not accept `--release`
1031+
if cmd != "bench" && cmd != "install" {
10231032
cargo.arg("--release");
10241033
}
10251034
}
@@ -1742,7 +1751,7 @@ mod __test {
17421751
&[test::Crate {
17431752
compiler: Compiler { host, stage: 0 },
17441753
target: host,
1745-
mode: Mode::Libstd,
1754+
mode: Mode::Std,
17461755
test_kind: test::TestKind::Test,
17471756
krate: INTERNER.intern_str("std"),
17481757
},]

src/bootstrap/check.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ impl Step for Std {
4040
let target = self.target;
4141
let compiler = builder.compiler(0, builder.config.build);
4242

43-
let out_dir = builder.stage_out(compiler, Mode::Libstd);
43+
let out_dir = builder.stage_out(compiler, Mode::Std);
4444
builder.clear_if_dirty(&out_dir, &builder.rustc(compiler));
4545

46-
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "check");
46+
let mut cargo = builder.cargo(compiler, Mode::Std, target, "check");
4747
std_cargo(builder, &compiler, target, &mut cargo);
4848

4949
let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage));
@@ -87,11 +87,11 @@ impl Step for Rustc {
8787
let compiler = builder.compiler(0, builder.config.build);
8888
let target = self.target;
8989

90-
let stage_out = builder.stage_out(compiler, Mode::Librustc);
90+
let stage_out = builder.stage_out(compiler, Mode::Rustc);
9191
builder.clear_if_dirty(&stage_out, &libstd_stamp(builder, compiler, target));
9292
builder.clear_if_dirty(&stage_out, &libtest_stamp(builder, compiler, target));
9393

94-
let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "check");
94+
let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "check");
9595
rustc_cargo(builder, &mut cargo);
9696

9797
let _folder = builder.fold_output(|| format!("stage{}-rustc", compiler.stage));
@@ -137,7 +137,7 @@ impl Step for CodegenBackend {
137137
let target = self.target;
138138
let backend = self.backend;
139139

140-
let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "check");
140+
let mut cargo = builder.cargo(compiler, Mode::Codegen, target, "check");
141141
let features = builder.rustc_features().to_string();
142142
cargo.arg("--manifest-path").arg(builder.src.join("src/librustc_codegen_llvm/Cargo.toml"));
143143
rustc_cargo_env(builder, &mut cargo);
@@ -175,10 +175,10 @@ impl Step for Test {
175175
let compiler = builder.compiler(0, builder.config.build);
176176
let target = self.target;
177177

178-
let out_dir = builder.stage_out(compiler, Mode::Libtest);
178+
let out_dir = builder.stage_out(compiler, Mode::Test);
179179
builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target));
180180

181-
let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "check");
181+
let mut cargo = builder.cargo(compiler, Mode::Test, target, "check");
182182
test_cargo(builder, &compiler, target, &mut cargo);
183183

184184
let _folder = builder.fold_output(|| format!("stage{}-test", compiler.stage));
@@ -219,6 +219,7 @@ impl Step for Rustdoc {
219219

220220
let mut cargo = prepare_tool_cargo(builder,
221221
compiler,
222+
Mode::ToolRustc,
222223
target,
223224
"check",
224225
"src/tools/rustdoc");
@@ -236,27 +237,27 @@ impl Step for Rustdoc {
236237
builder.ensure(tool::CleanTools {
237238
compiler,
238239
target,
239-
mode: Mode::Tool,
240+
cause: Mode::Rustc,
240241
});
241242
}
242243
}
243244

244245
/// Cargo's output path for the standard library in a given stage, compiled
245246
/// by a particular compiler for the specified target.
246247
pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
247-
builder.cargo_out(compiler, Mode::Libstd, target).join(".libstd-check.stamp")
248+
builder.cargo_out(compiler, Mode::Std, target).join(".libstd-check.stamp")
248249
}
249250

250251
/// Cargo's output path for libtest in a given stage, compiled by a particular
251252
/// compiler for the specified target.
252253
pub fn libtest_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
253-
builder.cargo_out(compiler, Mode::Libtest, target).join(".libtest-check.stamp")
254+
builder.cargo_out(compiler, Mode::Test, target).join(".libtest-check.stamp")
254255
}
255256

256257
/// Cargo's output path for librustc in a given stage, compiled by a particular
257258
/// compiler for the specified target.
258259
pub fn librustc_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
259-
builder.cargo_out(compiler, Mode::Librustc, target).join(".librustc-check.stamp")
260+
builder.cargo_out(compiler, Mode::Rustc, target).join(".librustc-check.stamp")
260261
}
261262

262263
/// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular
@@ -265,12 +266,12 @@ fn codegen_backend_stamp(builder: &Builder,
265266
compiler: Compiler,
266267
target: Interned<String>,
267268
backend: Interned<String>) -> PathBuf {
268-
builder.cargo_out(compiler, Mode::Librustc, target)
269+
builder.cargo_out(compiler, Mode::Codegen, target)
269270
.join(format!(".librustc_codegen_llvm-{}-check.stamp", backend))
270271
}
271272

272273
/// Cargo's output path for rustdoc in a given stage, compiled by a particular
273274
/// compiler for the specified target.
274275
pub fn rustdoc_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
275-
builder.cargo_out(compiler, Mode::Tool, target).join(".rustdoc-check.stamp")
276+
builder.cargo_out(compiler, Mode::ToolRustc, target).join(".rustdoc-check.stamp")
276277
}

0 commit comments

Comments
 (0)