Skip to content

Commit 4e62503

Browse files
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.
1 parent 88f19c6 commit 4e62503

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

compiler/rustc_session/src/config.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1885,7 +1885,12 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
18851885

18861886
check_thread_count(&debugging_opts, error_format);
18871887

1888-
let incremental = cg.incremental.as_ref().map(PathBuf::from);
1888+
let incremental =
1889+
if std::env::var_os("RUSTC_FORCE_INCREMENTAL").map(|v| v == "1").unwrap_or(false) {
1890+
cg.incremental.as_ref().map(PathBuf::from)
1891+
} else {
1892+
None
1893+
};
18891894

18901895
if debugging_opts.profile && incremental.is_some() {
18911896
early_error(

src/doc/rustc/src/codegen-options/index.md

+3
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ to save information after compiling a crate to be reused when recompiling the
161161
crate, improving re-compile times. This takes a path to a directory where
162162
incremental files will be stored.
163163

164+
Note that this option currently does not take effect unless
165+
`RUSTC_FORCE_INCREMENTAL=1` in the environment.
166+
164167
## inline-threshold
165168

166169
This option lets you set the default threshold for inlining a function. It

src/tools/compiletest/src/runtest.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,15 @@ pub fn run(config: Config, testpaths: &TestPaths, revision: Option<&str>) {
229229
print!("\n\n");
230230
}
231231
debug!("running {:?}", testpaths.file.display());
232-
let props = TestProps::from_file(&testpaths.file, revision, &config);
232+
let mut props = TestProps::from_file(&testpaths.file, revision, &config);
233+
234+
// Currently, incremental is soft disabled unless this environment
235+
// variable is set. A bunch of our tests assume it's enabled, though - so
236+
// just enable it for our tests.
237+
//
238+
// This is deemed preferable to ignoring those tests; we still want to test
239+
// incremental somewhat, as users can opt in to it.
240+
props.rustc_env.push((String::from("RUSTC_FORCE_INCREMENTAL"), String::from("1")));
233241

234242
let cx = TestCx { config: &config, props: &props, testpaths, revision };
235243
create_dir_all(&cx.output_base_dir()).unwrap();
@@ -240,7 +248,11 @@ pub fn run(config: Config, testpaths: &TestPaths, revision: Option<&str>) {
240248
assert!(!props.revisions.is_empty(), "Incremental tests require revisions.");
241249
cx.init_incremental_test();
242250
for revision in &props.revisions {
243-
let revision_props = TestProps::from_file(&testpaths.file, Some(revision), &config);
251+
let mut revision_props = TestProps::from_file(&testpaths.file, Some(revision), &config);
252+
// See above - need to enable it explicitly for now.
253+
revision_props
254+
.rustc_env
255+
.push((String::from("RUSTC_FORCE_INCREMENTAL"), String::from("1")));
244256
let rev_cx = TestCx {
245257
config: &config,
246258
props: &revision_props,

0 commit comments

Comments
 (0)