Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc: More stable hashes of command line arguments #48641

Merged
merged 1 commit into from
Mar 3, 2018

Conversation

alexcrichton
Copy link
Member

Currently rustc isn't always the best at producing deterministic builds of a
crate when the source directory of a crate is changed. This is happening due to
what appears two different sources:

  • First the -L paths passed to rustc are hashed into the crate hash. These
    paths through Cargo are typically absolute paths that can vary if the build
    directory changes.

  • Next the paths passed to --extern are also hashed which like -L can change
    if the build directory changes.

This commit fixes these two sources of nondeterminism by ensuring that avoiding
tracking the hashes of these arguments on the command line. For -L paths
they're either related to loading crates (whose hashes are tracked elsewhere) or
native librarise used in the linking phase (which isn't incremental). The
--extern paths are similar in that they're related to crate resolution which
is already tracked independently of the command line arguments.

Closes #48019

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 1, 2018
@alexcrichton
Copy link
Member Author

r? @michaelwoerister

Currently rustc isn't always the best at producing deterministic builds of a
crate when the source directory of a crate is changed. This is happening due to
what appears two different sources:

* First the `-L` paths passed to rustc are hashed into the crate hash. These
  paths through Cargo are typically absolute paths that can vary if the build
  directory changes.

* Next the paths passed to `--extern` are also hashed which like `-L` can change
  if the build directory changes.

This commit fixes these two sources of nondeterminism by ensuring that avoiding
tracking the hashes of these arguments on the command line. For `-L` paths
they're either related to loading crates (whose hashes are tracked elsewhere) or
native librarise used in the linking phase (which isn't incremental). The
`--extern` paths are similar in that they're related to crate resolution which
is already tracked independently of the command line arguments.

Closes rust-lang#48019
@michaelwoerister
Copy link
Member

Thanks, @alexcrichton! Nice tests :)
Let's see if this causes a problem on https://travis-ci.org/rust-icci.

@bors r+

@bors
Copy link
Contributor

bors commented Mar 2, 2018

📌 Commit 2e9d9d4 has been approved by michaelwoerister

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 2, 2018
Manishearth added a commit to Manishearth/rust that referenced this pull request Mar 2, 2018
Manishearth added a commit to Manishearth/rust that referenced this pull request Mar 3, 2018
Manishearth added a commit to Manishearth/rust that referenced this pull request Mar 3, 2018
@bors
Copy link
Contributor

bors commented Mar 3, 2018

☔ The latest upstream changes (presumably #48689) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 3, 2018
@bors bors merged commit 2e9d9d4 into rust-lang:master Mar 3, 2018
@alexcrichton alexcrichton deleted the no-hash-l-paths branch March 3, 2018 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rlibs are not bit-identical when building the same crate in different directories with -Zremap-path-prefix
5 participants