Skip to content

strip prefix of temporary file names when it exceeds filesystem name length limit #145005

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
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tardyp
Copy link

@tardyp tardyp commented Aug 6, 2025

When doing lto, rustc generates filenames that are concatenating many information.

In the case of this testcase, it is concatenating crate name and rust file name, plus some hash, and the extension. In some other cases it will concatenate even more information reducing the maximum effective crate name to about 110 chars on linux filesystems where filename max length is 255

This commit is ensuring that the temporary file names are limited in size, while still reasonably ensuring the unicity (with hashing of the stripped part)

Fix: #49914

@rustbot
Copy link
Collaborator

rustbot commented Aug 6, 2025

r? @lcnr

rustbot has assigned @lcnr.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 6, 2025
@rustbot

This comment has been minimized.

@bjorn3
Copy link
Member

bjorn3 commented Aug 6, 2025

This method is also used for generating output files in various places. Mangling the name of output files would break cargo and other build tools that pre-generate the expected filenames based on rustc --print file-names or hardcode it.

@tardyp
Copy link
Author

tardyp commented Aug 6, 2025

@bjorn3 would it be more appropriate to put the filename stripping in temp_path_ext_for_cgu ?

those files if I understand correctly are temporary and unlinked after the rustc invocation.

@tardyp tardyp force-pushed the lto_big_filesize branch from 9f21f3c to 4d6eb1e Compare August 6, 2025 16:37
…length limit

When doing lto, rustc generates filenames that are concatenating many information.

In the case of this testcase, it is concatenating crate name and rust file name, plus some hash, and the extension.
In some other cases it will concatenate even more information reducing the maximum effective crate name to about 110 chars on linux filesystems where
filename max length is 255

This commit is ensuring that the temporary file names are limited in size, while still reasonabily ensuring the unicity (with hashing of the stripped part)
@tardyp tardyp force-pushed the lto_big_filesize branch from 4d6eb1e to 3239eeb Compare August 6, 2025 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"File name too long" error when compiling files with long names
4 participants