rust: Propagate static libs correctly
A dylib link is a final link, so we should not propagate staticlibs
through them. Most of the time this made no difference, but this
was breaking edge cases on coverage builds.
This CL breaks apart linkObjects so we can more finely tune which
dependencies we propagate and which we should not.
rlibs should only propagate non-whole static librares, while rlibs and
dylibs propagate whole static libs.
Bug: 377932175
Test: m
Test: New Soong tests
Change-Id: Ib2ae3dcb7d775a57bd4b1715ec528f48cc0ca026
diff --git a/rust/library.go b/rust/library.go
index 95e7099..dd19437 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -671,7 +671,10 @@
flags.RustFlags = append(flags.RustFlags, deps.depFlags...)
flags.LinkFlags = append(flags.LinkFlags, deps.depLinkFlags...)
- flags.LinkFlags = append(flags.LinkFlags, deps.linkObjects...)
+ flags.LinkFlags = append(flags.LinkFlags, deps.rustLibObjects...)
+ flags.LinkFlags = append(flags.LinkFlags, deps.sharedLibObjects...)
+ flags.LinkFlags = append(flags.LinkFlags, deps.staticLibObjects...)
+ flags.LinkFlags = append(flags.LinkFlags, deps.wholeStaticLibObjects...)
if String(library.Properties.Version_script) != "" {
if String(library.Properties.Extra_exported_symbols) != "" {
@@ -719,9 +722,17 @@
ret.kytheFile = TransformSrctoShared(ctx, crateRootPath, deps, flags, outputFile).kytheFile
}
+ // rlibs and dylibs propagate their shared, whole static, and rustlib dependencies
if library.rlib() || library.dylib() {
library.flagExporter.exportLinkDirs(deps.linkDirs...)
- library.flagExporter.exportLinkObjects(deps.linkObjects...)
+ library.flagExporter.exportRustLibs(deps.rustLibObjects...)
+ library.flagExporter.exportSharedLibs(deps.sharedLibObjects...)
+ library.flagExporter.exportWholeStaticLibs(deps.wholeStaticLibObjects...)
+ }
+
+ // rlibs also propagate their staticlibs dependencies
+ if library.rlib() {
+ library.flagExporter.exportStaticLibs(deps.staticLibObjects...)
}
// Since we have FFI rlibs, we need to collect their includes as well
@@ -756,6 +767,7 @@
}
cc.AddStubDependencyProviders(ctx)
+ // Set our flagexporter provider to export relevant Rust flags
library.flagExporter.setProvider(ctx)
return ret