-
Notifications
You must be signed in to change notification settings - Fork 13.3k
deduplicate abort implementations #139103
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
base: master
Are you sure you want to change the base?
Conversation
Currently, the code for process aborts is duplicated across `panic_abort` and `std`. This PR uses `#[rustc_std_internal_symbol]` to make the `std` implementation available to `panic_abort` via the linker, thereby deduplicating the code.
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
This comment has been minimized.
This comment has been minimized.
The Miri subtree was changed cc @rust-lang/miri |
The job Click to see the possible cause of the failure (guessed by this bot)
|
/// In Windows 8 and later, this will terminate the process immediately without | ||
/// running any in-process exception handlers. In earlier versions of Windows, | ||
/// this sequence of instructions will be treated as an access violation, | ||
/// terminating the process but without necessarily bypassing all exception | ||
/// handlers. |
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.
/// In Windows 8 and later, this will terminate the process immediately without | |
/// running any in-process exception handlers. In earlier versions of Windows, | |
/// this sequence of instructions will be treated as an access violation, | |
/// terminating the process but without necessarily bypassing all exception | |
/// handlers. | |
/// In Windows 8 and later, this will terminate the process immediately, | |
/// bypassing all in-process exception handlers. In earlier versions of Windows, | |
/// this sequence of instructions will be treated as an access violation, | |
/// terminating the process but without necessarily bypassing all exception | |
/// handlers. |
Let's use the same verb both times, otherwise this is unnecessarily confusing since it uses "without" twice to actually make statements that are opposites of each other.
@@ -1,6 +1,6 @@ | |||
//@error-in-other-file: the program aborted execution | |||
//@normalize-stderr-test: "\| +\^+" -> "| ^" | |||
//@normalize-stderr-test: "unsafe \{ libc::abort\(\); \}|core::intrinsics::abort\(\);" -> "ABORT();" | |||
//@normalize-stderr-test: "unsafe \{ libc::abort\(\) \}|core::intrinsics::abort\(\)" -> "ABORT()" |
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.
//@normalize-stderr-test: "unsafe \{ libc::abort\(\) \}|core::intrinsics::abort\(\)" -> "ABORT()" | |
//@normalize-stderr-test: "unsafe \{ libc::abort\(\) \}|crate::intrinsics::abort\(\)" -> "ABORT()" |
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.
// Note: contrary to the `__rust_abort` in `crate::rt`, this uses `no_mangle` | ||
// because it is actually used from C code. Because symbols annotated with | ||
// #[rustc_std_internal_symbol] get mangled, this will not lead to linker | ||
// conflicts. |
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.
Could they get different symbol names? Having the same extern signature reused but distinguished by attributes is a bit tricky.
Reminder, once the PR becomes ready for a review, use |
Makes sense for now. In the future maybe we could make panic_abort and panic_unwind depend on std rather than the other way around. Both of them are only used with std, but currently std has a kind of weak dependency on panic_abort and panic_unwind where both get registered into the crate store (and thus for example participate in the duplicate lang item check), but only one of the two will actually "activated" and end up getting linked in the end. Flipping the dependency around would allow getting rid of this weird dependency state and allow directly using libstd symbols from both crates. |
☔ The latest upstream changes (presumably #139746) made this pull request unmergeable. Please resolve the merge conflicts. |
Currently, the code for process aborts is duplicated across
panic_abort
andstd
. This PR uses#[rustc_std_internal_symbol]
to make thestd
implementation available topanic_abort
via the linker, thereby deduplicating the code.