Add libraryDependencyTag to track dependencies on static and shared libraries
dependencyTag uses a set of predefined tags to identify different types of dependencies. There are already multiple bits of metadata stored in the dependency tag (Library, Shared, ReexportFlags), and supporting them all requires a combinatorial explosion of predefined tags and causes issues when using equality comparisons if a new bit of metadata is added. Add a new libraryDependencyTag type that will contain the metadata bits, and replace the quality comparisons with checks on the metadata bits. There are 5 TODOs where modifying the checks identified problems with the existing checks. These were left in place to produce identical build output and will be fixed separately. Bug: 162437057 Test: no change to build.ninja or {Android,make_vars,late}-${TARGET_PRODUCT}.mk Change-Id: I72d4207dcf381c07c92e00e5a03968ebb5ed8d30
This commit is contained in:
41
cc/lto.go
41
cc/lto.go
@@ -148,24 +148,33 @@ func ltoDepsMutator(mctx android.TopDownMutatorContext) {
|
||||
|
||||
mctx.WalkDeps(func(dep android.Module, parent android.Module) bool {
|
||||
tag := mctx.OtherModuleDependencyTag(dep)
|
||||
switch tag {
|
||||
case StaticDepTag, staticExportDepTag, lateStaticDepTag, wholeStaticDepTag, objDepTag, reuseObjTag:
|
||||
if dep, ok := dep.(*Module); ok && dep.lto != nil &&
|
||||
!dep.lto.Disabled() {
|
||||
if full && !Bool(dep.lto.Properties.Lto.Full) {
|
||||
dep.lto.Properties.FullDep = true
|
||||
}
|
||||
if thin && !Bool(dep.lto.Properties.Lto.Thin) {
|
||||
dep.lto.Properties.ThinDep = true
|
||||
}
|
||||
}
|
||||
|
||||
// Recursively walk static dependencies
|
||||
return true
|
||||
}
|
||||
libTag, isLibTag := tag.(libraryDependencyTag)
|
||||
|
||||
// Do not recurse down non-static dependencies
|
||||
return false
|
||||
if isLibTag {
|
||||
// TODO(ccross): the staticUnwinder check is there to maintain existing behavior
|
||||
// when adding libraryDependencyTag and should be removed.
|
||||
if !libTag.static() || libTag.staticUnwinder {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
if tag != objDepTag && tag != reuseObjTag {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if dep, ok := dep.(*Module); ok && dep.lto != nil &&
|
||||
!dep.lto.Disabled() {
|
||||
if full && !Bool(dep.lto.Properties.Lto.Full) {
|
||||
dep.lto.Properties.FullDep = true
|
||||
}
|
||||
if thin && !Bool(dep.lto.Properties.Lto.Thin) {
|
||||
dep.lto.Properties.ThinDep = true
|
||||
}
|
||||
}
|
||||
|
||||
// Recursively walk static dependencies
|
||||
return true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user