-
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
Not reproducible when a project is copied to another directory #13586
Comments
this is a cargo issue, not a compiler one. -C metadata is passed by cargo. |
cargo/src/cargo/core/source_id.rs Lines 536 to 540 in 2fe739f
If crates are in the same workspace, their paths will be relative to workspace and get hashed into metadata. This is likely by design to avoid reuse cache coming from different workspace when sharing So for you, The straightforward solution for you is putting these crates under a single workspace. |
It is tempted to use pathdiff and hash relative paths instead of absolutes. Yet it doesn't help reproducibility when you move and change the relative path of the crate to the workspace, without any code change. |
The Compiled Binary Files Are Inconsistent After the Directory of the Rust Package Is Changed.
It is important to have reproducible builds.
Let's say I have two crate in my project, crate mangle2 depends on crate mangle1 and they are located in directory1.
mangle1/Cargo.toml file:
mangle1/src/lib.rs file:
in mangle2/Cargo.toml file, we see mangle2 depends on mangle1.
in mangle2/src/lib.rs file
Then I went into the mangle2 directory and compiled the whole project.
when compiling mangle2, we see -C metadata=b27aeebcd77b3cf1.
Then I copied the directory1 directory to another location directory2.
As before, I went into the mangle2 directory and compiled the whole project.
this time when compiling mangle2, we see -C metadata=6bc8f0dbcefdbca3.
The metadata of the two compilations is different. Therefore, the symbol table names in the generated binary files are different.
_ZN7mangle29super_add17heef584606885c889E change to _ZN7mangle29super_add17h7cd0a6fdff1a3985E
I just copied the project to a different directory and didn't change any code. Compiling in different directories caused binary inconsistencies.
If a single crate is copied to another directory for compilation, this problem does not occur. Binary inconsistency occurs when two crates depend on each other and both crates are copied to another directory.
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: