summaryrefslogtreecommitdiff
path: root/cc
diff options
context:
space:
mode:
author Martin Stjernholm <mast@google.com> 2020-10-06 02:36:43 +0100
committer Martin Stjernholm <mast@google.com> 2020-10-06 04:27:42 +0100
commit02460abb300390a2c8e27945bada21c7936ee7bd (patch)
treec3a5384802f80b5e11a3c07b3778d40a5745e534 /cc
parent66fee25c5b447df6e02adae3fa8b9a548b024130 (diff)
Avoid conflicting shared libraries from SDK snapshots.
Test: m nothing Test: env SANITIZE_HOST=address \ SANITIZE_TARGET='hwaddress fuzzer' \ build/soong/soong_ui.bash --make-mode \ TARGET_PRODUCT=blueline_hwasan haiku dist Bug: 170041398 Change-Id: Ifa4f72d6778cbb10663a780c7eb54b5e21d5b571
Diffstat (limited to 'cc')
-rw-r--r--cc/fuzz.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/cc/fuzz.go b/cc/fuzz.go
index 045384718..e81b40f54 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -167,7 +167,9 @@ func collectAllSharedDependencies(ctx android.SingletonContext, module android.M
// that should be installed in the fuzz target output directories. This function
// returns true, unless:
// - The module is not a shared library, or
-// - The module is a header, stub, or vendor-linked library.
+// - The module is a header, stub, or vendor-linked library, or
+// - The module is a prebuilt and its source is available, or
+// - The module is a versioned member of an SDK snapshot.
func isValidSharedDependency(dependency android.Module) bool {
// TODO(b/144090547): We should be parsing these modules using
// ModuleDependencyTag instead of the current brute-force checking.
@@ -190,6 +192,20 @@ func isValidSharedDependency(dependency android.Module) bool {
}
}
+ // If the same library is present both as source and a prebuilt we must pick
+ // only one to avoid a conflict. Always prefer the source since the prebuilt
+ // probably won't be built with sanitizers enabled.
+ if prebuilt, ok := dependency.(android.PrebuiltInterface); ok &&
+ prebuilt.Prebuilt() != nil && prebuilt.Prebuilt().SourceExists() {
+ return false
+ }
+
+ // Discard versioned members of SDK snapshots, because they will conflict with
+ // unversioned ones.
+ if sdkMember, ok := dependency.(android.SdkAware); ok && !sdkMember.ContainingSdk().Unversioned() {
+ return false
+ }
+
return true
}