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
diff --git a/cc/cc.go b/cc/cc.go
index 426bac8..f2c8525 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1913,14 +1913,14 @@
// 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 @@
// 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
}
}