rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.31k stars 1.62k forks source link

Non-reproducible builds #5351

Open jgalenson opened 4 years ago

jgalenson commented 4 years ago

If I make two different copies of rust-analyzer, set them both to build with --remap-path-prefix by adding it to rustflags in .cargo/config, and build them with cargo xtask install, I see multiple differences in the output files, including librust_analyzer.rlib and a number of the rlibs in release/deps. Many of the rlib differences are non-obvious differences in rmeta files.

Now that this is part of the rustc tree, this affects rust-lang/rust#34902.

jonas-schievink commented 4 years ago

With this patch the output of two consecutive builds is identical:

--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,6 +5,8 @@ members = [ "crates/*", "xtask/" ]
 # disabling debug info speeds up builds a bunch,
 # and we don't rely on it for debugging that much.
 debug = 0
+incremental = false
+codegen-units = 1

 [profile.release]

Therefore, closing as a rustc bug.

jgalenson commented 4 years ago

I still see differences with that patch, both in target/debug (just libxtask-*.rlib) and in target/release (same as before). For one thing, doesn't that not affect the release build?

To make it more clear, I'm not talking about two repeated builds of the same directory but two builds of different directories. That is, clone the repo, make a copy of it in a different location, add --remap-path-prefix to both, build both, and compare the outputs.

jonas-schievink commented 4 years ago

Hmm, I see. Are you sure this is not a rustc bug?

jgalenson commented 4 years ago

No, I'm not sure. But the steps I described in the first comment here reproduce for me when I clone this project by itself, so I don't think it's a bug in the rustc build system, if that's what you meant. The cause of the non-reproducibility could be due to a bug in rustc itself, of course, but it also could be due to something here; it's not obvious to me which is the case.