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
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 300bc8f..33e4a4a 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -714,8 +714,14 @@
}
func isSanitizableDependencyTag(tag blueprint.DependencyTag) bool {
- t, ok := tag.(DependencyTag)
- return ok && t.Library || t == reuseObjTag || t == objDepTag
+ switch t := tag.(type) {
+ case dependencyTag:
+ return t == reuseObjTag || t == objDepTag
+ case libraryDependencyTag:
+ return true
+ default:
+ return false
+ }
}
// Propagate sanitizer requirements down from binaries
@@ -957,10 +963,11 @@
}
// static executable gets static runtime libs
+ depTag := libraryDependencyTag{Kind: staticLibraryDependency}
mctx.AddFarVariationDependencies(append(mctx.Target().Variations(), []blueprint.Variation{
{Mutator: "link", Variation: "static"},
c.ImageVariation(),
- }...), StaticDepTag, deps...)
+ }...), depTag, deps...)
} else if !c.static() && !c.header() {
// If we're using snapshots and in vendor, redirect to snapshot whenever possible
if c.VndkVersion() == mctx.DeviceConfig().VndkVersion() {
@@ -971,10 +978,11 @@
}
// dynamic executable and shared libs get shared runtime libs
+ depTag := libraryDependencyTag{Kind: sharedLibraryDependency, Order: earlyLibraryDependency}
mctx.AddFarVariationDependencies(append(mctx.Target().Variations(), []blueprint.Variation{
{Mutator: "link", Variation: "shared"},
c.ImageVariation(),
- }...), earlySharedDepTag, runtimeLibrary)
+ }...), depTag, runtimeLibrary)
}
// static lib does not have dependency to the runtime library. The
// dependency will be added to the executables or shared libs using