-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
#![no_std] results in linker errors for debug builds that use Drop due to _rust_eh_personality #47442
Comments
It looks like this was introduced between 2017-12-02 (f9b0897) and 2017-12-03 (1956d55):
|
cc @arielb1 Unfortunately I don't know how to fix this. I'm not familiar enough with the compiler internals to be of much help other than this initial triage. |
I don't think this way of avoiding linking against the exception handling code is officially supported ( Nevertheless, we only emit |
For example, if a tuple is used like in this code, then a landing pad is created in all modern versions of rustc - that is needed to handle the case where #![feature(lang_items, start)]
#![no_std]
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }
struct Foo {}
impl core::ops::Drop for Foo {
fn drop(&mut self) {
}
}
#[start]
fn main(_argc: isize, _argv: *const *const u8) -> isize {
let _foo = (Foo {}, Foo {}); // note change here
return 0;
} |
Compiling everything (including libcore) with panic=abort should be reliable, right? |
Sure that should work. Even just compiling the problem I just remembered the tiptoing around exceptions in the context of |
These are already removed in the normal optimization pipeline - so this should slightly improve codegen performance, as these cleanup blocks are known to hurt LLVM. This un-regresses and is therefore a fix for rust-lang#47442. However, the reporter of that issue should try using `-C panic=abort` instead of carefully avoiding panics.
Thanks for looking into this so quickly! Using |
remove noop landing pads in cleanup shims No-op landing pads are already removed in the normal optimization pipeline - so also removing them on the shim pipeline should slightly improve codegen performance, as these cleanup blocks are known to hurt LLVM. This un-regresses and is therefore a fix for rust-lang#47442. However, the reporter of that issue should try using `-C panic=abort` instead of carefully avoiding panics. r? @eddyb
remove noop landing pads in cleanup shims No-op landing pads are already removed in the normal optimization pipeline - so also removing them on the shim pipeline should slightly improve codegen performance, as these cleanup blocks are known to hurt LLVM. This un-regresses and is therefore a fix for rust-lang#47442. However, the reporter of that issue should try using `-C panic=abort` instead of carefully avoiding panics. r? @eddyb
This is no longer an issue. |
The following simple program fails to compile with Rust because the
Drop
trait introduces an incompatibility that causes a linker error. If you comment out theimpl
block, then it will work just fine. Additionally, if you compile with optimizations turned on, it will work just fine. But if you compile the following without optimizations, it will fail.t.rs:
The error: (part of the paths have been redacted;
<RUSTUP>
is the installation directory forrustup
)Rust version:
Note: Building with optimizations on works, presumably because the optimizer is able to optimize away the call to
core::ptr::drop_in_place
(which is tagged with.cfi_personality 155, _rust_eh_personality
in the generated debug assembly, which I presume is the source of the problem):My system: macOS 10.13.2.
rustc
is installed fromrustup
.The text was updated successfully, but these errors were encountered: