From fe7b4bbcd8a77faca169e2b04ee4982f4ada6a13 Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Thu, 30 Mar 2023 15:53:33 +0000 Subject: Remove rlib restriction Unfortunately, static_assertions, despite being a compile time crate, does have code. This means that if you have libA depending on static_assertions and libB depending on static_assertions, A and B can't be dynamically linked into the same process with the rlib restriction. Test: mma Change-Id: If0c8e3b9eadef99dd4dc84c70243d2b2fcb3583e --- Android.bp | 2 +- cargo2android.json | 1 - patches/dylib-std.patch | 14 ++++++++++++++ src/lib.rs | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 patches/dylib-std.patch diff --git a/Android.bp b/Android.bp index 05a9aa3..1d545f3 100644 --- a/Android.bp +++ b/Android.bp @@ -20,7 +20,7 @@ license { ], } -rust_library_rlib { +rust_library { name: "libstatic_assertions", host_supported: true, crate_name: "static_assertions", diff --git a/cargo2android.json b/cargo2android.json index f41bf78..ac5389c 100644 --- a/cargo2android.json +++ b/cargo2android.json @@ -1,6 +1,5 @@ { "device": true, - "force-rlib": true, "no_pkg_vers": true, "min-sdk-version": "29", "vendor-available": true, diff --git a/patches/dylib-std.patch b/patches/dylib-std.patch new file mode 100644 index 0000000..7864526 --- /dev/null +++ b/patches/dylib-std.patch @@ -0,0 +1,14 @@ +diff --git a/src/lib.rs b/src/lib.rs +index aa7e227..df47529 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -101,6 +101,9 @@ + )] + #![no_std] + ++#[cfg(android_dylib)] ++extern crate std; ++ + #[cfg(feature = "proc_static_assertions")] + extern crate proc_static_assertions; + #[cfg(feature = "proc_static_assertions")] diff --git a/src/lib.rs b/src/lib.rs index aa7e227..df47529 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -101,6 +101,9 @@ )] #![no_std] +#[cfg(android_dylib)] +extern crate std; + #[cfg(feature = "proc_static_assertions")] extern crate proc_static_assertions; #[cfg(feature = "proc_static_assertions")] -- cgit v1.2.3