From 231922802741afaf17e053f6ca14279b87115e92 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Wed, 17 Jul 2024 17:40:19 -0700 Subject: [PATCH] android: Don't strip debug info out of the AAR This *greatly* increases the size of the artifacts uploaded to Maven, but it looks like the libraries do correctly get stripped when the final APK is built. (This was not true in the past.) Also, make sure the built library includes a "build ID", or else the stripped version of the library will be treated as a different library, and all the line tables will go to waste. --- java/android/build.gradle | 2 ++ rust/bridge/jni/build.rs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/java/android/build.gradle b/java/android/build.gradle index edba9df7..7405a6dc 100644 --- a/java/android/build.gradle +++ b/java/android/build.gradle @@ -54,6 +54,8 @@ android { pickFirst 'lib/*/libsignal_jni.so' pickFirst 'lib/*/libsignal_jni_testing.so' } + // Defer stripping to the Android app project. + doNotStrip '**/*.so' } publishing { diff --git a/rust/bridge/jni/build.rs b/rust/bridge/jni/build.rs index 9f7bcfc4..457a6979 100644 --- a/rust/bridge/jni/build.rs +++ b/rust/bridge/jni/build.rs @@ -9,6 +9,9 @@ fn main() { if env::var("CARGO_CFG_TARGET_ARCH").expect("set by Cargo") == "aarch64" && env::var("CARGO_CFG_TARGET_OS").expect("set by Cargo") == "android" { + // --build-id ensures that Android Studio's LLDB can map stripped binaries back to their debug info + println!("cargo:rustc-cdylib-link-arg=-Wl,--build-id"); + // HACK: Force libdl to be linked. // Something about the Docker-based build results in it getting skipped; // if we figure out what, we can remove this.