diff options
| author | 2021-02-05 12:27:08 -0500 | |
|---|---|---|
| committer | 2021-02-05 12:32:47 -0500 | |
| commit | fb6f36f3e40adcd3210fad714a2ffb4739a7158d (patch) | |
| tree | dc13171b152f4746c74e15f5e17c5407738838a6 /rust/rust.go | |
| parent | b3f9025b6e2ba2e34a77eb7a3b69d993839c35c3 (diff) | |
rust: Only pass "-lstatic" for rlibs.
Passing '-lstatic' for dylib static dependencies results in some
unexpected bloat as the static libraries are included as
whole-archives.
For now, limit this to rlibs while we investigate.
Bug: 175886967
Bug: 179122837
Test: cd system/bt/; mma
Test: Checked size of dylibs.
Change-Id: Id8328e95771e2ca8503bc8df35248b1c39cabc8e
Diffstat (limited to 'rust/rust.go')
| -rw-r--r-- | rust/rust.go | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/rust/rust.go b/rust/rust.go index e1af77692..0b733cc35 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -896,14 +896,17 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { exportDep := false switch { case cc.IsStaticDepTag(depTag): - // Link cc static libraries using "-lstatic" so rustc can reason about how to handle these - // (for example, bundling them into rlibs). - // - // rustc does not support linking libraries with the "-l" flag unless they are prefixed by "lib". - // If we need to link a library that isn't prefixed by "lib", we'll just link to it directly through - // linkObjects; such a library may need to be redeclared by static dependents. - if libName, ok := libNameFromFilePath(linkObject.Path()); ok { - depPaths.depFlags = append(depPaths.depFlags, "-lstatic="+libName) + // Only pass -lstatic for rlibs as it results in dylib bloat. + if lib, ok := ctx.Module().(*Module).compiler.(libraryInterface); ok && lib.rlib() { + // Link cc static libraries using "-lstatic" so rustc can reason about how to handle these + // (for example, bundling them into rlibs). + // + // rustc does not support linking libraries with the "-l" flag unless they are prefixed by "lib". + // If we need to link a library that isn't prefixed by "lib", we'll just link to it directly through + // linkObjects; such a library may need to be redeclared by static dependents. + if libName, ok := libNameFromFilePath(linkObject.Path()); ok { + depPaths.depFlags = append(depPaths.depFlags, "-lstatic="+libName) + } } // Add this to linkObjects to pass the library directly to the linker as well. This propagates |