From 2b0811310eb79c98966220f2336fbd22bdef4110 Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Tue, 8 Sep 2020 12:46:52 -0400 Subject: rust: Add libstd linkage mutator for rlibs. The current state of linkage is that device targets always link libstd dynamically except for rust_ffi_static which requires a static libstd linkage. However this prevents producing rust_ffi_static modules which depend on other Rust libraries as those dependencies will link libstd dynamically and cause a collision. We also want our rust_test modules to statically link in libstd as well. This adds a linkage mutator for rlibs that creates a variant for each libstd linkage. Dependent modules can then select the variant that matches their linkage of libstd. Also fixes an issue where installation paths were being generated for rlibs and static libs even though they weren't being installed. This broke when adding the linkage mutator as Make would complain about multiple targets producing the same output. Bug: 168729404 Test: rust_ffi_static module with other rustlib dependency can be built. Change-Id: I955b484bf5809e8fc5517750c7f8df82d3ca8895 --- rust/rust_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'rust/rust_test.go') diff --git a/rust/rust_test.go b/rust/rust_test.go index 89ce35919..4842a4ca8 100644 --- a/rust/rust_test.go +++ b/rust/rust_test.go @@ -189,7 +189,7 @@ func TestDepsTracking(t *testing.T) { t.Errorf("Dylib dependency not detected (dependency missing from AndroidMkDylibs)") } - if !android.InList("librlib", module.Properties.AndroidMkRlibs) { + if !android.InList("librlib.rlib-std", module.Properties.AndroidMkRlibs) { t.Errorf("Rlib dependency not detected (dependency missing from AndroidMkRlibs)") } @@ -253,7 +253,7 @@ func TestSourceProviderDeps(t *testing.T) { } `) - libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_rlib").Rule("rustc") + libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_rlib_dylib-std").Rule("rustc") if !android.SuffixInList(libfoo.Implicits.Strings(), "/out/bindings.rs") { t.Errorf("rust_bindgen generated source not included as implicit input for libfoo; Implicits %#v", libfoo.Implicits.Strings()) } @@ -279,15 +279,15 @@ func TestSourceProviderDeps(t *testing.T) { // Check that our bindings are picked up as crate dependencies as well libfooMod := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_dylib").Module().(*Module) - if !android.InList("libbindings", libfooMod.Properties.AndroidMkRlibs) { + if !android.InList("libbindings.dylib-std", libfooMod.Properties.AndroidMkRlibs) { t.Errorf("bindgen dependency not detected as a rlib dependency (dependency missing from AndroidMkRlibs)") } fizzBuzzMod := ctx.ModuleForTests("fizz-buzz-dep", "android_arm64_armv8-a").Module().(*Module) - if !android.InList("libbindings", fizzBuzzMod.Properties.AndroidMkRlibs) { + if !android.InList("libbindings.dylib-std", fizzBuzzMod.Properties.AndroidMkRlibs) { t.Errorf("bindgen dependency not detected as a rlib dependency (dependency missing from AndroidMkRlibs)") } libprocmacroMod := ctx.ModuleForTests("libprocmacro", "linux_glibc_x86_64").Module().(*Module) - if !android.InList("libbindings", libprocmacroMod.Properties.AndroidMkRlibs) { + if !android.InList("libbindings.rlib-std", libprocmacroMod.Properties.AndroidMkRlibs) { t.Errorf("bindgen dependency not detected as a rlib dependency (dependency missing from AndroidMkRlibs)") } @@ -365,6 +365,6 @@ func TestMultilib(t *testing.T) { crate_name: "foo", }`) - _ = ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_rlib") - _ = ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_rlib") + _ = ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_rlib_dylib-std") + _ = ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_rlib_dylib-std") } -- cgit v1.2.3-59-g8ed1b