Merge "Make java_fuzz_host not implement Sanitizeable." am: 53c6c67cbb am: 2928c292e6

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2096734

Change-Id: I1827cc21a64596be2af5760519d755c078658383
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Lukács T. Berki 2022-05-18 07:33:06 +00:00 committed by Automerger Merge Worker
commit 5258c42167
2 changed files with 16 additions and 39 deletions

View file

@ -968,23 +968,21 @@ func sanitizerDepsMutator(t SanitizerType) func(android.TopDownMutatorContext) {
return true
})
}
} else if sanitizeable, ok := mctx.Module().(Sanitizeable); ok {
} else if jniSanitizeable, ok := mctx.Module().(JniSanitizeable); ok {
// If it's a Java module with native dependencies through jni,
// set the sanitizer for them
if jniSanitizeable, ok := mctx.Module().(JniSanitizeable); ok {
if jniSanitizeable.IsSanitizerEnabledForJni(mctx, t.name()) {
mctx.VisitDirectDeps(func(child android.Module) {
if c, ok := child.(PlatformSanitizeable); ok &&
mctx.OtherModuleDependencyTag(child) == JniFuzzLibTag &&
c.SanitizePropDefined() &&
!c.SanitizeNever() &&
!c.IsSanitizerExplicitlyDisabled(t) {
c.SetSanitizeDep(true)
}
})
}
if jniSanitizeable.IsSanitizerEnabledForJni(mctx, t.name()) {
mctx.VisitDirectDeps(func(child android.Module) {
if c, ok := child.(PlatformSanitizeable); ok &&
mctx.OtherModuleDependencyTag(child) == JniFuzzLibTag &&
c.SanitizePropDefined() &&
!c.SanitizeNever() &&
!c.IsSanitizerExplicitlyDisabled(t) {
c.SetSanitizeDep(true)
}
})
}
} else if sanitizeable, ok := mctx.Module().(Sanitizeable); ok {
// If an APEX module includes a lib which is enabled for a sanitizer T, then
// the APEX module is also enabled for the same sanitizer type.
mctx.VisitDirectDeps(func(child android.Module) {
@ -1529,12 +1527,10 @@ func enableMinimalRuntime(sanitize *sanitize) bool {
if !Bool(sanitize.Properties.Sanitize.Address) &&
!Bool(sanitize.Properties.Sanitize.Hwaddress) &&
!Bool(sanitize.Properties.Sanitize.Fuzzer) &&
(Bool(sanitize.Properties.Sanitize.Integer_overflow) ||
len(sanitize.Properties.Sanitize.Misc_undefined) > 0 ||
Bool(sanitize.Properties.Sanitize.Undefined) ||
Bool(sanitize.Properties.Sanitize.All_undefined)) &&
!(Bool(sanitize.Properties.Sanitize.Diag.Integer_overflow) ||
Bool(sanitize.Properties.Sanitize.Diag.Cfi) ||
Bool(sanitize.Properties.Sanitize.Diag.Undefined) ||

View file

@ -50,9 +50,10 @@ type JavaFuzzLibrary struct {
jniFilePaths android.Paths
}
// IsSanitizerEnabled implemented to make JavaFuzzLibrary implement
// cc.Sanitizeable
func (j *JavaFuzzLibrary) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
// IsSanitizerEnabledForJni implemented to make JavaFuzzLibrary implement
// cc.JniSanitizeable. It returns a bool for whether a cc dependency should be
// sanitized for the given sanitizer or not.
func (j *JavaFuzzLibrary) IsSanitizerEnabledForJni(ctx android.BaseModuleContext, sanitizerName string) bool {
for _, s := range j.jniProperties.Sanitizers {
if sanitizerName == s {
return true
@ -61,26 +62,6 @@ func (j *JavaFuzzLibrary) IsSanitizerEnabled(ctx android.BaseModuleContext, sani
return false
}
// IsSanitizerEnabledForJni implemented to make JavaFuzzLibrary implement
// cc.JniSanitizeable. It returns a bool for whether a cc dependency should be
// sanitized for the given sanitizer or not.
func (j *JavaFuzzLibrary) IsSanitizerEnabledForJni(ctx android.BaseModuleContext, sanitizerName string) bool {
return j.IsSanitizerEnabled(ctx, sanitizerName)
}
// EnableSanitizer implemented to make JavaFuzzLibrary implement
// cc.Sanitizeable
func (j *JavaFuzzLibrary) EnableSanitizer(sanitizerName string) {
}
// AddSanitizerDependencies implemented to make JavaFuzzLibrary implement
// cc.Sanitizeable
func (j *JavaFuzzLibrary) AddSanitizerDependencies(mctx android.BottomUpMutatorContext, sanitizerName string) {
}
// To verify that JavaFuzzLibrary implements cc.Sanitizeable
var _ cc.Sanitizeable = (*JavaFuzzLibrary)(nil)
func (j *JavaFuzzLibrary) DepsMutator(mctx android.BottomUpMutatorContext) {
if len(j.jniProperties.Jni_libs) > 0 {
if j.fuzzPackagedModule.FuzzProperties.Fuzz_config == nil {