default all unknown weak extern statics to null#5015
Merged
Conversation
Collaborator
|
Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two. |
bjorn3
reviewed
May 11, 2026
| if extern_decl_layout.size != ecx.tcx.data_layout.pointer_size() { | ||
| throw_unsup_format!( | ||
| "`{link_name}` is a non-pointer-sized weak symbol, which is not supported by Miri", | ||
| ) |
Member
There was a problem hiding this comment.
I this wouldn't even typecheck: https://doc.rust-lang.org/nightly/error_codes/E0791.html
Member
Author
There was a problem hiding this comment.
Ah nice :) Then I can just make this panic.
8ff0aba to
4d8d0f7
Compare
Member
Author
|
All right, based on Zulip discussions and rust-lang/rust#156467, I'd say this is good to go. :) |
bjorn3
reviewed
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unfortunately we can't easily create a zero-filled allocation on-demand when encountering a weak extern. So instead we pre-allocate a ptr-sized null-filled allocation, and then make all ptr-sized weak externs aliases of that allocation. (Non-ptr-sized weak externs are just not supported for now.)
@bjorn3 does that seem like a plausible implementation strategy or is it silly?
In particular I wonder if LLVM is allowed to assume that different weak extern statics resolve to different addresses.