Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiletest: split rmake.rs executable from scratch directory #125827

Merged
merged 1 commit into from
Jun 2, 2024

Conversation

jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented May 31, 2024

When implementing support for rmake.rs, I copied over the $TMPDIR directory logic from the legacy Makefile setup. In doing so, I also compiled recipe rmake.rs into executables which unfortunately are placed into $TMPDIR as well.

This causes a problem on Windows (as observed in PRs like #125752 (comment)) where:

  • The rmake.exe executable is placed in $TMPDIR.
  • We run the rmake.exe as a process.
  • The process uses rmake.exe inside $TMPDIR.
  • Windows prevents the .exe file from being deleted when the process is still alive.
  • The recipe test code tries to remove_dir_all($TMPDIR), which fails with access denied because rmake.exe is still being used.

We fix this by separating the recipe executable and the output artifacts directory:

base_dir/
    rmake.exe
    rmake_out/

We construct a base directory, unique to each run-make test, under which we place rmake.exe alongside a rmake_out/ directory. This rmake_out/ directory is what is passed to rmake.rs tests as $TMPDIR, so now remove_dir_all($TMPDIR) has a chance to succeed because it no longer contains rmake.exe.

This wasn't a problem for Makefile tests because there's no exe file under $TMPDIR whose process is still running when rm -rf $TMPDIR is called.

try-job: x86_64-msvc

@rustbot
Copy link
Collaborator

rustbot commented May 31, 2024

r? @albertlarsan68

rustbot has assigned @albertlarsan68.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels May 31, 2024
@jieyouxu
Copy link
Member Author

@bors try

@jieyouxu

This comment was marked as resolved.

bors added a commit to rust-lang-ci/rust that referenced this pull request May 31, 2024
…try>

compiletest: split rmake.rs executable from scratch directory

When implementing support for rmake.rs, I copied over the `$TMPDIR` directory logic from the legacy Makefile setup. In doing so, I also compiled recipe `rmake.rs` into executables which unfortunately are placed into `$TMPDIR` as well.

This causes a problem on Windows (as observed in PRs like rust-lang#125752 (comment)) where:

- The `rmake.exe` executable is placed in `$TMPDIR`.
- We run the `rmake.exe` as a process.
- The process uses `rmake.exe` inside `$TMPDIR`.
- Windows prevents the .exe file from being deleted when the process is still alive.
- The recipe test code tries to `remove_dir_all($TMPDIR)`, which fails with access denied because `rmake.exe` is still being used.

We fix this by separating the recipe executable and the scratch directory:

```
base_dir/
    rmake.exe
    scratch/
```

We construct a base directory, unique to each run-make test, under which we place rmake.exe alongside a `scratch/` directory. This `scratch/` directory is what is passed to rmake.rs tests as `$TMPDIR`, so now `remove_dir_all($TMPDIR)` has a chance to succeed because it no longer contains `rmake.exe`.

This wasn't a problem for Makefile tests because there's no exe file under `$TMPDIR` whose process is still running when `rm -rf $TMPDIR` is called.

try-job: x86_64-msvc
@bors
Copy link
Contributor

bors commented May 31, 2024

⌛ Trying commit 2163e31 with merge 092eb27...

@bors

This comment was marked as resolved.

@bors
Copy link
Contributor

bors commented May 31, 2024

☀️ Try build successful - checks-actions
Build commit: 092eb27 (092eb273642f28ffb4b329694c1f577f3c64bc25)

@onur-ozkan
Copy link
Member

r? onur-ozkan

When implementing support for rmake.rs, I copied over the `$TMPDIR`
directory logic from the legacy Makefile setup. In doing so, I also
compiled recipe `rmake.rs` into executables which unfortunately are
placed into `$TMPDIR` as well.

This causes a problem on Windows where:

- The `rmake.exe` executable is placed in `$TMPDIR`.
- We run the `rmake.exe` as a process.
- The process uses `rmake.exe` inside `$TMPDIR`.
- Windows prevents the .exe file from being deleted when the process
  is still alive.
- The recipe test code tries to `remove_dir_all($TMPDIR)`, which fails
  with access denied because `rmake.exe` is still being used.

We fix this by separating the recipe executable and the sratch
directory:

```
base_dir/
    rmake.exe
    scratch/
```

We construct a base directory, unique to each run-make test, under
which we place rmake.exe alongside a `scratch/` directory. This
`scratch/` directory is what is passed to rmake.rs tests as `$TMPDIR`,
so now `remove_dir_all($TMPDIR)` has a chance to succeed because
it no longer contains `rmake.exe`.

Oops. This was a fun one to try figure out.
@rust-cloud-vms rust-cloud-vms bot force-pushed the rmake-separate-tmp-dir branch from 2163e31 to 4562245 Compare June 2, 2024 06:32
@jieyouxu
Copy link
Member Author

jieyouxu commented Jun 2, 2024

Changes since last reviewed:

  • Renamed rmake output artifact directory to rmake_out.
  • Removed redundant create_dir_all.

@rustbot ready

Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@onur-ozkan
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jun 2, 2024

📌 Commit 4562245 has been approved by onur-ozkan

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 2, 2024
@bors
Copy link
Contributor

bors commented Jun 2, 2024

⌛ Testing commit 4562245 with merge 13e2d72...

@bors
Copy link
Contributor

bors commented Jun 2, 2024

☀️ Test successful - checks-actions
Approved by: onur-ozkan
Pushing 13e2d72 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 2, 2024
@bors bors merged commit 13e2d72 into rust-lang:master Jun 2, 2024
7 checks passed
@rustbot rustbot added this to the 1.80.0 milestone Jun 2, 2024
@jieyouxu jieyouxu deleted the rmake-separate-tmp-dir branch June 2, 2024 10:18
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (13e2d72): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results (secondary -3.4%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.4% [-3.4%, -3.4%] 1
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 667.268s -> 666.563s (-0.11%)
Artifact size: 318.90 MiB -> 318.88 MiB (-0.01%)

// ```
// base_dir/
// rmake.exe
// scratch/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this comment is out of date now with the rmake_out change?

Copy link
Member Author

@jieyouxu jieyouxu Jun 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the PR description but I forgor to update the comment, thanks, I'll send a follow-up PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #125896

jieyouxu added a commit to jieyouxu/rust that referenced this pull request Jun 2, 2024
…, r=compiler-errors

compiletest: fix outdated rmake.rs comment

Noticed in rust-lang#125827 (comment). I fixed the PR description but forgot to update the comment.
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 2, 2024
…, r=compiler-errors

compiletest: fix outdated rmake.rs comment

Noticed in rust-lang#125827 (comment). I fixed the PR description but forgot to update the comment.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jun 3, 2024
Rollup merge of rust-lang#125896 - jieyouxu:compiletest-rmake-comment, r=compiler-errors

compiletest: fix outdated rmake.rs comment

Noticed in rust-lang#125827 (comment). I fixed the PR description but forgot to update the comment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants