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

Make host_root return host.root(), not host.dest() #8819

Merged
merged 3 commits into from
Oct 29, 2020
Merged

Make host_root return host.root(), not host.dest() #8819

merged 3 commits into from
Oct 29, 2020

Conversation

khyperia
Copy link
Contributor

Also create host_dest function to let other callsites retain their old functionality. Fixes #8817, verified it works on the original problem reported in the rust-gpu repo.

I did two things here:

  1. Rename host_root (which returns self.host.dest()) to be host_dest. This has three callsites. I did this to make it more clear that it returns dest, not root.
  2. For the callsite that's relevant in fingerprint.rs uses different target roots when serializing/deserializing #8817, I created a "new" host_root function (that returns self.host.root()). This means that the callsite that this PR is actually fixing doesn't show up in this diff :/ - but I thought it was more clear this way.

(Also copied the example path docs over from layout.rs to hopefully avoid this mistake again in the future)

I tried to look into if the other two callsites should actually be calling host.root() instead of dest, because I imagine the same mistake could have been made again, but it quickly grew out of my understanding (this is my first time in the cargo codebase). Feel free to let me know if they should also call host.root() too, and I can update them.

Thanks! (oh gosh I have no idea what I'm doing, I hope this is right)

r? @alexcrichton

Also create host_dest function to let other callsites retain their old
functionality
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 28, 2020
@alexcrichton
Copy link
Member

Nah this looks great, thanks! Would it be possible to add a test of some form for this as well?

@ehuss
Copy link
Contributor

ehuss commented Oct 28, 2020

Thanks!

Do you think you could add a test for this? It would probably go in freshness.rs. There is some documentation on running and writing tests at https://doc.crates.io/contrib/tests/index.html. I can also help answer questions or help with writing it.

I'm a little uncertain what exactly the issue is, though. Is there a command I can run in the rust-gpu repo to reproduce the problem?

@khyperia
Copy link
Contributor Author

khyperia commented Oct 28, 2020

I'm a little uncertain what exactly the issue is, though. Is there a command I can run in the rust-gpu repo to reproduce the problem?

There's a bit of setup before you can build rust-gpu, overviewed in the getting started guide - tl;dr install the pinned nightly version, add rust-src rustc-dev llvm-tools-preview components, install SPIRV-Tools binaries to PATH, then cargo build.

There's a few fiddly dependency bugs, but theoretically, from a clean build, running cargo build followed by cargo build will not be a no-op, but rather rebuild a couple crates. This is because the dep file in target/spirv-unknown-unknown/release/example_shader.d has the nonexistent path /.../target/release/debug/deps/librustc_codegen_spirv.so (it should be target/debug/deps, not target/release/debug/deps), and so cargo says "oh, missing file in the deps, better rebuild".

Then, follow the logic of #8817 to see how that path in that file leads to this change.

It certainly is a massive and bizzarely-set-up project, though (building a compiler and using it requires shenanigans), which obscures things a bit.

Do you think you could add a test for this?

Yeah!

@khyperia
Copy link
Contributor Author

khyperia commented Oct 28, 2020

Oh, I just realized, cargo itself doesn't consume the incorrect .d file, that's probably why this bug has gone unnoticed - it's intended to only be used by external build systems (which is technically what's happening in rust-gpu, even though the "external build system" is actually another cargo)

//! On top of all this, Cargo emits its own dep-info files in the output
//! directory. This is done for every "uplifted" artifact. These are intended
//! to be used with external build systems so that they can detect if Cargo
//! needs to be re-executed. It includes all the entries from the `rustc`
//! dep-info file, and extends it with any `rerun-if-changed` entries from
//! build scripts. It also includes sources from any path dependencies. Registry
//! dependencies are not included under the assumption that changes to them can
//! be detected via changes to `Cargo.lock`.

In any case, test written! fails before this commit, succeeds afterwards.


edit: also, if you'd like, feel free to ping me on Embark discord, rust-gpu channel, or the rust-lang zulip (I'm either "Ashley Hauck" or khyperia, I forget), if you'd like to poke around what utterly cursed things we're doing to cargo in rust-gpu, and perhaps ways we could do things better. (I'm guessing there might be questions around why we're consuming cargo dep files into another cargo...). It's very similar to the wasm problem of "an x86 crate wants to reference a wasm crate and embed the binary in itself to use it", except spir-v, not wasm, and we need to build the compiler backend for spir-v too.

@ehuss
Copy link
Contributor

ehuss commented Oct 29, 2020

Looks good, thanks!

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 29, 2020

📌 Commit 628f701 has been approved by ehuss

@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 Oct 29, 2020
@bors
Copy link
Collaborator

bors commented Oct 29, 2020

⌛ Testing commit 628f701 with merge 7197c66...

@bors
Copy link
Collaborator

bors commented Oct 29, 2020

☀️ Test successful - checks-actions
Approved by: ehuss
Pushing 7197c66 to master...

@bors bors merged commit 7197c66 into rust-lang:master Oct 29, 2020
@khyperia khyperia deleted the target-root-path branch October 29, 2020 07:54
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Nov 5, 2020
Update cargo

7 commits in becb4c282b8f37469efb8f5beda45a5501f9d367..d5556aeb8405b1fe696adb6e297ad7a1f2989b62
2020-10-28 16:41:55 +0000 to 2020-11-04 22:20:36 +0000
- Implement weak dependency features. (rust-lang/cargo#8818)
- Avoid some extra downloads with new feature resolver. (rust-lang/cargo#8823)
- fix: remove install command `$`, for copying friendly (rust-lang/cargo#8828)
- Bump `anyhow` dependency to `1.0.34` in `crates-io` crate (rust-lang/cargo#8826)
- Normalize SourceID in `cargo metadata`. (rust-lang/cargo#8824)
- vendor: correct the path to cargo config (rust-lang/cargo#8822)
- Make host_root return host.root(), not host.dest() (rust-lang/cargo#8819)
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Nov 5, 2020
Update cargo

7 commits in becb4c282b8f37469efb8f5beda45a5501f9d367..d5556aeb8405b1fe696adb6e297ad7a1f2989b62
2020-10-28 16:41:55 +0000 to 2020-11-04 22:20:36 +0000
- Implement weak dependency features. (rust-lang/cargo#8818)
- Avoid some extra downloads with new feature resolver. (rust-lang/cargo#8823)
- fix: remove install command `$`, for copying friendly (rust-lang/cargo#8828)
- Bump `anyhow` dependency to `1.0.34` in `crates-io` crate (rust-lang/cargo#8826)
- Normalize SourceID in `cargo metadata`. (rust-lang/cargo#8824)
- vendor: correct the path to cargo config (rust-lang/cargo#8822)
- Make host_root return host.root(), not host.dest() (rust-lang/cargo#8819)
@ehuss ehuss added this to the 1.49.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fingerprint.rs uses different target roots when serializing/deserializing
5 participants