Loading cc/cc.go +17 −6 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) { ctx.TopDown("lto_deps", ltoDepsMutator) ctx.BottomUp("lto", ltoMutator).Parallel() ctx.BottomUp("check_linktype", checkLinkTypeMutator).Parallel() ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel() }) Loading Loading @@ -2004,7 +2005,7 @@ func BeginMutator(ctx android.BottomUpMutatorContext) { // Whether a module can link to another module, taking into // account NDK linking. func checkLinkType(ctx android.ModuleContext, from LinkableInterface, to LinkableInterface, func checkLinkType(ctx android.BaseModuleContext, from LinkableInterface, to LinkableInterface, tag blueprint.DependencyTag) { switch t := tag.(type) { Loading Loading @@ -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. // 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 Loading @@ -2132,15 +2145,15 @@ func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) { check := func(child, parent android.Module) bool { to, ok := child.(*Module) if !ok { // follow thru cc.Defaults, etc. return true return false } if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() { 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() { return true } Loading Loading @@ -2304,8 +2317,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { return } checkLinkType(ctx, c, ccDep, depTag) linkFile := ccDep.OutputFile() if libDepTag, ok := depTag.(libraryDependencyTag); ok { Loading cc/cc_test.go +30 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ func testCcErrorWithConfig(t *testing.T, pattern string, config android.Config) } func testCcError(t *testing.T, pattern string, bp string) { t.Helper() config := TestConfig(buildDir, android.Android, nil, bp, nil) config.TestProductVariables.DeviceVndkVersion = StringPtr("current") config.TestProductVariables.Platform_vndk_version = StringPtr("VER") Loading Loading @@ -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) { // This test checks the VNDK-Ext properties. bp := ` Loading cc/vndk.go +1 −1 Original line number Diff line number Diff line Loading @@ -129,7 +129,7 @@ func (vndk *vndkdep) typeName() string { 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 { return } Loading Loading
cc/cc.go +17 −6 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) { ctx.TopDown("lto_deps", ltoDepsMutator) ctx.BottomUp("lto", ltoMutator).Parallel() ctx.BottomUp("check_linktype", checkLinkTypeMutator).Parallel() ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel() }) Loading Loading @@ -2004,7 +2005,7 @@ func BeginMutator(ctx android.BottomUpMutatorContext) { // Whether a module can link to another module, taking into // account NDK linking. func checkLinkType(ctx android.ModuleContext, from LinkableInterface, to LinkableInterface, func checkLinkType(ctx android.BaseModuleContext, from LinkableInterface, to LinkableInterface, tag blueprint.DependencyTag) { switch t := tag.(type) { Loading Loading @@ -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. // 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 Loading @@ -2132,15 +2145,15 @@ func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) { check := func(child, parent android.Module) bool { to, ok := child.(*Module) if !ok { // follow thru cc.Defaults, etc. return true return false } if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() { 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() { return true } Loading Loading @@ -2304,8 +2317,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { return } checkLinkType(ctx, c, ccDep, depTag) linkFile := ccDep.OutputFile() if libDepTag, ok := depTag.(libraryDependencyTag); ok { Loading
cc/cc_test.go +30 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ func testCcErrorWithConfig(t *testing.T, pattern string, config android.Config) } func testCcError(t *testing.T, pattern string, bp string) { t.Helper() config := TestConfig(buildDir, android.Android, nil, bp, nil) config.TestProductVariables.DeviceVndkVersion = StringPtr("current") config.TestProductVariables.Platform_vndk_version = StringPtr("VER") Loading Loading @@ -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) { // This test checks the VNDK-Ext properties. bp := ` Loading
cc/vndk.go +1 −1 Original line number Diff line number Diff line Loading @@ -129,7 +129,7 @@ func (vndk *vndkdep) typeName() string { 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 { return } Loading