diff --git a/cc/cc.go b/cc/cc.go index 67e7d7c56..f467c7339 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -1777,6 +1777,9 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { for _, lib := range deps.SharedLibs { depTag := SharedDepTag + if c.static() { + depTag = SharedFromStaticDepTag + } if inList(lib, deps.ReexportSharedLibHeaders) { depTag = sharedExportDepTag } @@ -2194,7 +2197,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { depFile := android.OptionalPath{} switch depTag { - case ndkStubDepTag, SharedDepTag, sharedExportDepTag: + case ndkStubDepTag, SharedDepTag, SharedFromStaticDepTag, sharedExportDepTag: ptr = &depPaths.SharedLibs depPtr = &depPaths.SharedLibsDeps depFile = ccDep.Toc() @@ -2547,9 +2550,17 @@ func (c *Module) AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Write func (c *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { if depTag, ok := ctx.OtherModuleDependencyTag(dep).(DependencyTag); ok { - if cc, ok := dep.(*Module); ok && cc.HasStubsVariants() && depTag.Shared && depTag.Library { - // dynamic dep to a stubs lib crosses APEX boundary - return false + if cc, ok := dep.(*Module); ok { + if cc.HasStubsVariants() && depTag.Shared && depTag.Library { + // dynamic dep to a stubs lib crosses APEX boundary + return false + } + if depTag.FromStatic { + // shared_lib dependency from a static lib is considered as crossing + // the APEX boundary because the dependency doesn't actually is + // linked; the dependency is used only during the compilation phase. + return false + } } } return true diff --git a/cc/linkable.go b/cc/linkable.go index 3c46d9dd9..2abb11264 100644 --- a/cc/linkable.go +++ b/cc/linkable.go @@ -67,12 +67,17 @@ type DependencyTag struct { ReexportFlags bool ExplicitlyVersioned bool + + FromStatic bool } var ( SharedDepTag = DependencyTag{Name: "shared", Library: true, Shared: true} StaticDepTag = DependencyTag{Name: "static", Library: true} + // Same as SharedDepTag, but from a static lib + SharedFromStaticDepTag = DependencyTag{Name: "shared from static", Library: true, Shared: true, FromStatic: true} + CrtBeginDepTag = DependencyTag{Name: "crtbegin"} CrtEndDepTag = DependencyTag{Name: "crtend"} )