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

buildRustCrate: add host platform to rlib hash suffix #105305

Merged
merged 1 commit into from
Nov 29, 2020

Conversation

lopsided98
Copy link
Contributor

Motivation for this change

If a crate depends on both the host and build versions of a crate when cross-compiling, both versions of the crate have the same rlib name, and they clobber each other in the deps directory. This PR adds the host platform target triple to the hash, so the crates end up with unique hashes.

Is there a reason ___ is used to separate the components?

cc @Ericson2314 @andir

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@ofborg ofborg bot added the 6.topic: rust label Nov 29, 2020
@ofborg ofborg bot requested a review from adisbladis November 29, 2020 00:55
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Nov 29, 2020
@Ericson2314
Copy link
Member

Is there a reason ___ is used to separate the components?

I bet someone was being cautious about pre-image attacks. Not sure if this is necessary or even sufficient, but I suppose we can leave it for now. Maybe if you want and a TODO asking someone to explain.

@lopsided98 lopsided98 force-pushed the build-rust-crate-platform-hash branch from 096c213 to f46a70c Compare November 29, 2020 03:21
@lopsided98
Copy link
Contributor Author

This breaks buildRustCrateTests because they check the specific hash value. We should probably just allow any hash, but that will require rewriting the test infrastructure a bit.

@lopsided98 lopsided98 force-pushed the build-rust-crate-platform-hash branch from f46a70c to 8c47905 Compare November 29, 2020 03:25
@Ericson2314
Copy link
Member

Yeah I would just focus on testing that things that shouldn't be equal indeed are. Nix makes it very easy to make it deterministic, but leaves it to the other to make the equivalence class sufficiently fine-grained.

@Ericson2314 Ericson2314 merged commit 7781642 into NixOS:master Nov 29, 2020
@Ericson2314
Copy link
Member

Oh I forgot about the tests, I guess I'll go fix myself.

Ericson2314 added a commit that referenced this pull request Nov 29, 2020
As @lopsided98 points out in #105305, we're probably better off not
asserting exact hashes, but that is a more involved fix.
@Ericson2314
Copy link
Member

Fixed tests in #105379.

@lopsided98 lopsided98 deleted the build-rust-crate-platform-hash branch November 29, 2020 17:22
@andir
Copy link
Member

andir commented Nov 30, 2020

Ugh, the commit message doesn't cary any of the detail required to judge the change. We only have that in this PR.. This will make it harder to figure out why we did something. In my initial refactoring the git history was the most valuable asset we had on this :/

Regardless of that I think this is a good change. Thanks @lopsided98!

Ericson2314 added a commit that referenced this pull request Dec 19, 2020
As @lopsided98 points out in #105305, since the hashes are now target
sensative, and until we find reason to actually care to test what they
are exactly, we are best just normalizing them away in the tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: rust 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants