Merge "run vndk-sp closure check before double-loadable" am: 12aa3e44d0
am: c0ef63a3bc
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1465909 Change-Id: I3a4c29bf840e94def38e336e055c553e7c2ba7a3
This commit is contained in:
23
cc/cc.go
23
cc/cc.go
@@ -84,6 +84,7 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
|
|||||||
ctx.TopDown("lto_deps", ltoDepsMutator)
|
ctx.TopDown("lto_deps", ltoDepsMutator)
|
||||||
ctx.BottomUp("lto", ltoMutator).Parallel()
|
ctx.BottomUp("lto", ltoMutator).Parallel()
|
||||||
|
|
||||||
|
ctx.BottomUp("check_linktype", checkLinkTypeMutator).Parallel()
|
||||||
ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
|
ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -2004,7 +2005,7 @@ func BeginMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
|
|
||||||
// Whether a module can link to another module, taking into
|
// Whether a module can link to another module, taking into
|
||||||
// account NDK linking.
|
// account NDK linking.
|
||||||
func checkLinkType(ctx android.ModuleContext, from LinkableInterface, to LinkableInterface,
|
func checkLinkType(ctx android.BaseModuleContext, from LinkableInterface, to LinkableInterface,
|
||||||
tag blueprint.DependencyTag) {
|
tag blueprint.DependencyTag) {
|
||||||
|
|
||||||
switch t := tag.(type) {
|
switch t := tag.(type) {
|
||||||
@@ -2124,6 +2125,18 @@ func checkLinkType(ctx android.ModuleContext, from LinkableInterface, to Linkabl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkLinkTypeMutator(ctx android.BottomUpMutatorContext) {
|
||||||
|
if c, ok := ctx.Module().(*Module); ok {
|
||||||
|
ctx.VisitDirectDeps(func(dep android.Module) {
|
||||||
|
depTag := ctx.OtherModuleDependencyTag(dep)
|
||||||
|
ccDep, ok := dep.(LinkableInterface)
|
||||||
|
if ok {
|
||||||
|
checkLinkType(ctx, c, ccDep, depTag)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tests whether the dependent library is okay to be double loaded inside a single process.
|
// Tests whether the dependent library is okay to be double loaded inside a single process.
|
||||||
// If a library has a vendor variant and is a (transitive) dependency of an LLNDK library,
|
// If a library has a vendor variant and is a (transitive) dependency of an LLNDK library,
|
||||||
// it is subject to be double loaded. Such lib should be explicitly marked as double_loadable: true
|
// it is subject to be double loaded. Such lib should be explicitly marked as double_loadable: true
|
||||||
@@ -2132,15 +2145,15 @@ func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) {
|
|||||||
check := func(child, parent android.Module) bool {
|
check := func(child, parent android.Module) bool {
|
||||||
to, ok := child.(*Module)
|
to, ok := child.(*Module)
|
||||||
if !ok {
|
if !ok {
|
||||||
// follow thru cc.Defaults, etc.
|
return false
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() {
|
if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// if target lib has no vendor variant, keep checking dependency graph
|
// Even if target lib has no vendor variant, keep checking dependency graph
|
||||||
|
// in case it depends on vendor_available but not double_loadable transtively.
|
||||||
if !to.HasVendorVariant() {
|
if !to.HasVendorVariant() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -2304,8 +2317,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
checkLinkType(ctx, c, ccDep, depTag)
|
|
||||||
|
|
||||||
linkFile := ccDep.OutputFile()
|
linkFile := ccDep.OutputFile()
|
||||||
|
|
||||||
if libDepTag, ok := depTag.(libraryDependencyTag); ok {
|
if libDepTag, ok := depTag.(libraryDependencyTag); ok {
|
||||||
|
@@ -103,6 +103,7 @@ func testCcErrorWithConfig(t *testing.T, pattern string, config android.Config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testCcError(t *testing.T, pattern string, bp string) {
|
func testCcError(t *testing.T, pattern string, bp string) {
|
||||||
|
t.Helper()
|
||||||
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
||||||
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
||||||
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
||||||
@@ -1665,6 +1666,35 @@ func TestDoubleLoadableDepError(t *testing.T) {
|
|||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCheckVndkMembershipBeforeDoubleLoadable(t *testing.T) {
|
||||||
|
testCcError(t, "module \"libvndksp\" variant .*: .*: VNDK-SP must only depend on VNDK-SP", `
|
||||||
|
cc_library {
|
||||||
|
name: "libvndksp",
|
||||||
|
shared_libs: ["libanothervndksp"],
|
||||||
|
vendor_available: true,
|
||||||
|
vndk: {
|
||||||
|
enabled: true,
|
||||||
|
support_system_process: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "libllndk",
|
||||||
|
shared_libs: ["libanothervndksp"],
|
||||||
|
}
|
||||||
|
|
||||||
|
llndk_library {
|
||||||
|
name: "libllndk",
|
||||||
|
symbol_file: "",
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "libanothervndksp",
|
||||||
|
vendor_available: true,
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
func TestVndkExt(t *testing.T) {
|
func TestVndkExt(t *testing.T) {
|
||||||
// This test checks the VNDK-Ext properties.
|
// This test checks the VNDK-Ext properties.
|
||||||
bp := `
|
bp := `
|
||||||
|
@@ -129,7 +129,7 @@ func (vndk *vndkdep) typeName() string {
|
|||||||
return "native:vendor:vndkspext"
|
return "native:vendor:vndkspext"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vndk *vndkdep) vndkCheckLinkType(ctx android.ModuleContext, to *Module, tag blueprint.DependencyTag) {
|
func (vndk *vndkdep) vndkCheckLinkType(ctx android.BaseModuleContext, to *Module, tag blueprint.DependencyTag) {
|
||||||
if to.linker == nil {
|
if to.linker == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user