summaryrefslogtreecommitdiff
path: root/rust/library.go
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2024-11-08 16:16:50 +0000
committer Ivan Lozano <ivanlozano@google.com> 2025-02-05 03:13:01 +0000
commit1f10f684516b131b5e6aebdf9b7915cf07409510 (patch)
treee4c5d3f6092fedc33807da4532b023bad3759a92 /rust/library.go
parente068e0cb169335d5c76a27aba7f77088c52fb060 (diff)
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
Diffstat (limited to 'rust/library.go')
-rw-r--r--rust/library.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/rust/library.go b/rust/library.go
index 95e7099a6..dd194374f 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -671,7 +671,10 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
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 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
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 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
}
cc.AddStubDependencyProviders(ctx)
+ // Set our flagexporter provider to export relevant Rust flags
library.flagExporter.setProvider(ctx)
return ret