Skip to content

rustc_codegen_ssa should write temporary files to the output directory #139963

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

Open
ChrisDenton opened this issue Apr 17, 2025 · 1 comment
Open
Labels
A-codegen Area: Code generation C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ChrisDenton
Copy link
Member

In most places in the compiler temporary files are written to the output directory (using tempdir_in). E.g.:

let metadata_tmpdir = TempFileBuilder::new()
.prefix("rmeta")
.tempdir_in(out_filename.parent().unwrap_or_else(|| Path::new("")))

let archive_tmpdir = TempFileBuilder::new()
.suffix(".temp-archive")
.tempdir_in(output.parent().unwrap_or_else(|| Path::new("")))

The one exception is compiler/rustc_codegen_ssa/src/back/link.rs which writes to the OS temp directory (note the use of tempdir instead of tempdir_in):

let tmpdir = TempFileBuilder::new()
.prefix("rustc")
.tempdir()

I don't think there is a good reason to maintain this inconsistency?

Note that this affects -C save-temps where you have to go hunting for the relevant temp file (or redirect the platform-specific temp directory environment variable).

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 17, 2025
@ChrisDenton ChrisDenton added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 17, 2025
@jieyouxu
Copy link
Member

Related: #138475

@jieyouxu jieyouxu added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-codegen Area: Code generation and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants