Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding multiple static Rust libraries in an iOS app

I have two libraries (with C compatible interface) written in Rust that I'm trying to integrate into an iOS app.

When integrating the two .a files in the same project, I get errors because symbols from the Rust standard library are now present multiple times:

duplicate symbol _rust_eh_personality in:
    /Users/x/Development/ios-client/Y/Rust/lib1_ffi.a(lib1_ffi.0.o)
    /Users/x/Development/ios-client/Y/Rust/lib2_ffi.a(lib2_ffi.0.o)
...

How can this be solved? Could the Rust symbols be extracted into a separate library? Or can the symbols be namespaced?

like image 553
Danilo Bargen Avatar asked Oct 04 '17 15:10

Danilo Bargen


1 Answers

At the time of this posting, the prevalent theory is that this issue occurs when Link-Time Optimization (LTO) is enabled and is caused by a bug in the static libraries that rustc produces (link).

As a temporary measure, it has been suggested that LTO should not be enabled until this issue has been resolved.

like image 127
Doe Avatar answered Oct 21 '22 07:10

Doe