summaryrefslogtreecommitdiff
path: root/rust/library.go
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2020-06-09 08:27:49 -0400
committer Ivan Lozano <ivanlozano@google.com> 2020-06-09 08:40:24 -0400
commitbec05ea26d98101b54426cc6ee55e646953f9997 (patch)
tree9c0b0a0ac825a8f06b6a4d379fa58cb4f216d9d3 /rust/library.go
parent3ef493ff91c343881191b1fd813f57f92f3d85eb (diff)
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
Diffstat (limited to 'rust/library.go')
-rw-r--r--rust/library.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/rust/library.go b/rust/library.go
index 8aa033c0f..2e5126639 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -329,12 +329,21 @@ func (library *libraryDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps {
return deps
}
+
+func (library *libraryDecorator) sharedLibFilename(ctx ModuleContext) string {
+ return library.getStem(ctx) + ctx.toolchain().SharedLibSuffix()
+}
+
func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
flags.RustFlags = append(flags.RustFlags, "-C metadata="+ctx.baseModuleName())
flags = library.baseCompiler.compilerFlags(ctx, flags)
if library.shared() || library.static() {
library.includeDirs = append(library.includeDirs, android.PathsForModuleSrc(ctx, library.Properties.Include_dirs)...)
}
+ if library.shared() {
+ flags.LinkFlags = append(flags.LinkFlags, "-Wl,-soname="+library.sharedLibFilename(ctx))
+ }
+
return flags
}
@@ -371,7 +380,7 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
outputs := TransformSrctoStatic(ctx, srcPath, deps, flags, outputFile, deps.linkDirs)
library.coverageFile = outputs.coverageFile
} else if library.shared() {
- fileName := library.getStem(ctx) + ctx.toolchain().SharedLibSuffix()
+ fileName := library.sharedLibFilename(ctx)
outputFile = android.PathForModuleOut(ctx, fileName)
outputs := TransformSrctoShared(ctx, srcPath, deps, flags, outputFile, deps.linkDirs)