Only allowlist cfi enabled modules for apex variant.

Bug: 286224058
Test: lunch aosp_bramble-userdebug && m --skip-soong-tests nothing --bazel-mode-staging
Change-Id: Ida3287ee718dc868a46b625f82c352029734a724
This commit is contained in:
Yu Liu
2023-06-07 12:43:26 -07:00
parent e02112615e
commit 8860c6c114

View File

@@ -1913,14 +1913,14 @@ func (c *Module) QueueBazelCall(ctx android.BaseModuleContext) {
// IsMixedBuildSupported returns true if the module should be analyzed by Bazel
// in any of the --bazel-mode(s).
func (c *Module) IsMixedBuildSupported(ctx android.BaseModuleContext) bool {
if !allEnabledSanitizersSupportedByBazel(c) {
if !allEnabledSanitizersSupportedByBazel(ctx, c) {
//TODO(b/278772861) support sanitizers in Bazel rules
return false
}
return c.bazelHandler != nil
}
func allEnabledSanitizersSupportedByBazel(c *Module) bool {
func allEnabledSanitizersSupportedByBazel(ctx android.BaseModuleContext, c *Module) bool {
if c.sanitize == nil {
return true
}
@@ -1943,12 +1943,17 @@ func allEnabledSanitizersSupportedByBazel(c *Module) bool {
// TODO(b/261058727): enable mixed builds for all modules with UBSan
// Currently we can only support ubsan when minimum runtime is used.
ubsanEnabled := Bool(sanitizeProps.Integer_overflow) || len(sanitizeProps.Misc_undefined) > 0
if ubsanEnabled && !c.MinimalRuntimeNeeded() {
return false
if !ubsanEnabled || c.MinimalRuntimeNeeded() {
continue
}
} else if san == cfi {
continue
} else if c.sanitize.isSanitizerEnabled(san) {
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
// Only allow cfi if this is an apex variant
if !apexInfo.IsForPlatform() {
continue
}
}
if c.sanitize.isSanitizerEnabled(san) {
return false
}
}