From 4e625035982f5dc524df6d6e7ff30623ec704297 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 8 May 2021 20:30:54 -0400 Subject: [PATCH 1/4] Soft disable incremental This disables incremental (i.e., -Cincremental) taking effect unless an environment variable, RUSTC_FORCE_INCREMENTAL, is set to 1 in the environment of the running rustc. Currently incremental causes errors for many users, and we do not have an expectation of being able to quickly fix these errors in a backportable way - so, for now, disable incremental entirely. The user can still opt-in, but this way the majority of users merely get slower builds, not broken builds. --- compiler/rustc_session/src/config.rs | 7 ++++++- src/doc/rustc/src/codegen-options/index.md | 3 +++ src/tools/compiletest/src/runtest.rs | 16 ++++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 75078a1231163..85448b7fe72d2 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1885,7 +1885,12 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { check_thread_count(&debugging_opts, error_format); - let incremental = cg.incremental.as_ref().map(PathBuf::from); + let incremental = + if std::env::var_os("RUSTC_FORCE_INCREMENTAL").map(|v| v == "1").unwrap_or(false) { + cg.incremental.as_ref().map(PathBuf::from) + } else { + None + }; if debugging_opts.profile && incremental.is_some() { early_error( diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md index 1883346430be0..4eb2aa9917560 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -161,6 +161,9 @@ to save information after compiling a crate to be reused when recompiling the crate, improving re-compile times. This takes a path to a directory where incremental files will be stored. +Note that this option currently does not take effect unless +`RUSTC_FORCE_INCREMENTAL=1` in the environment. + ## inline-threshold This option lets you set the default threshold for inlining a function. It diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 7aa3d4ab09e41..6aebf4b6044ea 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -229,7 +229,15 @@ pub fn run(config: Config, testpaths: &TestPaths, revision: Option<&str>) { print!("\n\n"); } debug!("running {:?}", testpaths.file.display()); - let props = TestProps::from_file(&testpaths.file, revision, &config); + let mut props = TestProps::from_file(&testpaths.file, revision, &config); + + // Currently, incremental is soft disabled unless this environment + // variable is set. A bunch of our tests assume it's enabled, though - so + // just enable it for our tests. + // + // This is deemed preferable to ignoring those tests; we still want to test + // incremental somewhat, as users can opt in to it. + props.rustc_env.push((String::from("RUSTC_FORCE_INCREMENTAL"), String::from("1"))); let cx = TestCx { config: &config, props: &props, testpaths, revision }; create_dir_all(&cx.output_base_dir()).unwrap(); @@ -240,7 +248,11 @@ pub fn run(config: Config, testpaths: &TestPaths, revision: Option<&str>) { assert!(!props.revisions.is_empty(), "Incremental tests require revisions."); cx.init_incremental_test(); for revision in &props.revisions { - let revision_props = TestProps::from_file(&testpaths.file, Some(revision), &config); + let mut revision_props = TestProps::from_file(&testpaths.file, Some(revision), &config); + // See above - need to enable it explicitly for now. + revision_props + .rustc_env + .push((String::from("RUSTC_FORCE_INCREMENTAL"), String::from("1"))); let rev_cx = TestCx { config: &config, props: &revision_props, From 6d698cecf5f13d3809a6676ce920787ea1716558 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 8 May 2021 20:38:23 -0400 Subject: [PATCH 2/4] Bump to 1.52.1 This bumps the stable version number and adds corresponding release notes. --- RELEASES.md | 21 +++++++++++++++++++++ src/version | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 1e94fb8e42f04..02778204a406c 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,24 @@ +Version 1.52.1 (2021-05-10) +============================ + +This release disables incremental compilation, unless the user has explicitly +opted in via the newly added RUSTC_FORCE_INCREMENTAL=1 environment variable. + +This is due to the widespread, and frequently occuring, breakage encountered by +Rust users due to newly enabled incremental verification in 1.52.0. Notably, +Rust users **should** upgrade to 1.52.0 or 1.52.1: the bugs that are detected by +newly added incremental verification are still present in past stable versions, +and are not yet fixed on any channel. These bugs can lead to miscompilation of +Rust binaries. + +These problems only affect incremental builds, so release builds with Cargo +should not be affected unless the user has explicitly opted into incremental. +Debug and check builds are affected. + +See [84970] for more details. + +[84970]: https://github.com/rust-lang/rust/issues/84970 + Version 1.52.0 (2021-05-06) ============================ diff --git a/src/version b/src/version index a63cb35e6f0b4..154cb93b2cc63 100644 --- a/src/version +++ b/src/version @@ -1 +1 @@ -1.52.0 +1.52.1 From 572d14db8c218268ba23537db99476c68f68df07 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Thu, 6 May 2021 13:44:17 -0400 Subject: [PATCH 3/4] Show nicer error when an 'unstable fingerprints' error occurs --- compiler/rustc_query_system/src/query/plumbing.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 77267489a7526..5a825e6775b8e 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -590,7 +590,18 @@ fn incremental_verify_ich( let old_hash = tcx.dep_graph().fingerprint_of(dep_node_index); - assert!(new_hash == old_hash, "found unstable fingerprints for {:?}: {:?}", dep_node, result); + if new_hash != old_hash { + let run_cmd = if let Some(crate_name) = &tcx.sess().opts.crate_name { + format!("`cargo clean -p {}` or `cargo clean`", crate_name) + } else { + "`cargo clean`".to_string() + }; + tcx.sess().struct_err(&format!("internal compiler error: encountered incremental compilation error with {:?}", dep_node)) + .help(&format!("This is a known issue with the compiler. Run {} to allow your project to compile", run_cmd)) + .note(&format!("Please follow the instructions below to create a bug report with the provided information")) + .emit(); + panic!("Found unstable fingerprints for {:?}: {:?}", dep_node, result); + } } fn force_query_with_job( From a0190b5fdd54a3183739982d722472491313c69c Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 8 May 2021 20:43:23 -0400 Subject: [PATCH 4/4] Add link to issue --- compiler/rustc_query_system/src/query/plumbing.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 5a825e6775b8e..da372091608a0 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -599,6 +599,7 @@ fn incremental_verify_ich( tcx.sess().struct_err(&format!("internal compiler error: encountered incremental compilation error with {:?}", dep_node)) .help(&format!("This is a known issue with the compiler. Run {} to allow your project to compile", run_cmd)) .note(&format!("Please follow the instructions below to create a bug report with the provided information")) + .note(&format!("See for more information.")) .emit(); panic!("Found unstable fingerprints for {:?}: {:?}", dep_node, result); }