Make -Cmetadata consistent across platforms by alexcrichton · Pull Request #14107 · rust-lang/cargo (original) (raw)
This commit updates how -Cmetadata is calculated for each unit to optionally exclude the host: ... line that rustc prints for cross-compiled builds. Previously the full verbose_version was hashed for stable builds and the host was explicitly hashed for non-stable builds. For a build using --target, however, that means that the -Cmetadata will be different when producing the same target on different hosts (e.g. producing the binary once on Linux and once on macOS).
This can hinder reproduction of a binary across different platforms even when the --target flag is used. For example in rust-lang/rust#117597 it was seen that a WebAssembly binary produced on different platforms was slightly different and this appears due to the differing -Cmetadata flags. After this commit the -Cmetadata flag is the same for two different platforms meaning that different platforms produce the same binary.
I've tested locally and a simple project produces a different binary before this change but produces the same binary on two platforms after this change. Unfortunately automated testing of this change will be difficult since it requires two different host compilers, though.