Cargo unit fingerprint influence on generated binaries


I am trying to do a reproducible build on rust compiler, for that rust sources are built in 2 build directories (buildA & buildB) with command build --build-dir buildA

But, the generated binary in build directories (../x86_64-unknown-linux-gnu/stage1/lib) are different.

When I analyzed the differences I could see the fingerprint is changed between both builds (The sources are identical just a rebuild on another build directory on buildB).

Does the change in fingerprint influences the generated binaries? if yes, how

Some addition details can be found here...rustc-driver binary is not identical for every build · Issue #102299 · rust-lang/rust · GitHub

Did you set remap-debuginfo = true in config.toml? If not, the debuginfo will differ.

The fingerprint doesn't affect the generated binaries as it is only used by cargo itself to determine if the crate needs to be rebuilt. The metadata hash can affect generated binaries as it is passed to rustc using -Cmetadata and is also what the xxxx part of and similar is, but that one doesn't include any paths or source files, but is based on rustc version, the used profile settings, crate name and version, dependencies and so on.

I tried by setting remap-debuginfo = true but still the binary differs. I am trying to add --remap-path-prefix environment variable but unable to add this in config.toml and not working when added in ~/.cargo/config. Where to set these env variables?

How exactly does it differ? Are there paths that changed, did symbol names differ or is it the assembly that changed?

1 Like