Stream: general

Topic: Breaking change, `eh_unwind_resume` removed


Elichai Turkel (Mar 29 2020 at 13:06, on Zulip):

Previously no-std working code had to define a eh_personality lang item. now this code doesn't compile with:
definition of unknown language item eh_unwind_resume`.
Example: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=9df0b520f99f60d369d2fc3a331b5b42

Example in the wild: https://travis-ci.org/github/rust-bitcoin/rust-secp256k1/jobs/666330964#L1175

I think this was introduced here: https://github.com/rust-lang/rust/pull/67502

Elichai Turkel (Mar 29 2020 at 13:06, on Zulip):

It seems the same is true for eh_unwind_resume

bjorn3 (Mar 29 2020 at 13:09, on Zulip):

Removing fn rust_eh_unwind_resume fixes the issue.

simulacrum (Mar 29 2020 at 13:12, on Zulip):

I believe just dropping the function should work, yes.

Elichai Turkel (Mar 29 2020 at 13:15, on Zulip):

I know. just wanted to raise awareness to that fact :)

RalfJ (Mar 29 2020 at 13:41, on Zulip):

I mean lang items are entirely internal to the compiler, it's no surprise code breaks when it depends on them

RalfJ (Mar 29 2020 at 13:42, on Zulip):

this is no more a "breaking change" (in the semver sense) than e.g. removing/changing an intrinsic

Elichai Turkel (Mar 29 2020 at 14:00, on Zulip):

You're right. but because these lang items were required for any no-std/embedded use, it's a bit more suprising to see code break without hearing about their removal (and I consider myself pretty much up to date for someone who isn't a compiler dev)

RalfJ (Mar 29 2020 at 14:04, on Zulip):

So maybe it would be a good idea to post about this on IRLO or so?

centril (Mar 29 2020 at 14:04, on Zulip):

No hurt in doing that

RalfJ (Mar 29 2020 at 14:05, on Zulip):

are there stable things people should do instead these days?

Jonas Schievink (Mar 29 2020 at 14:05, on Zulip):

Unstable features haven't been required for a while now, your entire no_std_test can probably be made to work on stable

RalfJ (Mar 29 2020 at 14:05, on Zulip):

(something something #[panic_handler])

Jonas Schievink (Mar 29 2020 at 14:05, on Zulip):

(for no_std/embedded use that is)

RalfJ (Mar 29 2020 at 14:05, on Zulip):

if so, the IRLO post could mention that

XAMPPRocky (Mar 29 2020 at 14:14, on Zulip):

@RalfJ Depending on the scale of the breakage it would also be good to post about it on the "Inside Rust" blog.

Amanieu (Mar 29 2020 at 14:14, on Zulip):

I doubt the breakage is that significant.

Amanieu (Mar 29 2020 at 14:15, on Zulip):

The eh_unwind_resume lang item was only required on windows-gnu targets.

Elichai Turkel (Mar 29 2020 at 14:17, on Zulip):

When I wrote that test it failed when I didn't implement those lang items

XAMPPRocky (Mar 29 2020 at 14:19, on Zulip):

@Amanieu I can't speak to this particular case. I was more saying in the future, consider writing an Inside Rust post about the nightly breaking changes if they are significant.

Amanieu (Mar 29 2020 at 14:20, on Zulip):

I would definitely expect a post about the asm! to llvm_asm! renaming since that's a pretty significant change.

Elichai Turkel (Mar 29 2020 at 14:20, on Zulip):

Jonas Schievink said:

Unstable features haven't been required for a while now, your entire no_std_test can probably be made to work on stable

Even start doesn't work on stable

error[E0658]: `#[start]` functions are experimental and their signature may change over time
Jonas Schievink (Mar 29 2020 at 14:24, on Zulip):

I didn't mean to say it'll work on stable by just removing the feature gates

Elichai Turkel (Mar 29 2020 at 14:25, on Zulip):

Amanieu said:

I would definitely expect a post about the asm! to llvm_asm! renaming since that's a pretty significant change.

Even trying to make this work on current stable I very fast get this linker error:
/usr/bin/ld: /home/elichai2/gits/rust-secp256k1/no_std_test/target/debug/deps/no_std_test-1cf5bdb9b6995360.22glz8jg3lucse6p.rcgu.o:(.data.DW.ref.rust_eh_personality[DW.ref.rust_eh_personality]+0x0): undefined reference to rust_eh_personality'`

Elichai Turkel (Mar 29 2020 at 14:25, on Zulip):

Jonas Schievink said:

I didn't mean to say it'll work on stable by just removing the feature gates

Would appreciate an example of how :)

Jonas Schievink (Mar 29 2020 at 14:30, on Zulip):

Seems like targets that ship libstd do require the start lang item (unsure why though), but the rest of the features can be removed

Elichai Turkel (Mar 29 2020 at 14:31, on Zulip):

Can I remove the start feature?

Jonas Schievink (Mar 29 2020 at 14:34, on Zulip):

Not while building for a target with libstd, at least I don't think so

Jonas Schievink (Mar 29 2020 at 14:55, on Zulip):

Ah, nevermind, I forgot about #![no_main]

#![no_std]
#![no_main]

use core::panic::PanicInfo;

#[link(name = "c")]
extern {
    fn exit(code: i32);
}

#[no_mangle]
fn main() {
    unsafe {
        exit(0);
    }
}

#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
    loop {
        continue;
    }
}

Build with rustc -Cpanic=abort main.rs

Amanieu (Mar 29 2020 at 15:01, on Zulip):

@Elichai Turkel Only the eh_unwind_resume target feature got removed. There was no change to eh_personality.

Elichai Turkel (Mar 29 2020 at 15:11, on Zulip):

@Amanieu You're right I somehow got confused here

Last update: May 29 2020 at 18:00UTC