Skip to content

Commit 6af5faf

Browse files
Soft-disable incremental compilation
This disables incremental compilation by default and adds a snippet to the compiler release notes explaining the rationale and encouraging testing.
1 parent a92566a commit 6af5faf

File tree

6 files changed

+54
-3
lines changed

6 files changed

+54
-3
lines changed

RELEASES.md

+15
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ Compiler
1818
- [Warn when a `#[test]`-like built-in attribute macro is present multiple times.][91172]
1919
- [Add support for riscv64gc-unknown-freebsd][91284]
2020
- [Stabilize `-Z emit-future-incompat` as `--json future-incompat`][91535]
21+
- [Soft disable incremental compilation][94124]
22+
23+
This release disables incremental compilation, unless the user has explicitly
24+
opted in via the newly added RUSTC_FORCE_INCREMENTAL=1 environment variable.
25+
This is due to a known and relatively frequently occurring bug in incremental
26+
compilation, which causes builds to issue internal compiler errors. This
27+
particular bug is already fixed on nightly, but that fix has not yet rolled out
28+
to stable and is deemed too risky for a direct stable backport.
29+
30+
As always, we encourage users to test with nightly and report bugs so that we
31+
can track failures and fix issues earlier.
32+
33+
See [94124] for more details.
34+
35+
[94124]: https://github.com/rust-lang/rust/issues/94124
2136

2237
Libraries
2338
---------

compiler/rustc_session/src/config.rs

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

21032103
check_thread_count(&debugging_opts, error_format);
21042104

2105-
let incremental = cg.incremental.as_ref().map(PathBuf::from);
2105+
let incremental =
2106+
if std::env::var_os("RUSTC_FORCE_INCREMENTAL").map(|v| v == "1").unwrap_or(false) {
2107+
cg.incremental.as_ref().map(PathBuf::from)
2108+
} else {
2109+
None
2110+
};
21062111

21072112
let assert_incr_state =
21082113
parse_assert_incr_state(&debugging_opts.assert_incr_state, error_format);

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

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

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

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

src/test/run-make/dep-graph/Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
# Just verify that we successfully run and produce dep graphs when requested.
66

77
all:
8-
RUST_DEP_GRAPH=$(TMPDIR)/dep-graph $(RUSTC) \
8+
RUST_DEP_GRAPH=$(TMPDIR)/dep-graph \
9+
RUSTC_FORCE_INCREMENTAL=1 \
10+
$(RUSTC) \
911
-Cincremental=$(TMPDIR)/incr \
1012
-Zquery-dep-graph -Zdump-dep-graph foo.rs
1113
test -f $(TMPDIR)/dep-graph.txt

src/test/run-make/incremental-session-fail/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ all:
88
# Make it so that rustc will fail to create a session directory.
99
touch $(SESSION_DIR)
1010
# Check exit code is 1 for an error, and not 101 for ICE.
11+
RUSTC_FORCE_INCREMENTAL=1 \
1112
$(RUSTC) foo.rs --crate-type=rlib -C incremental=$(SESSION_DIR) > $(OUTPUT_FILE) 2>&1; [ $$? -eq 1 ]
1213
$(CGREP) "Could not create incremental compilation crate directory" < $(OUTPUT_FILE)
1314
# -v tests are fragile, hopefully this text won't change

src/tools/compiletest/src/runtest.rs

+26-1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ pub fn run(config: Config, testpaths: &TestPaths, revision: Option<&str>) {
130130
}
131131
debug!("running {:?}", testpaths.file.display());
132132
let mut props = TestProps::from_file(&testpaths.file, revision, &config);
133+
134+
// Currently, incremental is soft disabled unless this environment
135+
// variable is set. A bunch of our tests assume it's enabled, though - so
136+
// just enable it for our tests.
137+
//
138+
// This is deemed preferable to ignoring those tests; we still want to test
139+
// incremental somewhat, as users can opt in to it.
140+
props.rustc_env.push((String::from("RUSTC_FORCE_INCREMENTAL"), String::from("1")));
141+
133142
if props.incremental {
134143
props.incremental_dir = Some(incremental_dir(&config, testpaths));
135144
}
@@ -146,6 +155,12 @@ pub fn run(config: Config, testpaths: &TestPaths, revision: Option<&str>) {
146155
assert!(!props.revisions.is_empty(), "Incremental tests require revisions.");
147156
for revision in &props.revisions {
148157
let mut revision_props = TestProps::from_file(&testpaths.file, Some(revision), &config);
158+
159+
// See above - need to enable it explicitly for now.
160+
revision_props
161+
.rustc_env
162+
.push((String::from("RUSTC_FORCE_INCREMENTAL"), String::from("1")));
163+
149164
revision_props.incremental_dir = props.incremental_dir.clone();
150165
let rev_cx = TestCx {
151166
config: &config,
@@ -1630,7 +1645,17 @@ impl<'test> TestCx<'test> {
16301645
/// Returns whether or not it is a dylib.
16311646
fn build_auxiliary(&self, source_path: &str, aux_dir: &Path) -> bool {
16321647
let aux_testpaths = self.compute_aux_test_paths(source_path);
1633-
let aux_props = self.props.from_aux_file(&aux_testpaths.file, self.revision, self.config);
1648+
let mut aux_props =
1649+
self.props.from_aux_file(&aux_testpaths.file, self.revision, self.config);
1650+
1651+
// Currently, incremental is soft disabled unless this environment
1652+
// variable is set. A bunch of our tests assume it's enabled, though - so
1653+
// just enable it for our tests.
1654+
//
1655+
// This is deemed preferable to ignoring those tests; we still want to test
1656+
// incremental somewhat, as users can opt in to it.
1657+
aux_props.rustc_env.push((String::from("RUSTC_FORCE_INCREMENTAL"), String::from("1")));
1658+
16341659
let aux_output = TargetLocation::ThisDirectory(self.aux_output_dir_name());
16351660
let aux_cx = TestCx {
16361661
config: self.config,

0 commit comments

Comments
 (0)