-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Cargo modifies renamed executable in the target directory on rebuild #11101
Comments
Thanks for the report and reproducible steps! This is not a copy or modification of the renamed executable. Instead, it is a hard link.
On Linux, the second column of My bold guessing is that the inode was reused so that the renamed hard link and new hard link pointed to the same inode. Unfortunately, it seems that inode reuse depends on multiple things and is not easy to control3. I am not an expert on this topic, though. BTW my x86_64 Linux did create hard links but cannot reproduce this issue. Footnotes |
To confirm my assumption, could you use |
Looks like yes
Before creating this issue I also thought that there could be something going with hard links, but didn't debug it more thoroughly with My use case, where I found this surprising was the following. I renamed the binary output hoping that I would save a copy of the executable for the future. Then I changed my code and rebuilt the project. Then, imagine how surprised I was to figure out that the executable I renamed before now is the same as the one that I've just rebuilt. Since this behavior is very magical I propose to either re-review it and maybe make a real copy of the binary instead of hard-linking to By the way, here is a related issue (possibly a duplicate): #8348 |
Problem
If you rename the executable output file in
target/{profile}
and rebuild the project, then the renamed file is modified to be a copy of the new binary output.I suppose it is possible to create an unlimited amount of renamed files this way and all of them will be modified to be the copy of the latest built executable. I've verified that renaming the executable and building the project two times (i.e. having
original
executable,renamed_copy_1
,renamed_copy_2
).Steps
The commands in terminal (bash). I've copied them with the output lower
As you can notice, the size of the file
renamed-1
changed to14M
, where it was3.8M
before, and it do is the copy of that latest build (rename-repro
)Here is also the reproduction on windows recorded in a video
rust-rename-repro.mp4
Notes
Verified that the bug reproduces both on Linux amd64 and Windows amd64
Version
The text was updated successfully, but these errors were encountered: