Truncate IR dump basenames to respect NAME_MAX#1650
Open
npiesco wants to merge 1 commit intorust-lang:mainfrom
Open
Truncate IR dump basenames to respect NAME_MAX#1650npiesco wants to merge 1 commit intorust-lang:mainfrom
npiesco wants to merge 1 commit intorust-lang:mainfrom
Conversation
Symbol-mangled Rust names can easily exceed the per-component filename
length limit enforced by most filesystems (255 bytes on ext4/XFS/Btrfs,
143 on HFS+, 255 UTF-16 code units on NTFS), causing `File::create`
in `write_ir_file` to fail with ENAMETOOLONG when `--emit=llvm-ir`
is passed so cg_clif dumps CLIF/vcode per function. The previous code
carried a `FIXME work around filename too long errors` marker.
This change introduces `truncate_ir_basename`: names `\u{2264}` 200
bytes pass through unchanged; longer names are rewritten to
`<first 160 bytes of stem>_h<16-hex-FNV-1a-64 of full stem>.<exts>`.
The hash is computed over the original stem, so the transformation is
deterministic and collision-resistant (any two distinct inputs map to
distinct outputs with overwhelming probability). Extension suffix
chains such as `.opt.clif`, `.unopt.clif`, and `.vcode` are
preserved, so downstream tooling keying off the extension is unaffected.
The function is invoked inside `write_ir_file` so that every caller
(`write_clif_file` for CLIF dumps and the vcode dump in `base.rs`)
benefits uniformly, and the FIXME at the top of `write_clif_file` is
removed.
Author
|
@folkertdev @Urgau — tagging you for a second pair of eyes since #1649 closed with a "not quite the right approach" note but no concrete alternative. Open to reshaping on feedback; the core point is that the current |
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.
Resolves the
// FIXME work around filename too long errorsinsrc/pretty_clif.rs.When
--emit=llvm-iris used with cg_clif, symbol-mangled basenames can exceed the filesystem per-component limit (255B on ext4/XFS/APFS, 143B on HFS+, 255 UTF-16 on NTFS).File::createreturnsENAMETOOLONG; the currentearly_warnpath silently drops the dump.This patch truncates only names that would fail:
Cow).<first 160 bytes of stem>_h<16-hex-FNV-1a-64 over the full stem>.<exts>..opt.clif,.unopt.clif,.vcode) preserved.Called inside
write_ir_file, so bothwrite_clif_fileand the vcode writer inbase.rsbenefit uniformly.Supersedes #1649 (closed). Happy to adjust the shape on review feedback.