Limit propagating san config of shared to fuzzer

Prior to refactoring the sanitizers to use transition mutators, only
fuzzer sanitizer propagated configuration to shared dependencies
https://android-review.googlesource.com/c/platform/build/soong/+/2123434/9/cc/sanitize.go#b1365
However, this expanded to include TSAN in the refactoring
https://android-review.googlesource.com/c/platform/build/soong/+/2123434/9/cc/sanitize.go#1068.

Fortunately, TSAN is never enabled via Android.bp files in AOSP, so
there was no regression, but we should restore to the prevous state.

Test: go tests
Change-Id: I1a5ad8d033f7a9b4f7578393a2eac7c9362ab6f7
This commit is contained in:
Liz Kammer
2022-10-31 10:31:11 -04:00
parent ba36441424
commit fd8a49fb9d
2 changed files with 303 additions and 69 deletions

View File

@@ -171,6 +171,20 @@ func (t SanitizerType) registerMutators(ctx android.RegisterMutatorsContext) {
}
}
// shouldPropagateToSharedLibraryDeps returns whether a sanitizer type should propagate to share
// dependencies. In most cases, sanitizers only propagate to static dependencies; however, some
// sanitizers also must be enabled for shared libraries for linking.
func (t SanitizerType) shouldPropagateToSharedLibraryDeps() bool {
switch t {
case Fuzzer:
// Typically, shared libs are not split. However, for fuzzer, we split even for shared libs
// because a library sanitized for fuzzer can't be linked from a library that isn't sanitized
// for fuzzer.
return true
default:
return false
}
}
func (*Module) SanitizerSupported(t SanitizerType) bool {
switch t {
case Asan:
@@ -1127,7 +1141,8 @@ func (s *sanitizerSplitMutator) IncomingTransition(ctx android.IncomingTransitio
return s.sanitizer.variationName()
}
if s.sanitizer == cfi || s.sanitizer == Hwasan || s.sanitizer == scs || s.sanitizer == Asan {
// Some sanitizers do not propagate to shared dependencies
if !s.sanitizer.shouldPropagateToSharedLibraryDeps() {
return ""
}
}