Rust_begin_unwind从Rust 1.11到1.12的变化是什么?

fgh*_*ghj 11 rust

在1.12 beta期间,我为Android构建并运行了这个代码而没有任何问题:

[package]
name = "android"
version = "0.1.0"
authors = ["Author <mail@email.com>"]
build = "build.rs"

[lib]
name = "mylib"
crate-type = ["cdylib"]
Run Code Online (Sandbox Code Playgroud)

我使用rustup和rustup target add arm-linux-androideabi.

现在,当我从Java代码加载Rust 1.12库时,我得到:

java.lang.UnsatisfiedLinkError:dlopen失败:找不到符号"rust_begin_unwind"

要暂时解决此问题,我需要一个解决方法:

#[allow(unused_variables)]
#[no_mangle]
pub extern
fn rust_begin_unwind(fmt: ::std::fmt::Arguments, file: &'static str, line: u32) -> ! {
    loop {}
}
Run Code Online (Sandbox Code Playgroud)
  1. 为什么在Android平台上无法解开?
  2. 如何正确解决这个问题?调试时,我希望在Android IDE日志窗口中看到完整的堆栈跟踪.

Jac*_*ips 1

Rust 1.12 引入了 MIR(中级中间表示),这是编译器使用的机器代码的新翻译。我对此了解不多,但它显然主要集中在控制流上,而且rust_begin_unwind 听起来很可能受到了影响。

https://blog.rust-lang.org/2016/09/29/Rust-1.12.html#mir-code- Generation