Skip to content

Commit c63ed55

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#35811 - jonathandturner:fix_rustbuild_version_test, r=alexcrichton
Add workaround to detect correct compiler version This adds a workaround which fixes a rustbuild issue where the wrong compiler is checked for the version number. The bug would arise if you build the system correctly then changed to any other version (eg doing a `git pull`). After changing to the new version, building would fail and complain that crates were built with the wrong compiler. There are actually two compilers at play, the bootstrapping compiler (called the "snapshot" compiler) and the actual compiler being built (the "real" compiler). In the case of this issue, the wrong compiler was being checked for version mismatch. r? @alexcrichton
2 parents f21dcbe + ffbb860 commit c63ed55

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/bootstrap/bin/rustc.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,19 @@ fn main() {
3838
// is passed (a bit janky...)
3939
let target = args.windows(2).find(|w| &*w[0] == "--target")
4040
.and_then(|w| w[1].to_str());
41+
let version = args.iter().find(|w| &**w == "-vV");
4142

4243
// Build scripts always use the snapshot compiler which is guaranteed to be
4344
// able to produce an executable, whereas intermediate compilers may not
4445
// have the standard library built yet and may not be able to produce an
4546
// executable. Otherwise we just use the standard compiler we're
4647
// bootstrapping with.
47-
let (rustc, libdir) = if target.is_none() {
48+
//
49+
// Also note that cargo will detect the version of the compiler to trigger
50+
// a rebuild when the compiler changes. If this happens, we want to make
51+
// sure to use the actual compiler instead of the snapshot compiler becase
52+
// that's the one that's actually changing.
53+
let (rustc, libdir) = if target.is_none() && version.is_none() {
4854
("RUSTC_SNAPSHOT", "RUSTC_SNAPSHOT_LIBDIR")
4955
} else {
5056
("RUSTC_REAL", "RUSTC_LIBDIR")

0 commit comments

Comments
 (0)