This repository contains a proof of concept for building rustc reproducibly.
The patches it uses are not all completely clean or even correct; they are intended to serve as a basis for discussion. We would greatly appreciate any suggestions for how to improve them.
To get reproducible builds locally, either run
- Apply the patches to two identical rustcs (tested with version 1.37.0).
- Build the two rustcs.
- Diff their stage 2s.
We currently require the following patches to build rustc reproducibly.
We can use the config option
--remap-path-prefixto rustc processes. As currently implemented, this does not work for non-target crate types such as proc-macro, which causes some libraries to depend on the path. We fix this by modifying it to work for everything.
We need to modify rustc to avoid hashing the
--sysrootargument, which contains the current directory and so leads to non-reproducible builds when using different source paths.
We modify librustc_llvm to avoid using the
__FILE__macro, which can contain absolute paths. We do this by propagating
NDEBUGfrom the bootstrap if applicable.
Similarly, we need to avoid using
__FILE__when compiling compiler-rt. This behavior cannot be disabled as easily as the one above, so as a hack we simply remove the