Repository navigation
codegen: back the standalone compiler's scratch directory with tempfile - #417
Merged
nihalpasham merged 3 commits intoJul 24, 2026
Merged
Conversation
ScratchDirectory was a hand-rolled RAII temp directory: a process-id and nanosecond-timestamp name, a compilation counter to break ties, a 32-attempt retry loop around DirBuilder, and a Drop that removes the tree. That is a reimplementation of tempfile, carrying the collision and cleanup edge cases that a widely used crate has already worked through. Replace it with tempfile::Builder. The 0o700 mode the previous code set through DirBuilderExt survives as Builder::permissions, and TempDir's own Drop keeps the cleanup behaviour. Add a workspace tempfile entry pinned at 3.9, the first release exposing Builder::permissions; 3.3 through 3.8 would fail to compile against this code. The workspace had no tempfile entry before; this adds one. The 3.3.0 in crates/fuzzer/rustlantis/difftest belongs to a separate vendored workspace that is excluded from this one and is unaffected. The scratch directory holds the caller's LLVM IR and the generated PTX in a shared temp root, so its mode is a security property and now has a unix test asserting 0o700. That mode is also the sole reason for the 3.9 floor. tempfile brings six transitive crates (rustix, linux-raw-sys, fastrand, getrandom, errno, r-efi), all permissively licensed and recorded in dependency-licenses.csv. errno and r-efi are platform-conditional and are not compiled on x86_64-unknown-linux-gnu. Signed-off-by: Alejandro Soto Franco <[email protected]>
# Conflicts: # crates/rustc-codegen-cuda/Cargo.lock
Collaborator
|
Taking the dependency: The branch had gone conflicting, so I pushed a merge with main: both lockfiles regenerated, licenses CSV rows confirmed against the resolved versions. cargo deny (licenses + bans) green, |
nihalpasham
approved these changes
Jul 24, 2026
nihalpasham
left a comment
Collaborator
There was a problem hiding this comment.
Taking the dependency; see merge comment.
nihalpasham
approved these changes
Jul 24, 2026
nihalpasham
left a comment
Collaborator
There was a problem hiding this comment.
Taking the dependency; validated on the merged head. See merge comment.
This was referenced Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One of three parts of #357, split so each can be reviewed on its own. This part adds a dependency, which is the discussion the other two were sitting behind. The three parts are independent: each applies cleanly to
mainalone, and they merge cleanly in any order. #357 will be closed once all three are open.Sibling parts: #415 (clone, liveness and diagnostic paths), #416 (target selection provenance).
Summary
ScratchDirectorywas a hand-rolled RAII temp directory: a process-id and nanosecond-timestamp name, a compilation counter to break ties, a 32-attempt retry loop aroundDirBuilder, and aDropthat removes the tree. That is a reimplementation oftempfile, carrying the collision and cleanup edge cases a widely used crate has already worked through.Changes
tempfile::Builder. The 0o700 mode the previous code set throughDirBuilderExtsurvives asBuilder::permissions, andTempDir's ownDropkeeps the cleanup behaviour.tempfileentry pinned at 3.9.dependency-licenses.csv.Rationale
3.9 is the first release exposing
Builder::permissions; 3.3 through 3.8 would fail to compile against this code. The workspace had notempfileentry before, so this adds one. The 3.3.0 incrates/fuzzer/rustlantis/difftestbelongs to a separate vendored workspace that is excluded from this one and is unaffected.The scratch directory holds the caller's LLVM IR and the generated PTX in a shared temp root, so its mode is a security property. It had no test, and it is also the sole reason for the 3.9 floor, so it has one now.
tempfilebrings six transitive crates:rustix,linux-raw-sys,fastrand,getrandom,errno,r-efi. All are permissively licensed and recorded independency-licenses.csv.errnoandr-efiare platform-conditional and are not compiled onx86_64-unknown-linux-gnu. Lockfiles were regenerated rather than transcribed, sofastrandresolves to 2.5.0 here.If the dependency is unwanted, the alternative is to keep the hand-rolled implementation and add the 0o700 test to it. The other two parts of #357 do not depend on this one either way.
Validation
cargo check --workspace --all-targetscargo test -p cuda-oxide-codegen(118 passed)cargo test -p mir-importer(801 passed)cargo clippy --workspace -- -D warningscargo fmt --all -- --check(cd crates/rustc-codegen-cuda && cargo fmt --all -- --check)cargo deny check, givingadvisories ok, bans ok, licenses ok, sources okRUSTDOCFLAGS="-D warnings" cargo doc --no-deps --workspace