-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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 compressed rmeta contain compressed data length after header #101550
Conversation
r? @fee1-dead (rust-highfive has picked a reviewer for you, use r? to override) |
r? rust-lang/compiler |
Can rust not be made more resilient to zero padding in |
r? @ehuss (commented on the issue) |
It may be possible to do that, but I'm not sure it's the best path forwards - I imagine it would effectively be removing some sanity checks on the length of the compressed data, and instead just decompressing the first N bytes. This is only a guess though, as I'm not actually incredibly familiar with how rustc does its compressed metadata writing. |
I also feel I should note that, as far as I'm aware, either only the Windows linker does this, or we already tell other linkers not to. I wouldn't consider this change to be working against linker expectations in general, just disabling a slightly odd behavior on Windows (I wouldn't think adding extra null bytes to unrecognized sections is, in general, a safe thing to do) |
Maybe only disable it for the dylib and proc-macro crate types? bin and cdylib don't have crate metadata. |
On the other hand there are crates which use custom sections that will likely break with padding too. For example inventory. |
I am almost certainly not the right person to review this. I do not know what the implications are of disabling incremental linking. Is there anyone on the compiler team familiar with linking ( I also wonder if a better solution would be to track the length of the compressed data instead of assuming the section data length is correct? The It also seems a little surprising that the linker is padding a section. I wonder if it is related to this:
Perhaps they always feel at liberty to pad things? |
Only the literal represented by rust/compiler/rustc_codegen_ssa/src/back/metadata.rs Lines 281 to 282 in addacb5
|
Ah, I misread that about the position. But I assume those lines could be changed to something like: let mut compressed = rustc_metadata::METADATA_HEADER.to_vec();
compressed.write_all(length).unwrap();
FrameEncoder::new(&mut compressed).write_all(metadata.raw_data()).unwrap(); where |
That should work. Rust-analyzer will need to be updated to reflect this in the proc macro loading code though. |
I'll work on making the necessary changes, since it seems like consensus is that supporting this is worth the change. Should I make a PR to rust-analyzer in sync with this change? |
Rust-analyzer is now a subtree, so you could make the changes in the same PR to this repo. Make sure to keep support for the current format though. |
By reading the latest comments it seems this PR will be waiting on work happening on rust-analyzer. I'll signal this with @rustbot author |
r? @wesleywiser |
@ehuss @CraftSpider If you do this change, don't forget to bump the (small) version number in |
I'll make sure to do so, I did start on implementing this change. I'll push an update once I have something working hopefully. |
@CraftSpider any updates on this? |
23309e3
to
22c80a0
Compare
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.
Compiler changes look good to me!
The rust-analyzer changes were merged in rust-lang/rust-analyzer#14153, but we'll double-check once this hits nightly. |
@rustbot label: -S-waiting-on-author +S-waiting-on-review |
Thanks @CraftSpider! @bors r+ |
@bors rollup=never let's get this out of the queue |
☀️ Test successful - checks-actions |
Finished benchmarking commit (a512c6c): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. |
…leywiser Make compressed rmeta contain compressed data length after header Fixes rust-lang#90056, which is caused by link.exe introducing padding to the `.rustc` section, since it assumes this will have no effect besides allowing it to possibly use the extra space in future links.
Fixes #90056, which is caused by link.exe introducing padding to the
.rustc
section, since it assumes this will have no effect besides allowing it to possibly use the extra space in future links.