Specify SONAME when building Rust shared libs.

Without specifying -soname, cc binaries are unable to locate Rust
provided shared libraries. This adds the -soname linker flag for shared
libraries.

Bug: 158490355
Test: readelf -d <cc_binary> shows the expected SONAME
Change-Id: I66852a7ce24d5ea5e426f11bc1834fb56a150628
This commit is contained in:
Ivan Lozano
2020-06-09 08:27:49 -04:00
parent 3ef493ff91
commit bec05ea26d
2 changed files with 24 additions and 1 deletions

View File

@@ -114,3 +114,17 @@ func TestValidateLibraryStem(t *testing.T) {
}`)
}
func TestSharedLibraryFlags(t *testing.T) {
ctx := testRust(t, `
rust_library_host {
name: "libfoo",
srcs: ["foo.rs"],
crate_name: "foo",
}`)
libfooShared := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_shared").Output("libfoo.so")
if !strings.Contains(libfooShared.Args["linkFlags"], "-Wl,-soname=libfoo.so") {
t.Errorf("missing expected -Wl,-soname linker flag for libfoo shared lib, linkFlags: %#v", libfooShared.Args["linkFlags"])
}
}