Make mtime of reproducible tarballs dependent on git commit by Kobzol · Pull Request #127050 · rust-lang/rust (original) (raw)

Since #123246, our tarballs should be fully reproducible. That means that the mtime of all files and directories in the tarballs is set to the date of the first Rust commit (from 2006). However, this is causing some mtime invalidation issues (#125578 (comment)).

Ideally, we would like to keep the mtime reproducible, but still update it with new versions of Rust. That's what this PR does. It modifies the tarball installer bootstrap invocation so that if the current rustc directory is managed by git, we will set the UTC timestamp of the latest commit as the mtime for all files in the archive. This means that the archive should be still fully reproducible from a given commit SHA, but it will also be changed with new beta bumps and download-rustc versions.

Note that only files are set to this mtime, directories are still set to the year 2006, because the tar library used by rust-installer doesn't allow us to selectively override mtime for directories (or at least I haven't found it). We could work around that by doing all the mtime modifications in bootstrap, but that would require more changes. I think/hope that just modifying the file mtimes should be enough. It should at least fix cargo rustc mtime invalidation.

Fixes: #125578

r? @onur-ozkan

try-job: x86_64-gnu-distcheck