Skip to content

Commit ffbb860

Browse files
author
Jonathan Turner
committed
Add workaround to detect correct compiler version
1 parent 43c090e commit ffbb860

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/bootstrap/bin/rustc.rs

+7-1
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)