Skip to content

Commit

Permalink
Rollup merge of rust-lang#35811 - jonathandturner:fix_rustbuild_versi…
Browse files Browse the repository at this point in the history
…on_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
  • Loading branch information
Jonathan Turner committed Aug 19, 2016
2 parents f21dcbe + ffbb860 commit c63ed55
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ fn main() {
// is passed (a bit janky...)
let target = args.windows(2).find(|w| &*w[0] == "--target")
.and_then(|w| w[1].to_str());
let version = args.iter().find(|w| &**w == "-vV");

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

0 comments on commit c63ed55

Please sign in to comment.