Convert coverage libs as alwayslink
Bug: 291090629 Test: bp2build.sh and CI Change-Id: I050a870b36b5bc84dbdbca73405e0a0fab1aef86
This commit is contained in:
parent
9488eb82d4
commit
3847f21848
2 changed files with 29 additions and 2 deletions
|
@ -48,6 +48,7 @@ func (cov *coverage) props() []interface{} {
|
|||
func getGcovProfileLibraryName(ctx ModuleContextIntf) string {
|
||||
// This function should only ever be called for a cc.Module, so the
|
||||
// following statement should always succeed.
|
||||
// LINT.IfChange
|
||||
if ctx.useSdk() {
|
||||
return "libprofile-extras_ndk"
|
||||
} else {
|
||||
|
@ -63,6 +64,7 @@ func getClangProfileLibraryName(ctx ModuleContextIntf) string {
|
|||
} else {
|
||||
return "libprofile-clang-extras"
|
||||
}
|
||||
// LINT.ThenChange(library.go)
|
||||
}
|
||||
|
||||
func (cov *coverage) deps(ctx DepsContext, deps Deps) Deps {
|
||||
|
|
|
@ -32,6 +32,20 @@ import (
|
|||
"github.com/google/blueprint/proptools"
|
||||
)
|
||||
|
||||
var (
|
||||
alwaysLinkLibraries = map[string]bool{
|
||||
// Coverage libraries are _always_ added as a whole_static_dep. By converting as these as
|
||||
// alwayslink = True, we can add these as to deps (e.g. as a regular static dep) in Bazel
|
||||
// without any extra complications in cc_shared_library roots to prevent linking the same
|
||||
// library repeatedly.
|
||||
"libprofile-extras_ndk": true,
|
||||
"libprofile-extras": true,
|
||||
"libprofile-clang-extras_ndk": true,
|
||||
"libprofile-clang-extras_cfi_support": true,
|
||||
"libprofile-clang-extras": true,
|
||||
}
|
||||
)
|
||||
|
||||
// LibraryProperties is a collection of properties shared by cc library rules/cc.
|
||||
type LibraryProperties struct {
|
||||
// local file name to pass to the linker as -unexported_symbols_list
|
||||
|
@ -435,6 +449,10 @@ func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) {
|
|||
Bzl_load_location: "//build/bazel/rules/cc:cc_library_shared.bzl",
|
||||
}
|
||||
|
||||
if _, ok := alwaysLinkLibraries[m.Name()]; ok {
|
||||
staticTargetAttrs.Alwayslink = proptools.BoolPtr(true)
|
||||
}
|
||||
|
||||
var tagsForStaticVariant bazel.StringListAttribute
|
||||
if compilerAttrs.stubsSymbolFile == nil && len(compilerAttrs.stubsVersions.Value) == 0 {
|
||||
tagsForStaticVariant = android.ApexAvailableTagsWithoutTestApexes(ctx, m)
|
||||
|
@ -2947,6 +2965,10 @@ func sharedOrStaticLibraryBp2Build(ctx android.TopDownMutatorContext, module *Mo
|
|||
var attrs interface{}
|
||||
if isStatic {
|
||||
commonAttrs.Deps.Add(baseAttributes.protoDependency)
|
||||
var alwayslink *bool
|
||||
if _, ok := alwaysLinkLibraries[module.Name()]; ok && isStatic {
|
||||
alwayslink = proptools.BoolPtr(true)
|
||||
}
|
||||
attrs = &bazelCcLibraryStaticAttributes{
|
||||
staticOrSharedAttributes: commonAttrs,
|
||||
Rtti: compilerAttrs.rtti,
|
||||
|
@ -2960,8 +2982,10 @@ func sharedOrStaticLibraryBp2Build(ctx android.TopDownMutatorContext, module *Mo
|
|||
Conlyflags: compilerAttrs.conlyFlags,
|
||||
Asflags: asFlags,
|
||||
|
||||
Features: *features,
|
||||
Alwayslink: alwayslink,
|
||||
Features: *features,
|
||||
}
|
||||
|
||||
} else {
|
||||
commonAttrs.Dynamic_deps.Add(baseAttributes.protoDependency)
|
||||
|
||||
|
@ -3043,7 +3067,8 @@ type bazelCcLibraryStaticAttributes struct {
|
|||
Conlyflags bazel.StringListAttribute
|
||||
Asflags bazel.StringListAttribute
|
||||
|
||||
Features bazel.StringListAttribute
|
||||
Alwayslink *bool
|
||||
Features bazel.StringListAttribute
|
||||
}
|
||||
|
||||
// TODO(b/199902614): Can this be factored to share with the other Attributes?
|
||||
|
|
Loading…
Reference in a new issue