Skip to content

Undefined reference to core::panicking::panic #245

Closed
@BartMassey

Description

@BartMassey

I have a little crate at http://gitlab.com/BartMassey/mixy that I have been compiling on Debian Linux x86-64 as a demo of providing Rust functions to C code. I'm using nightly Rust so that I can use lang_items to make no_std and no_builtins work.

Today I discovered the "--emit=obj" compiler option and decided to try it out. Compiled fine, but at the link stage (using gcc) I got

    rusty.o: In function `rust_add': rusty0-8787f43e282added376259c1adb08b80.rs (.text.rust_add+0x1c): undefined reference to `core::panicking::panic'

After discovering issue #79, I tried rustc -O and it worked.

I'm sure the panic in the not -O case is because rustc is checking the addition for overflow and planning to panic if it did. I'm hoping there's some way I can wire that panic to a hard abort, because in more complicated cases it would be a pain to rewrite all the arithmetic and besides checking adds in debug mode seems nice. Honestly, I would prefer to at least be able to check them in release code also.

I'm probably all kinds of confused, and reporting to the wrong place besides, but given the possible regression I thought it was at least worth mentioning here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions