Skip to content

rustc_codegen_ssa should write temporary files to the output directory #139963

@ChrisDenton

Description

@ChrisDenton
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).

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Apr 17, 2025
added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Apr 17, 2025
jieyouxu

jieyouxu commented on Apr 17, 2025

@jieyouxu
Member

Related: #138475

added
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
A-codegenArea: Code generation
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Development

    No branches or pull requests

      Participants

      @ChrisDenton@jieyouxu@rustbot

      Issue actions

        rustc_codegen_ssa should write temporary files to the output directory · Issue #139963 · rust-lang/rust