Merge "Handle static binary repetition of system deps" into main
This commit is contained in:
commit
0a681989ae
3 changed files with 102 additions and 3 deletions
|
@ -931,9 +931,6 @@ var (
|
|||
"test_fips", // depends on unconverted modules: adb
|
||||
"timezone-host", // depends on unconverted modules: art.module.api.annotations
|
||||
|
||||
// '//bionic/libc:libc_bp2build_cc_library_static' is duplicated in the 'deps' attribute of rule
|
||||
"toybox-static",
|
||||
|
||||
// aidl files not created
|
||||
"overlayable_policy_aidl_interface",
|
||||
|
||||
|
|
|
@ -1214,3 +1214,82 @@ func TestCCBinaryRscriptSrc(t *testing.T) {
|
|||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcBinaryStatic_SystemSharedLibUsedAsDep(t *testing.T) {
|
||||
runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{
|
||||
description: "cc_library_static system_shared_lib empty for linux_bionic variant",
|
||||
blueprint: soongCcLibraryStaticPreamble +
|
||||
simpleModuleDoNotConvertBp2build("cc_library", "libc") + `
|
||||
|
||||
cc_library {
|
||||
name: "libm",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "used_in_bionic_oses",
|
||||
target: {
|
||||
android: {
|
||||
static_libs: ["libc"],
|
||||
},
|
||||
linux_bionic: {
|
||||
static_libs: ["libc"],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
static_executable: true,
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "all",
|
||||
static_libs: ["libc"],
|
||||
include_build_directory: false,
|
||||
static_executable: true,
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "keep_for_empty_system_shared_libs",
|
||||
static_libs: ["libc"],
|
||||
system_shared_libs: [],
|
||||
include_build_directory: false,
|
||||
static_executable: true,
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "used_with_stubs",
|
||||
static_libs: ["libm"],
|
||||
include_build_directory: false,
|
||||
static_executable: true,
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "keep_with_stubs",
|
||||
static_libs: ["libm"],
|
||||
system_shared_libs: [],
|
||||
include_build_directory: false,
|
||||
static_executable: true,
|
||||
}
|
||||
`,
|
||||
targets: []testBazelTarget{
|
||||
{"cc_binary", "all", AttrNameToString{
|
||||
"linkshared": "False",
|
||||
}},
|
||||
{"cc_binary", "keep_for_empty_system_shared_libs", AttrNameToString{
|
||||
"deps": `[":libc_bp2build_cc_library_static"]`,
|
||||
"system_deps": `[]`,
|
||||
"linkshared": "False",
|
||||
}},
|
||||
{"cc_binary", "keep_with_stubs", AttrNameToString{
|
||||
"linkshared": "False",
|
||||
"deps": `[":libm_bp2build_cc_library_static"]`,
|
||||
"system_deps": `[]`,
|
||||
}},
|
||||
{"cc_binary", "used_in_bionic_oses", AttrNameToString{
|
||||
"linkshared": "False",
|
||||
}},
|
||||
{"cc_binary", "used_with_stubs", AttrNameToString{
|
||||
"linkshared": "False",
|
||||
}},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1139,6 +1139,7 @@ type linkerAttributes struct {
|
|||
wholeArchiveDeps bazel.LabelListAttribute
|
||||
implementationWholeArchiveDeps bazel.LabelListAttribute
|
||||
systemDynamicDeps bazel.LabelListAttribute
|
||||
usedSystemDynamicDepAsStaticDep map[string]bool
|
||||
usedSystemDynamicDepAsDynamicDep map[string]bool
|
||||
|
||||
useVersionLib bazel.BoolAttribute
|
||||
|
@ -1201,6 +1202,18 @@ func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversion
|
|||
// https://cs.android.com/android/platform/superproject/+/master:build/soong/cc/linker.go;l=247-249;drc=088b53577dde6e40085ffd737a1ae96ad82fc4b0
|
||||
la.wholeArchiveDeps.SetSelectValue(axis, config, bazelLabelForWholeDepsExcludes(ctx, wholeStaticLibs, props.Exclude_static_libs))
|
||||
|
||||
if isBinary && module.StaticExecutable() {
|
||||
usedSystemStatic := android.FilterListPred(staticLibs, func(s string) bool {
|
||||
return android.InList(s, soongSystemSharedLibs) && !android.InList(s, props.Exclude_static_libs)
|
||||
})
|
||||
|
||||
for _, el := range usedSystemStatic {
|
||||
if la.usedSystemDynamicDepAsStaticDep == nil {
|
||||
la.usedSystemDynamicDepAsStaticDep = map[string]bool{}
|
||||
}
|
||||
la.usedSystemDynamicDepAsStaticDep[el] = true
|
||||
}
|
||||
}
|
||||
staticDeps := maybePartitionExportedAndImplementationsDepsExcludes(
|
||||
ctx,
|
||||
!isBinary,
|
||||
|
@ -1233,6 +1246,7 @@ func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversion
|
|||
usedSystem := android.FilterListPred(sharedLibs, func(s string) bool {
|
||||
return android.InList(s, soongSystemSharedLibs) && !android.InList(s, excludeSharedLibs)
|
||||
})
|
||||
|
||||
for _, el := range usedSystem {
|
||||
if la.usedSystemDynamicDepAsDynamicDep == nil {
|
||||
la.usedSystemDynamicDepAsDynamicDep = map[string]bool{}
|
||||
|
@ -1625,6 +1639,15 @@ func (la *linkerAttributes) finalize(ctx android.BazelConversionPathContext) {
|
|||
}
|
||||
la.implementationDynamicDeps.Exclude(bazel.OsAndInApexAxis, bazel.AndroidPlatform, bazel.MakeLabelList(stubsToRemove))
|
||||
}
|
||||
if la.systemDynamicDeps.IsNil() && len(la.usedSystemDynamicDepAsStaticDep) > 0 {
|
||||
toRemove := bazelLabelForStaticDeps(ctx, android.SortedKeys(la.usedSystemDynamicDepAsStaticDep))
|
||||
la.deps.Exclude(bazel.NoConfigAxis, "", toRemove)
|
||||
la.deps.Exclude(bazel.OsConfigurationAxis, "android", toRemove)
|
||||
la.deps.Exclude(bazel.OsConfigurationAxis, "linux_bionic", toRemove)
|
||||
la.implementationDeps.Exclude(bazel.NoConfigAxis, "", toRemove)
|
||||
la.implementationDeps.Exclude(bazel.OsConfigurationAxis, "android", toRemove)
|
||||
la.implementationDeps.Exclude(bazel.OsConfigurationAxis, "linux_bionic", toRemove)
|
||||
}
|
||||
|
||||
la.deps.ResolveExcludes()
|
||||
la.implementationDeps.ResolveExcludes()
|
||||
|
|
Loading…
Reference in a new issue