Commit 2387999
committed
Truncate IR dump basenames to respect NAME_MAX
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.1 parent 203a324 commit 2387999
1 file changed
Lines changed: 36 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
262 | | - | |
| 262 | + | |
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
273 | 308 | | |
274 | 309 | | |
275 | 310 | | |
| |||
278 | 313 | | |
279 | 314 | | |
280 | 315 | | |
281 | | - | |
282 | 316 | | |
283 | 317 | | |
284 | 318 | | |
| |||
0 commit comments