-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add version header to -Zno-link .rlink files #95297
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
Comments
To clarify: here's what I thought you had to do:
But that gives an inscrutable error like this:
The correct way to invoke is actually this
If the |
@nnethercote I tried to look at this. I see several solutions to this:
What do you suggest, solution 2)? |
The crate metadata encodes and decodes the header separately from the contents. For crate metadata the header is of the form "rust" + 32bit be version number (currently 5 I believe) + 32bit offset of the crate root + rustc version string. During decoding the header is checked for "rust", the right version number and then the right rustc version. Only after that is a rust/compiler/rustc_metadata/src/rmeta/encoder.rs Lines 2173 to 2177 in 07a461a
rust/compiler/rustc_metadata/src/rmeta/encoder.rs Lines 2201 to 2202 in 07a461a
The rlink header could work the same way except omitting the offset of the crate root and using say "rsld" (rust ld) or "rustlink" as start instead of "rust" like the crate metadata. |
Thanks for the hint. I checked rmeta decoding and it basically decodes the magic header byte slice with So with this approach we could have a nice error if header magic is missing, nice error if rust version is wrong, but weird error if rust version if missing. That is basically the same that we get for |
Yeah, the header magic is supposed to be changed every time the rustc version needs to be decoded in a different way.
IMO it is ok. |
This allows giving a better error when attempting to use the original source file with -Zlink-only rather than crashing and allows rejecting rlink files produced by a different rustc version.
The text was updated successfully, but these errors were encountered: