Pass -fno-sanitize=vptr,function for musl
The prebuilts for musl have the necessary symbols for vptr and function
sanitizers, but enabling them implicitly enables RTTI which causes RTTI
mismatch issues with dependencies.
Bug: 215802826
Test: m USE_HOST_MUSL=true host-native
Change-Id: I93edfd617d99efcac0eca58bb3f3c173c4fa121a
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 8e0813d..86472a2 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -710,8 +710,13 @@
// Host sanitizers only link symbols in the final executable, so
// there will always be undefined symbols in intermediate libraries.
_, flags.Global.LdFlags = removeFromList("-Wl,--no-undefined", flags.Global.LdFlags)
+ }
- // non-Bionic toolchain prebuilts are missing UBSan's vptr and function san
+ if !ctx.toolchain().Bionic() {
+ // non-Bionic toolchain prebuilts are missing UBSan's vptr and function san.
+ // Musl toolchain prebuilts have vptr and function sanitizers, but enabling them
+ // implicitly enables RTTI which causes RTTI mismatch issues with dependencies.
+
flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize=vptr,function")
}