Link device binaries dynamically by default.

Device binaries currently are linked statically by default. Instead we
should be linking these dynamic by default. To avoid conflicts when
manually specifying rlib dependencies on modules, we always link libstd
dynamically for all device modules except static libraries.

This removes the "prefer_dynamic" property entirely to avoid confusion.

Bug: 165161105
Test: m profcollectd is built dynamically.
Test: cd external/rust/; mma
Test: cd external/crosvm/; mma
Change-Id: I25ac897040acbcc2d97c791a33e8e01610632272
This commit is contained in:
Ivan Lozano
2020-08-18 14:31:23 -04:00
parent f5a2b8a641
commit 042504f7d6
9 changed files with 112 additions and 44 deletions

View File

@@ -144,6 +144,22 @@ func TestSharedLibrary(t *testing.T) {
}
}
func TestStaticLibraryLinkage(t *testing.T) {
ctx := testRust(t, `
rust_ffi_static {
name: "libfoo",
srcs: ["foo.rs"],
crate_name: "foo",
}`)
libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_static")
if !android.InList("libstd", libfoo.Module().(*Module).Properties.AndroidMkRlibs) {
t.Errorf("Static libstd rlib expected to be a dependency of Rust static libraries. Rlib deps are: %#v",
libfoo.Module().(*Module).Properties.AndroidMkDylibs)
}
}
// Test that variants pull in the right type of rustlib autodep
func TestAutoDeps(t *testing.T) {