rust: Add whole_static_libs, revert static_lib
Revert the static_lib behavior to the previous behavior (pass static
libs to the linker rather than via to rustc using `-lstatic=<lib>`). To
bundle static libraries into libraries, provide the whole_static_libs
property which retains the current static_libs behavior.
Passing all static libraries via -lstatic was resulting in odd bloat
where in some cases static symbols were duplicated in binaries and
libraries. This split makes it possible to be explicit about when static
libraries should be bundled.
Bug: 183182230
Test: mma system/bt; mma system/security/keystore2; mma external/rust
Change-Id: Ic2dde5d1542dca5ce145aa3a3fbd9ea54440d991
diff --git a/rust/rust_test.go b/rust/rust_test.go
index bed28ec..418bd93 100644
--- a/rust/rust_test.go
+++ b/rust/rust_test.go
@@ -149,6 +149,11 @@
srcs: ["foo.rs"],
crate_name: "static",
}
+ rust_ffi_host_static {
+ name: "libwholestatic",
+ srcs: ["foo.rs"],
+ crate_name: "wholestatic",
+ }
rust_ffi_host_shared {
name: "libshared",
srcs: ["foo.rs"],
@@ -164,6 +169,7 @@
srcs: ["foo.rs"],
crate_name: "rlib",
static_libs: ["libstatic"],
+ whole_static_libs: ["libwholestatic"],
}
rust_proc_macro {
name: "libpm",
@@ -204,8 +210,8 @@
t.Errorf("Static library dependency not detected (dependency missing from AndroidMkStaticLibs)")
}
- if !strings.Contains(rustc.Args["rustcFlags"], "-lstatic=static") {
- t.Errorf("-lstatic flag not being passed to rustc for static library")
+ if !strings.Contains(rustc.Args["rustcFlags"], "-lstatic=wholestatic") {
+ t.Errorf("-lstatic flag not being passed to rustc for static library %#v", rustc.Args["rustcFlags"])
}
}