-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
[WIP] Content hash support. (See also cargo changes) #75594
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
That looks a legit test failure. Let me look into that. |
Hmm, so that test failure wasn't legit and went away. Meanwhile spotted we already use a |
Compiled dependencies and probably the output files also need to be hashed. |
Updated it so that we use the precomputed hashes - this makes this change effectively zero cost now as all the source was being hashed elsewhere. That's much better than I was exepcting (and given that maybe there's no need to put it behind a -Z rustc flag?). That's a really weird compiler error - I don't have a mental model how that could happen. Locally it's an Rc but the CI thinks it's an Arc. It's like the CI isn't actually compiling the branch of code I'm on, but is merging the patch onto master and building that? (Maybe the process has changed a bit? - I've taken a fair few months off from submissions) |
How should the hashes [u8] should be turned into utf8? Seems there's pleanty of options to turn bin to text - for now I've dodge that and just used the debug formatting of [u8] to turn it to a string but suggestions welcome! |
There is a type in |
☔ The latest upstream changes (presumably #74862) made this pull request unmergeable. Please resolve the merge conflicts. |
@ehuss do my changes to base.rs look vaguely in the right direction? Once I can get one symbol appearing in the output that I can find I'll be unstuck. But I'm really clueless about this codegen side at the moment - I've not touched this part of the compiler at all before. Any hints are greatfully appreciated and may shave months of headbanging off this PR... |
Well this have been a voyage of discovery, I made a hi.rs that printed 'Hi'. I can see the section coming out in the llvm IR code and I can see it coming out in the generated assembly code if I do:
I can see it in So I guess it's all working fine but some optimisation layer is removing it (linker maybe?). I will try and see if I can hint to the linker not to remove it... |
This for executables? You may need to do the same as for the gdb debug scripts section. (reference it from the main shim using a volatile load) rust/compiler/rustc_codegen_ssa/src/base.rs Line 429 in 17cc9b6
|
Seem to get the symbol coming out for rmeta and executables now. Just trying to add the symbol to the dylib (it's not coming out in the .ll so I've got a way to go there...). |
The cdylib doesn't contain the svh symbol, as the metadata module is omitted for cdylibs. |
.collect(); | ||
|
||
if let Some(ref backend) = sess.opts.debugging_opts.codegen_backend { | ||
files.push(backend.to_string()); | ||
files.push((backend.to_string(), None)); // TO DO: is this something we need to hash? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It is a dylib, so it contains an SVH. You could add a parameter with the result of codegen_backend.metadata_loader()
to this function to read it, but that looks like a bit of a hack.
denser encoding format Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
Did you also add the corresponding decode call? |
I see where I was being tripped up - the encode was converting an array to a slice before writing it so there's a length in there as well messing up my offsets. I should have guessed that might happen sooner... |
☔ The latest upstream changes (presumably #79070) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
☔ The latest upstream changes (presumably #77117) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
@gilescope any updates on this? |
This PR is good, but blocked waiting on the cargo changes. The cargo PR needs another round of work to nail the build.rs interactions. |
@gilescope @rustbot label: +S-inactive |
This PR adds a makefile comment (on the following line as can't be the same line in makefiles) with the file size and a hash of the file in the deps/*.d files.
The main PR is on cargo's repo: rust-lang/cargo#8623
This is to enable cargo to be able to use file sizes and content hashes as well as mtimes to both detect rapid changes that are currently missed and also to prevent compile cascades where mtimes have been altered but no actual change to the content occured (E.g. docker layers typically don't store precise times or copying a target dir from one place to another).
It seems that the hashes are already being calculated in the compiler so this is almost zero cost to rustc - the changes are:
.rlib
,lib.rmeta
is renamed tolibcrate_name-svh.rmeta
.rmeta
files we add the svh to a known location in the uncompressed header.(For outanding points please see the cargo PR. For binary file tracking we build on #63012 )