-
Notifications
You must be signed in to change notification settings - Fork 229
Undefined reference to core::panicking::panic #245
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
Comments
Got the repo URL for mixy wrong above. Fixed now. |
Ah currently this library requires to always be built with optimization, I don't think it works unoptimized yet |
Sorry, I kind of screwed up the bug report. Here's the source file in question, just so I'm sure we're talking about the same thing. //! Copyright © 2016 Bart Massey
//!
//! [This program is licensed under the "MIT License"]
//! Please see the file COPYING in the source distribution
//! of this software for license terms.
//!
//! Demonstrate making statically-linked rust
//! functions available to C.
#![crate_type="staticlib"]
#![feature(lang_items)]
#![no_std]
#![no_builtins]
#[no_mangle]
pub extern "system" fn rust_add(a: i32, b: i32) -> i32 {
a + b
}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"] #[no_mangle] pub fn panic_fmt() -> ! { loop {} } The only undefined symbol when this is compiled with checked arithmetic is I totally get that this might require a panic; if there's nothing that can be done about that, so be it. What would be nice would be some rustic way to map that |
@BartMassey have you tried compiling with |
@alexcrichton Had forgotten Interestingly, if I put in an explicit panic the rust code still tries to call I found this https://github.com/japaric/panic-abort/blob/master/src/lib.rs, but it doesn't seem to make Are the Rust name mangling rules documented somewhere? |
@BartMassey hm ok, I think I may be confusing myself. If you're using The name mangling rules are currently an internal implementation detail and aren't a stable interface to rely on. Do you have a script or such to reproduce this as well that I could help poke around in? |
http://gitlab.com/BartMassey/mixy is what I'm currently playing with. It has rather a lot of branches, and is kind of a mess right now. Let me know what you want and I'll be happy to do some scripting or something for you. It sounds like it's really my bug at this point, and maybe there's no clean way to work around it.
Anyway, I should quit wasting your time with this. Thanks much for all your help and patience! |
@BartMassey sorry was away on vacation but am back now, in that example it's definitely invalid to use |
I'm going to close this now because I think this is likely related to compilation issues with this library rather than the source itself. |
Thank you so much, you solved all my problems !! |
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 makeno_std
andno_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
After discovering issue #79, I tried
rustc -O
and it worked.I'm sure the panic in the not
-O
case is becauserustc
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.
The text was updated successfully, but these errors were encountered: