Merge changes from topic "sanitizer-runtime-stubs" am: 973f46703b
am: 0730dce1c0
am: 0efc79cdd4
am: f7d81e216a
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1437232 Change-Id: Idcc8e7c956589ec8faf4d065d0031ad3beb0c002
This commit is contained in:
@@ -33,7 +33,7 @@ var (
|
||||
)
|
||||
|
||||
type AndroidMkContext interface {
|
||||
Name() string
|
||||
BaseModuleName() string
|
||||
Target() android.Target
|
||||
subAndroidMk(*android.AndroidMkEntries, interface{})
|
||||
Arch() android.Arch
|
||||
@@ -278,7 +278,7 @@ func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries
|
||||
})
|
||||
}
|
||||
if len(library.Properties.Stubs.Versions) > 0 &&
|
||||
android.DirectlyInAnyApex(ctx, ctx.Name()) && !ctx.InRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() &&
|
||||
android.DirectlyInAnyApex(ctx, ctx.BaseModuleName()) && !ctx.InRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() &&
|
||||
!ctx.static() {
|
||||
if library.buildStubs() && library.isLatestStubVersion() {
|
||||
// reference the latest version via its name without suffix when it is provided by apex
|
||||
|
110
cc/cc.go
110
cc/cc.go
@@ -740,6 +740,9 @@ func (c *Module) StubsVersions() []string {
|
||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
||||
return library.Properties.Stubs.Versions
|
||||
}
|
||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||
return library.Properties.Stubs.Versions
|
||||
}
|
||||
}
|
||||
panic(fmt.Errorf("StubsVersions called on non-library module: %q", c.BaseModuleName()))
|
||||
}
|
||||
@@ -749,6 +752,9 @@ func (c *Module) CcLibrary() bool {
|
||||
if _, ok := c.linker.(*libraryDecorator); ok {
|
||||
return true
|
||||
}
|
||||
if _, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -774,6 +780,14 @@ func (c *Module) SetBuildStubs() {
|
||||
c.Properties.PreventInstall = true
|
||||
return
|
||||
}
|
||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||
library.MutatedProperties.BuildStubs = true
|
||||
c.Properties.HideFromMake = true
|
||||
c.sanitize = nil
|
||||
c.stl = nil
|
||||
c.Properties.PreventInstall = true
|
||||
return
|
||||
}
|
||||
if _, ok := c.linker.(*llndkStubDecorator); ok {
|
||||
c.Properties.HideFromMake = true
|
||||
return
|
||||
@@ -787,6 +801,9 @@ func (c *Module) BuildStubs() bool {
|
||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
||||
return library.buildStubs()
|
||||
}
|
||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||
return library.buildStubs()
|
||||
}
|
||||
}
|
||||
panic(fmt.Errorf("BuildStubs called on non-library module: %q", c.BaseModuleName()))
|
||||
}
|
||||
@@ -796,6 +813,10 @@ func (c *Module) SetAllStubsVersions(versions []string) {
|
||||
library.MutatedProperties.AllStubsVersions = versions
|
||||
return
|
||||
}
|
||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||
library.MutatedProperties.AllStubsVersions = versions
|
||||
return
|
||||
}
|
||||
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
||||
llndk.libraryDecorator.MutatedProperties.AllStubsVersions = versions
|
||||
return
|
||||
@@ -806,6 +827,9 @@ func (c *Module) AllStubsVersions() []string {
|
||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
||||
return library.MutatedProperties.AllStubsVersions
|
||||
}
|
||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||
return library.MutatedProperties.AllStubsVersions
|
||||
}
|
||||
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
||||
return llndk.libraryDecorator.MutatedProperties.AllStubsVersions
|
||||
}
|
||||
@@ -818,6 +842,10 @@ func (c *Module) SetStubsVersion(version string) {
|
||||
library.MutatedProperties.StubsVersion = version
|
||||
return
|
||||
}
|
||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||
library.MutatedProperties.StubsVersion = version
|
||||
return
|
||||
}
|
||||
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
||||
llndk.libraryDecorator.MutatedProperties.StubsVersion = version
|
||||
return
|
||||
@@ -831,6 +859,9 @@ func (c *Module) StubsVersion() string {
|
||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
||||
return library.MutatedProperties.StubsVersion
|
||||
}
|
||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||
return library.MutatedProperties.StubsVersion
|
||||
}
|
||||
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
||||
return llndk.libraryDecorator.MutatedProperties.StubsVersion
|
||||
}
|
||||
@@ -1073,6 +1104,8 @@ func (c *Module) getVndkExtendsModuleName() string {
|
||||
func (c *Module) IsStubs() bool {
|
||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
||||
return library.buildStubs()
|
||||
} else if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||
return library.buildStubs()
|
||||
} else if _, ok := c.linker.(*llndkStubDecorator); ok {
|
||||
return true
|
||||
}
|
||||
@@ -1830,6 +1863,42 @@ func GetCrtVariations(ctx android.BottomUpMutatorContext,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Module) addSharedLibDependenciesWithVersions(ctx android.BottomUpMutatorContext,
|
||||
variations []blueprint.Variation, depTag libraryDependencyTag, name, version string, far bool) {
|
||||
|
||||
variations = append([]blueprint.Variation(nil), variations...)
|
||||
|
||||
if version != "" && VersionVariantAvailable(c) {
|
||||
// Version is explicitly specified. i.e. libFoo#30
|
||||
variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
|
||||
depTag.explicitlyVersioned = true
|
||||
}
|
||||
var deps []blueprint.Module
|
||||
if far {
|
||||
deps = ctx.AddFarVariationDependencies(variations, depTag, name)
|
||||
} else {
|
||||
deps = ctx.AddVariationDependencies(variations, depTag, name)
|
||||
}
|
||||
|
||||
// If the version is not specified, add dependency to all stubs libraries.
|
||||
// The stubs library will be used when the depending module is built for APEX and
|
||||
// the dependent module is not in the same APEX.
|
||||
if version == "" && VersionVariantAvailable(c) {
|
||||
if dep, ok := deps[0].(*Module); ok {
|
||||
for _, ver := range dep.AllStubsVersions() {
|
||||
// Note that depTag.ExplicitlyVersioned is false in this case.
|
||||
versionVariations := append(variations,
|
||||
blueprint.Variation{Mutator: "version", Variation: ver})
|
||||
if far {
|
||||
ctx.AddFarVariationDependencies(versionVariations, depTag, name)
|
||||
} else {
|
||||
ctx.AddVariationDependencies(versionVariations, depTag, name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
if !c.Enabled() {
|
||||
return
|
||||
@@ -1930,6 +1999,11 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
buildStubs = true
|
||||
}
|
||||
}
|
||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||
if library.buildStubs() {
|
||||
buildStubs = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rewriteSnapshotLibs := func(lib string, snapshotMap *snapshotMap) string {
|
||||
@@ -2018,32 +2092,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
}, depTag, rewriteSnapshotLibs(lib, vendorSnapshotStaticLibs))
|
||||
}
|
||||
|
||||
addSharedLibDependencies := func(depTag libraryDependencyTag, name string, version string) {
|
||||
var variations []blueprint.Variation
|
||||
variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"})
|
||||
if version != "" && VersionVariantAvailable(c) {
|
||||
// Version is explicitly specified. i.e. libFoo#30
|
||||
variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
|
||||
depTag.explicitlyVersioned = true
|
||||
}
|
||||
deps := actx.AddVariationDependencies(variations, depTag, name)
|
||||
|
||||
// If the version is not specified, add dependency to all stubs libraries.
|
||||
// The stubs library will be used when the depending module is built for APEX and
|
||||
// the dependent module is not in the same APEX.
|
||||
if version == "" && VersionVariantAvailable(c) {
|
||||
if dep, ok := deps[0].(*Module); ok {
|
||||
for _, ver := range dep.AllStubsVersions() {
|
||||
// Note that depTag.ExplicitlyVersioned is false in this case.
|
||||
ctx.AddVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "link", Variation: "shared"},
|
||||
{Mutator: "version", Variation: ver},
|
||||
}, depTag, name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// shared lib names without the #version suffix
|
||||
var sharedLibNames []string
|
||||
|
||||
@@ -2060,7 +2108,10 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
name, version := StubsLibNameAndVersion(lib)
|
||||
sharedLibNames = append(sharedLibNames, name)
|
||||
|
||||
addSharedLibDependencies(depTag, name, version)
|
||||
variations := []blueprint.Variation{
|
||||
{Mutator: "link", Variation: "shared"},
|
||||
}
|
||||
c.addSharedLibDependenciesWithVersions(ctx, variations, depTag, name, version, false)
|
||||
}
|
||||
|
||||
for _, lib := range deps.LateSharedLibs {
|
||||
@@ -2071,7 +2122,10 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
continue
|
||||
}
|
||||
depTag := libraryDependencyTag{Kind: sharedLibraryDependency, Order: lateLibraryDependency}
|
||||
addSharedLibDependencies(depTag, lib, "")
|
||||
variations := []blueprint.Variation{
|
||||
{Mutator: "link", Variation: "shared"},
|
||||
}
|
||||
c.addSharedLibDependenciesWithVersions(ctx, variations, depTag, lib, "", false)
|
||||
}
|
||||
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
|
@@ -1040,7 +1040,7 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
|
||||
if c.Device() {
|
||||
variations = append(variations, c.ImageVariation())
|
||||
}
|
||||
mctx.AddFarVariationDependencies(variations, depTag, runtimeLibrary)
|
||||
c.addSharedLibDependenciesWithVersions(mctx, variations, depTag, runtimeLibrary, "", true)
|
||||
}
|
||||
// static lib does not have dependency to the runtime library. The
|
||||
// dependency will be added to the executables or shared libs using
|
||||
|
Reference in New Issue
Block a user