Merge changes from topic "sanitizer-runtime-stubs" am: 973f46703b
am: 0730dce1c0
am: 0efc79cdd4
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1437232 Change-Id: Ie2c3fee68f96a97834a5f26a05e8f9e268bc0c6e
This commit is contained in:
@@ -33,7 +33,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type AndroidMkContext interface {
|
type AndroidMkContext interface {
|
||||||
Name() string
|
BaseModuleName() string
|
||||||
Target() android.Target
|
Target() android.Target
|
||||||
subAndroidMk(*android.AndroidMkEntries, interface{})
|
subAndroidMk(*android.AndroidMkEntries, interface{})
|
||||||
Arch() android.Arch
|
Arch() android.Arch
|
||||||
@@ -278,7 +278,7 @@ func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if len(library.Properties.Stubs.Versions) > 0 &&
|
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() {
|
!ctx.static() {
|
||||||
if library.buildStubs() && library.isLatestStubVersion() {
|
if library.buildStubs() && library.isLatestStubVersion() {
|
||||||
// reference the latest version via its name without suffix when it is provided by apex
|
// 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 {
|
if library, ok := c.linker.(*libraryDecorator); ok {
|
||||||
return library.Properties.Stubs.Versions
|
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()))
|
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 {
|
if _, ok := c.linker.(*libraryDecorator); ok {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if _, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -774,6 +780,14 @@ func (c *Module) SetBuildStubs() {
|
|||||||
c.Properties.PreventInstall = true
|
c.Properties.PreventInstall = true
|
||||||
return
|
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 {
|
if _, ok := c.linker.(*llndkStubDecorator); ok {
|
||||||
c.Properties.HideFromMake = true
|
c.Properties.HideFromMake = true
|
||||||
return
|
return
|
||||||
@@ -787,6 +801,9 @@ func (c *Module) BuildStubs() bool {
|
|||||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
if library, ok := c.linker.(*libraryDecorator); ok {
|
||||||
return library.buildStubs()
|
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()))
|
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
|
library.MutatedProperties.AllStubsVersions = versions
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||||
|
library.MutatedProperties.AllStubsVersions = versions
|
||||||
|
return
|
||||||
|
}
|
||||||
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
||||||
llndk.libraryDecorator.MutatedProperties.AllStubsVersions = versions
|
llndk.libraryDecorator.MutatedProperties.AllStubsVersions = versions
|
||||||
return
|
return
|
||||||
@@ -806,6 +827,9 @@ func (c *Module) AllStubsVersions() []string {
|
|||||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
if library, ok := c.linker.(*libraryDecorator); ok {
|
||||||
return library.MutatedProperties.AllStubsVersions
|
return library.MutatedProperties.AllStubsVersions
|
||||||
}
|
}
|
||||||
|
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||||
|
return library.MutatedProperties.AllStubsVersions
|
||||||
|
}
|
||||||
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
||||||
return llndk.libraryDecorator.MutatedProperties.AllStubsVersions
|
return llndk.libraryDecorator.MutatedProperties.AllStubsVersions
|
||||||
}
|
}
|
||||||
@@ -818,6 +842,10 @@ func (c *Module) SetStubsVersion(version string) {
|
|||||||
library.MutatedProperties.StubsVersion = version
|
library.MutatedProperties.StubsVersion = version
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||||
|
library.MutatedProperties.StubsVersion = version
|
||||||
|
return
|
||||||
|
}
|
||||||
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
||||||
llndk.libraryDecorator.MutatedProperties.StubsVersion = version
|
llndk.libraryDecorator.MutatedProperties.StubsVersion = version
|
||||||
return
|
return
|
||||||
@@ -831,6 +859,9 @@ func (c *Module) StubsVersion() string {
|
|||||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
if library, ok := c.linker.(*libraryDecorator); ok {
|
||||||
return library.MutatedProperties.StubsVersion
|
return library.MutatedProperties.StubsVersion
|
||||||
}
|
}
|
||||||
|
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||||
|
return library.MutatedProperties.StubsVersion
|
||||||
|
}
|
||||||
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
||||||
return llndk.libraryDecorator.MutatedProperties.StubsVersion
|
return llndk.libraryDecorator.MutatedProperties.StubsVersion
|
||||||
}
|
}
|
||||||
@@ -1073,6 +1104,8 @@ func (c *Module) getVndkExtendsModuleName() string {
|
|||||||
func (c *Module) IsStubs() bool {
|
func (c *Module) IsStubs() bool {
|
||||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
if library, ok := c.linker.(*libraryDecorator); ok {
|
||||||
return library.buildStubs()
|
return library.buildStubs()
|
||||||
|
} else if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||||
|
return library.buildStubs()
|
||||||
} else if _, ok := c.linker.(*llndkStubDecorator); ok {
|
} else if _, ok := c.linker.(*llndkStubDecorator); ok {
|
||||||
return true
|
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) {
|
func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||||
if !c.Enabled() {
|
if !c.Enabled() {
|
||||||
return
|
return
|
||||||
@@ -1930,6 +1999,11 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
buildStubs = true
|
buildStubs = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
||||||
|
if library.buildStubs() {
|
||||||
|
buildStubs = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rewriteSnapshotLibs := func(lib string, snapshotMap *snapshotMap) string {
|
rewriteSnapshotLibs := func(lib string, snapshotMap *snapshotMap) string {
|
||||||
@@ -2018,32 +2092,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
}, depTag, rewriteSnapshotLibs(lib, vendorSnapshotStaticLibs))
|
}, 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
|
// shared lib names without the #version suffix
|
||||||
var sharedLibNames []string
|
var sharedLibNames []string
|
||||||
|
|
||||||
@@ -2060,7 +2108,10 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
name, version := StubsLibNameAndVersion(lib)
|
name, version := StubsLibNameAndVersion(lib)
|
||||||
sharedLibNames = append(sharedLibNames, name)
|
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 {
|
for _, lib := range deps.LateSharedLibs {
|
||||||
@@ -2071,7 +2122,10 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
depTag := libraryDependencyTag{Kind: sharedLibraryDependency, Order: lateLibraryDependency}
|
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{
|
actx.AddVariationDependencies([]blueprint.Variation{
|
||||||
|
@@ -1040,7 +1040,7 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
if c.Device() {
|
if c.Device() {
|
||||||
variations = append(variations, c.ImageVariation())
|
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
|
// static lib does not have dependency to the runtime library. The
|
||||||
// dependency will be added to the executables or shared libs using
|
// dependency will be added to the executables or shared libs using
|
||||||
|
Reference in New Issue
Block a user