Merge "Disable no-vendor-variant VNDK for CFI modules"
diff --git a/cc/library.go b/cc/library.go
index 6c8f5bf..0bddab5 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1104,7 +1104,21 @@
 			if ctx.isVndkSp() {
 				library.baseInstaller.subDir = "vndk-sp"
 			} else if ctx.isVndk() {
-				if !ctx.mustUseVendorVariant() && !ctx.isVndkExt() {
+				mayUseCoreVariant := true
+
+				if ctx.mustUseVendorVariant() {
+					mayUseCoreVariant = false
+				}
+
+				if ctx.isVndkExt() {
+					mayUseCoreVariant = false
+				}
+
+				if ctx.Config().CFIEnabledForPath(ctx.ModuleDir()) && ctx.Arch().ArchType == android.Arm64 {
+					mayUseCoreVariant = false
+				}
+
+				if mayUseCoreVariant {
 					library.checkSameCoreVariant = true
 					if ctx.DeviceConfig().VndkUseCoreVariant() {
 						library.useCoreVariant = true