-
Notifications
You must be signed in to change notification settings - Fork 7
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
uniffi-rs errors reading from large release staticlib ELF binaries #122
Comments
We primarily build release, to avoid the extra disk space. But I haven't run the latest version and we have a slightly modified build script still. I will test tomorrow to confirm against main. |
Doing the same for iOS works, interestingly, as As a workaround one can just build for both platforms and then run
|
Hm, interesting. I'm not sure if it matters but I'm on |
So I've tried
Judging by the error message, it stems from https://github.com/mozilla/uniffi-rs/blob/438778213f6014dc44204acd3e6b92c29b439405/uniffi_bindgen/src/macro_metadata/extract.rs#L149. So might not actually be a UBRN issue. |
I don't recall seeing this yesterday but I might have just missed it. It appears to originate from https://github.com/mozilla/uniffi-rs/blob/438778213f6014dc44204acd3e6b92c29b439405/uniffi_meta/src/reader.rs#L62. |
@Johennes Are you still seeing this? |
I tried rebuilding and regenerating matrix-rust-sdk@matrix-sdk-ffi/20241008 with UBRN from current |
Stack trace from reproduction: Error: Failed to extract data from archive member `matrix_sdk_ffi.matrix_sdk_ffi.bf8c76dbb4572677-cgu.07.rcgu.o`
Caused by:
Unexpected metadata code: 88
Stack backtrace:
0: std::backtrace_rs::backtrace::libunwind::trace
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
1: std::backtrace_rs::backtrace::trace_unsynchronized
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: std::backtrace::Backtrace::create
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/backtrace.rs:331:13
3: anyhow::error::<impl anyhow::Error>::msg
at /Users/jhugman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.86/src/backtrace.rs:27:14
4: anyhow::__private::format_err
at /Users/jhugman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.86/src/lib.rs:692:13
5: uniffi_meta::reader::MetadataReader::read_metadata
at /Users/jhugman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/uniffi_meta-0.28.0/src/reader.rs:62:18
6: uniffi_meta::reader::read_metadata
at /Users/jhugman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/uniffi_meta-0.28.0/src/reader.rs:10:5
7: uniffi_meta::Metadata::read
at /Users/jhugman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/uniffi_meta-0.28.0/src/lib.rs:485:9
8: uniffi_bindgen::macro_metadata::extract::ExtractedItems::extract_item
at /Users/jhugman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/uniffi_bindgen-0.28.0/src/macro_metadata/extract.rs:178:25
9: uniffi_bindgen::macro_metadata::extract::extract_from_elf
at /Users/jhugman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/uniffi_bindgen-0.28.0/src/macro_metadata/extract.rs:53:13
10: uniffi_bindgen::macro_metadata::extract::extract_from_bytes
at /Users/jhugman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/uniffi_bindgen-0.28.0/src/macro_metadata/extract.rs:29:29
11: uniffi_bindgen::macro_metadata::extract::extract_from_archive
at /Users/jhugman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/uniffi_bindgen-0.28.0/src/macro_metadata/extract.rs:138:18
12: uniffi_bindgen::macro_metadata::extract::extract_from_bytes
at /Users/jhugman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/uniffi_bindgen-0.28.0/src/macro_metadata/extract.rs:32:37
13: uniffi_bindgen::macro_metadata::extract::extract_from_library
at /Users/jhugman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/uniffi_bindgen-0.28.0/src/macro_metadata/extract.rs:24:5
14: uniffi_bindgen::library_mode::find_components
at /Users/jhugman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/uniffi_bindgen-0.28.0/src/library_mode.rs:108:17
15: uniffi_bindgen::library_mode::generate_bindings
at /Users/jhugman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/uniffi_bindgen-0.28.0/src/library_mode.rs:49:26
16: ubrn_bindgen::bindings::BindingsArgs::run
at /Users/jhugman/workspaces/react-native-uniffi/work/uniffi-bindgen-react-native/crates/ubrn_bindgen/src/bindings/mod.rs:127:13
17: uniffi_bindgen_react_native::generate::GenerateAllCommand::run
at /Users/jhugman/workspaces/react-native-uniffi/work/uniffi-bindgen-react-native/crates/ubrn_cli/src/generate.rs:122:13
18: uniffi_bindgen_react_native::generate::GenerateCmd::run
at /Users/jhugman/workspaces/react-native-uniffi/work/uniffi-bindgen-react-native/crates/ubrn_cli/src/generate.rs:52:17
19: uniffi_bindgen_react_native::generate::GenerateArgs::run
at /Users/jhugman/workspaces/react-native-uniffi/work/uniffi-bindgen-react-native/crates/ubrn_cli/src/generate.rs:22:9
20: uniffi_bindgen_react_native::cli::CliCmd::run
at /Users/jhugman/workspaces/react-native-uniffi/work/uniffi-bindgen-react-native/crates/ubrn_cli/src/cli.rs:40:34
21: uniffi_bindgen_react_native::main
at /Users/jhugman/workspaces/react-native-uniffi/work/uniffi-bindgen-react-native/crates/ubrn_cli/src/main.rs:24:5
22: core::ops::function::FnOnce::call_once
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:250:5
23: std::sys::backtrace::__rust_begin_short_backtrace
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:152:18
24: std::rt::lang_start::{{closure}}
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:162:18
25: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:284:13
26: std::panicking::try::do_call
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:557:40
27: std::panicking::try
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:521:19
28: std::panic::catch_unwind
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panic.rs:350:14
29: std::rt::lang_start_internal::{{closure}}
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:141:48
30: std::panicking::try::do_call
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:557:40
31: std::panicking::try
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:521:19
32: std::panic::catch_unwind
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panic.rs:350:14
33: std::rt::lang_start_internal
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:141:20
34: std::rt::lang_start
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:161:17
35: _main |
Trying to characterize this issue with the given YAML. Once checked out, I'm building the matrix library, from within the Then feeding the resulting lib into the bundled This works: $ cargo run --manifest-path uniffi-bindgen/Cargo.toml -- generate --language kotlin --library target/aarch64-linux-android/release/libmatrix_sdk_ffi.so --out-dir kt We can also get swift to generate from this same library: $ cargo run --manifest-path uniffi-bindgen/Cargo.toml -- generate --language switt --library target/aarch64-linux-android/release/libmatrix_sdk_ffi.so --out-dir swift Swift is normally generated from a We seem to be having problems with the reading of staticlib release builds; we'd expect this to work, even though it's a build for a different architecture. However: $ cargo run --manifest-path uniffi-bindgen/Cargo.toml -- generate --language swift --library target/aarch64-linux-android/release/libmatrix_sdk_ffi.a --out-dir swift
Finished `dev` profile [unoptimized] target(s) in 0.11s
Running `target/debug/uniffi-bindgen generate --language swift --library target/aarch64-linux-android/release/libmatrix_sdk_ffi.a --out-dir swift`
Failed to extract data from archive member `matrix_sdk_ffi.matrix_sdk_ffi.bf8c76dbb4572677-cgu.07.rcgu.o` The $ cargo run --manifest-path uniffi-bindgen/Cargo.toml -- generate --language swift --library target/aarch64-linux-android/debug/libmatrix_sdk_
ffi.a --out-dir swift
Finished `dev` profile [unoptimized] target(s) in 0.11s
Running `target/debug/uniffi-bindgen generate --language swift --library target/aarch64-linux-android/debug/libmatrix_sdk_ffi.a --out-dir swift` So, what is different about the I'd also like to reduce the size of the library that is being built: @Johennes has reported Caused by:
Unexpected metadata code: 255 and I am now seeing: Caused by:
Unexpected metadata code: 88 |
I think we're firmly in the territory of "not holding it wrong, but not holding it as expected". Cutting out cd /private/tmp/turbomodule-tests/122-repro/rust_modules/matrix-rust-sdk/bindings/matrix-sdk-ffi && \
cargo ndk \
--manifest-path /private/tmp/turbomodule-tests/122-repro/rust_modules/matrix-rust-sdk/bindings/matrix-sdk-ffi/Cargo.toml \
--target arm64-v8a \
--platform 21 --no-strip -- \
build --release I have lightly instrumented And here is the output from Metadata symbol UNIFFI_META_MATRIX_SDK_FFI_INTERFACE_ENCRYPTION
thread 'main' panicked at uniffi_meta/src/metadata.rs:84:18:
XXXX UNKNOWN ITEM 88 XXXX
stack backtrace:
0: rust_begin_unwind
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/std/src/panicking.rs:647:5
1: core::panicking::panic_fmt
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/core/src/panicking.rs:72:14
2: uniffi_meta::metadata::codes::metadata_as_str
at ./uniffi_meta/src/metadata.rs:84:18
3: uniffi_meta::reader::MetadataReader::read_metadata
at ./uniffi_meta/src/reader.rs:39:33
4: uniffi_meta::reader::read_metadata
at ./uniffi_meta/src/reader.rs:10:5
5: uniffi_meta::Metadata::read
at ./uniffi_meta/src/lib.rs:505:9
6: uniffi_bindgen::macro_metadata::extract::ExtractedItems::extract_item
at ./uniffi_bindgen/src/macro_metadata/extract.rs:184:25
7: uniffi_bindgen::macro_metadata::extract::extract_from_elf
at ./uniffi_bindgen/src/macro_metadata/extract.rs:53:13
8: uniffi_bindgen::macro_metadata::extract::extract_from_bytes
at ./uniffi_bindgen/src/macro_metadata/extract.rs:29:29
9: uniffi_bindgen::macro_metadata::extract::extract_from_archive
at ./uniffi_bindgen/src/macro_metadata/extract.rs:143:18
10: uniffi_bindgen::macro_metadata::extract::extract_from_bytes
at ./uniffi_bindgen/src/macro_metadata/extract.rs:32:37
11: uniffi_bindgen::macro_metadata::extract::extract_from_library
at ./uniffi_bindgen/src/macro_metadata/extract.rs:24:5
12: uniffi_bindgen::library_mode::find_components
at ./uniffi_bindgen/src/library_mode.rs:104:17
13: uniffi_bindgen::library_mode::generate_bindings
at ./uniffi_bindgen/src/library_mode.rs:46:26
14: uniffi::cli::uniffi_bindgen::gen_library_mode
at ./uniffi/src/cli/uniffi_bindgen.rs:207:38
15: uniffi::cli::uniffi_bindgen::run_main
at ./uniffi/src/cli/uniffi_bindgen.rs:297:17
16: uniffi::cli::uniffi_bindgen_main
at ./uniffi/src/cli/mod.rs:9:21
17: uniffi_bindgen::main
at ./cli/src/main.rs:2:5
18: core::ops::function::FnOnce::call_once
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. i.e. it seems to be failing at the first metadata symbol I don't |
This will be fixed by mozilla/uniffi-rs#2286. |
With UBRN from 7afb49b and the following
ubrn.yaml
yarn ubrn build android --release --config ubrn.yaml --and-generate
fails for me:@zzorba have you tried UBRN on the Rust SDK in release mode yet by any chance?
The text was updated successfully, but these errors were encountered: