Merge "Disable LTO and CFI for riscv64"
diff --git a/cc/lto.go b/cc/lto.go
index 581856b..e068b05 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -91,6 +91,11 @@
 		return flags
 	}
 
+	// LTO doesn't work on riscv64 yet.
+	if ctx.Arch().ArchType == android.Riscv64 {
+		return flags
+	}
+
 	if lto.LTO(ctx) {
 		var ltoCFlag string
 		var ltoLdFlag string
diff --git a/cc/sanitize.go b/cc/sanitize.go
index a446cbb..ecbc6a3 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -511,6 +511,12 @@
 		s.Integer_overflow = nil
 	}
 
+	// CFI doesn't work for riscv64 yet because LTO doesn't work.
+	if ctx.Arch().ArchType == android.Riscv64 {
+		s.Cfi = nil
+		s.Diag.Cfi = nil
+	}
+
 	// Disable CFI for musl
 	if ctx.toolchain().Musl() {
 		s.Cfi = nil