Skip to content

Commit 243e61d

Browse files
author
Ralph Küpper
committed
test(codegen): update scratch lifecycle gate for native-root decision
1 parent 461a8a8 commit 243e61d

2 files changed

Lines changed: 11 additions & 36 deletions

File tree

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,8 @@
11
### Fixed
22

3-
- **In-process LLVM compiles no longer leak an empty scratch directory per compile.**
4-
`compile_ll_inprocess_in`'s statepoint arm is the only in-process path that
5-
*creates* the per-compile scratch directory — it writes the assembly there
6-
before the compact-map rewrite — but its cleanup removed the two files it knew
7-
about and left the directory. One `perry_llvm_scratch_<pid>_<counter>` husk
8-
survived every compile.
9-
10-
The clang path has always done `remove_dir_all`, under a comment saying "the
11-
directory cannot survive as an empty husk". Nothing went wrong while clang was
12-
the default; the leak began when the in-process backend became it, and the
13-
cleanup that only ever existed on the other path stopped running.
14-
15-
This is what turned `repsel-census` red on `main`: the job's Temp-directory
16-
hygiene step reported `58 compile(s) left 58 entries in a temp directory that
17-
started empty`. The leak is counted in *compiles* rather than in distinct IR,
18-
which is what distinguishes it from the earlier `#7144` leak.
19-
20-
The consequence was larger than a pile of empty directories. Temp-directory
21-
hygiene runs before `Promotion census` and `Sabotage check`, so both were
22-
skipped for every red run — the census gate itself had not executed on `main`
23-
since 2026-08-04. Because `repsel-census` is not a required status check, eight
24-
consecutive red nightlies blocked nothing and nobody was forced to notice.
25-
26-
The regression test pins the statepoint lowering with `NativeRootsPin::native()`
27-
rather than trusting the host default. Only the statepoint backends route
28-
through assembly, and only that arm creates the directory, so without the pin
29-
the test passes on a host that never enters the arm — the vacuous shape this
30-
repo has been bitten by before. Verified by sabotage: restoring the two
31-
`remove_file` calls turns the test red.
3+
- **Successful in-process LLVM statepoint compiles no longer leave an empty
4+
scratch directory behind.** Cleanup now removes the per-compile directory as
5+
a unit, matching the clang path and preventing temporary-directory growth
6+
proportional to the number of compiles. A focused regression explicitly
7+
selects native-root lowering and verifies that repeated compiles leave no
8+
scratch entries.

crates/perry-codegen/src/linker_temp_lifecycle_tests.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -455,17 +455,15 @@ fn inprocess_statepoint_compile_leaves_no_empty_scratch_dir() {
455455
// about and left the directory — harmless while clang was the default, a
456456
// leak per compile once in-process became it.
457457
//
458-
// The pin is what makes this test non-vacuous. Only the statepoint
459-
// backends route through assembly, and only that arm CREATES the scratch
460-
// dir; without the pin this passes on a host that never enters the arm at
461-
// all, which is the shape of gate the repo keeps getting bitten by.
458+
// The explicit native-roots decision is what makes this test non-vacuous.
459+
// Only the statepoint backends route through assembly, and only that arm
460+
// CREATES the scratch dir; `false` would exercise a path that never creates
461+
// the directory this regression is meant to observe.
462462
let Some(root) = temp_root_if_clang_available("inprocess_statepoint") else {
463463
return;
464464
};
465-
let _pin = crate::codegen::helpers::NativeRootsPin::native();
466-
467465
for nth in 0..3 {
468-
let bytes = compile_ll_inprocess_in(&root, &test_ir(100 + nth), None, CLEAN)
466+
let bytes = compile_ll_inprocess_in(&root, &test_ir(100 + nth), None, CLEAN, true)
469467
.unwrap_or_else(|e| panic!("in-process compile {nth} failed: {e:#}"));
470468
assert!(!bytes.is_empty(), "compile {nth} produced no object bytes");
471469
assert_eq!(

0 commit comments

Comments
 (0)