From 4f4f8ebd3fbc10e32fd102e2cce987a0edfb7781 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 6 Jan 2021 14:07:27 -0800 Subject: [PATCH] Fix llndk_library init llndk_library modules were not calling module.Init(), which caused them not to register ModuleBase.VendorProperties. Unregistered property structs lose their values during cloning, which caused the shared variants of llndk_library modules to not have IsLLNDK set. Call module.Init(), which registers ModuleBase.VendorProperties. Also add a helper function to filter out llndk_library modules that now show up in the list of modules with IsLLNDK set. Bug: 170784825 Test: m checkbuild Change-Id: Iafde85f6a95e85a618f6f7d7a210398febb6b158 --- cc/library.go | 5 +---- cc/llndk_library.go | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/cc/library.go b/cc/library.go index 1185385f3..bc6ff69e1 100644 --- a/cc/library.go +++ b/cc/library.go @@ -1738,12 +1738,9 @@ func LinkageMutator(mctx android.BottomUpMutatorContext) { isLLNDK := false if m, ok := mctx.Module().(*Module); ok { - isLLNDK = m.IsLlndk() // Don't count the vestigial llndk_library module as isLLNDK, it needs a static // variant so that a cc_library_prebuilt can depend on it. - if _, ok := m.linker.(*llndkStubDecorator); ok { - isLLNDK = false - } + isLLNDK = m.IsLlndk() && !isVestigialLLNDKModule(m) } buildStatic := library.BuildStaticVariant() && !isLLNDK buildShared := library.BuildSharedVariant() diff --git a/cc/llndk_library.go b/cc/llndk_library.go index d0fbc480e..0c4bcfdbc 100644 --- a/cc/llndk_library.go +++ b/cc/llndk_library.go @@ -100,6 +100,11 @@ func (stub *llndkStubDecorator) Name(name string) string { return name + llndkLibrarySuffix } +func (stub *llndkStubDecorator) linkerProps() []interface{} { + props := stub.libraryDecorator.linkerProps() + return append(props, &stub.Properties) +} + func (stub *llndkStubDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags { stub.libraryDecorator.libName = stub.implementationModuleName(ctx.ModuleName()) return stub.libraryDecorator.linkerFlags(ctx, flags) @@ -137,12 +142,6 @@ func NewLLndkStubLibrary() *Module { module.installer = nil module.library = stub - module.AddProperties( - &module.Properties, - &stub.Properties, - &library.MutatedProperties, - &library.flagExporter.Properties) - return module } @@ -156,8 +155,14 @@ func NewLLndkStubLibrary() *Module { // } func LlndkLibraryFactory() android.Module { module := NewLLndkStubLibrary() - android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth) - return module + return module.Init() +} + +// isVestigialLLNDKModule returns true if m is a vestigial llndk_library module used to provide +// properties to the LLNDK variant of a cc_library. +func isVestigialLLNDKModule(m *Module) bool { + _, ok := m.linker.(*llndkStubDecorator) + return ok } type llndkHeadersDecorator struct {