Don't create stubs variants of static libraries
Statically linking stub implementations doesn't make sense, don't
create stubs variants of static libraries.
Bug: 170784825
Test: all soong tests
Change-Id: Ie73635244516edf6da884e3a7a275971a9bd7839
diff --git a/cc/cc.go b/cc/cc.go
index 3b01fb2..286cf09 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -2337,12 +2337,17 @@
}
if depTag == reuseObjTag {
- // reusing objects only make sense for cc.Modules.
- staticAnalogue := ctx.OtherModuleProvider(dep, StaticLibraryInfoProvider).(StaticLibraryInfo)
- objs := staticAnalogue.ReuseObjects
- depPaths.Objs = depPaths.Objs.Append(objs)
- depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
- reexportExporter(depExporterInfo)
+ // Skip reused objects for stub libraries, they use their own stub object file instead.
+ // The reuseObjTag dependency still exists because the LinkageMutator runs before the
+ // version mutator, so the stubs variant is created from the shared variant that
+ // already has the reuseObjTag dependency on the static variant.
+ if !c.BuildStubs() {
+ staticAnalogue := ctx.OtherModuleProvider(dep, StaticLibraryInfoProvider).(StaticLibraryInfo)
+ objs := staticAnalogue.ReuseObjects
+ depPaths.Objs = depPaths.Objs.Append(objs)
+ depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
+ reexportExporter(depExporterInfo)
+ }
return
}
diff --git a/cc/library.go b/cc/library.go
index 910fc31..d77d876 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1665,10 +1665,9 @@
InRecovery() bool
CcLibraryInterface() bool
Shared() bool
- Static() bool
}) bool {
return CanBeOrLinkAgainstVersionVariants(module) &&
- module.CcLibraryInterface() && (module.Shared() || module.Static())
+ module.CcLibraryInterface() && module.Shared()
}
// versionSelector normalizes the versions in the Stubs.Versions property into MutatedProperties.AllStubsVersions,
diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go
index fa6b326..7f33072 100644
--- a/cc/library_sdk_member.go
+++ b/cc/library_sdk_member.go
@@ -86,10 +86,6 @@
if mctx.Device() {
variations = append(variations,
blueprint.Variation{Mutator: "image", Variation: android.CoreVariation})
- if mt.linkTypes != nil {
- variations = append(variations,
- blueprint.Variation{Mutator: "version", Variation: version})
- }
}
if mt.linkTypes == nil {
mctx.AddFarVariationDependencies(variations, dependencyTag, name)
@@ -97,6 +93,10 @@
for _, linkType := range mt.linkTypes {
libVariations := append(variations,
blueprint.Variation{Mutator: "link", Variation: linkType})
+ if mctx.Device() && linkType == "shared" {
+ libVariations = append(libVariations,
+ blueprint.Variation{Mutator: "version", Variation: version})
+ }
mctx.AddFarVariationDependencies(libVariations, dependencyTag, name)
}
}